Headline / Gangs

Gangs for Jailbreak Servers Running SourceMod
GNU General Public License v3.0
17 stars 7 forks source link

Any way to disable Gang perks on certain rounds? #19

Closed Hexer10 closed 7 years ago

Hexer10 commented 7 years ago

Maybe a forward that get trigger on round start? Like: Gangs_OnPerksActived that can be returned to Plugin_Handle to disable giving on the perks?

public Action Gangs_OnPerksActivated(int client)
{
      if (bSpecialRound)
      {
            return Plugin_Handle; //Disable perks of the client
       }
       return Plugin_Continue; //Do nothink
}

This is just an idea.

Thanks.

Headline commented 7 years ago

Done

It's implementation will look like this

public void Gangs_OnPerksSetPre(int client, bool &shouldGive = true)
{
     if (!ShouldReceivePerks(client)) // should not receive perks
     {
            shouldGive = false;
     }
}
Headline commented 7 years ago

Let me know if/how it works and I'll close this. Thanks.

shanapu commented 7 years ago

won't work for me. Should not it be Action instead of void?

// myjailbreak_gangs.sp
//
// D:\Code\MyJailbreak\addons\sourcemod\scripting\include\hl_gangs.inc(120) : error 059: function argument may not have a default value (variable "shouldGive")
// D:\Code\MyJailbreak\addons\sourcemod\scripting\myjailbreak_gangs.sp(48) : error 059: function argument may not have a default value (variable "shouldGive")
// Includes
#include <sourcemod>
#include <hl_gangs>
#include <myjailbreak>

// Compiler Options
#pragma semicolon 1
#pragma newdecls required

public void Gangs_OnPerksSetPre(int client, bool &shouldGive = true)
{
    if (MyJailbreak_IsEventDayRunning())
    {
        shouldGive = false;
    }
}
Headline commented 7 years ago

Try this

// Includes
#include <sourcemod>
#include <hl_gangs>
#include <myjailbreak>

// Compiler Options
#pragma semicolon 1
#pragma newdecls required

public void Gangs_OnPerksSetPre(int client, bool &shouldGive)
{
    if (MyJailbreak_IsEventDayRunning())
    {
        shouldGive = false;
    }
}
Headline commented 7 years ago

Also remove = true from the include too

Headline commented 7 years ago

If you still have problems I can try something else

shanapu commented 7 years ago

hl_gangs.inc

/**
 * Called immediately before perks are given. Set shouldGive to false in order to skip giving perks.

 * @param int client index
 * @param &bool shouldGive
 * @noreturn
 */
forward void Gangs_OnPerksSetPre(int client, bool &shouldGive);

and

public void Gangs_OnPerksSetPre(int client, bool &shouldGive)
{
    if (MyJailbreak_IsEventDayRunning() || MyJailbreak_IsEventDayPlanned())
    {
        shouldGive = false;
    }
}

works great! Thanks for fast response!

Headline commented 7 years ago

No problem. Let me know if you have any more issues