Block commands throughout the server
#1

Hello,
I have a little problem with a block command system, I searched for it but I couldn't find an answer.
So I decided to ask.
The problem is the following:

In my gamemode I have restricted players of using any kind of commands such as teleports, weapons and other things while they are in stunt or dm with " new BlockCMD[MAX_PLAYERS] = 0; ".
Everything works well when the commands are in the gamemode but once they are in a filterscript I can't block them.

So my question is, is there a way to block the commands globally once a players enters a stunt or dm zone even dough the commands are in a filterscript?

Here is some code so you guys understand what I'm talking about.

Code:
new BlockCMD[MAX_PLAYERS] = 0;

CMD:red(playerid,params[])
{
	if(BlockCMD[playerid] == 1)return SendClientMessage(playerid, X11_RED, "Command Block Activated to exit type /exit");
	SetPlayerColor(playerid, X11_RED);
	return 1;
}
PD: I tried putting the " new BlockCMD[MAX_PLAYERS] = 0; " in a include but that didn't workout.

I hope you guys could help me.
Thanks
Caribe88
Reply
#2

Yes, using player variables.
Reply
#3

Thanks for the answer I've never used them before could you explain a little how they work?

Edit: I looked at the examples but don't see how to use them jet i will search if there is a tutorial or something on how to use them
Reply
#4

Sorry for double post but i could not find any example of how to use player variables.
Reply
#5

You could try this out

pawn Code:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(IsInEvent[playerid] && strfind(cmdtext, "LeaveEvent", true) == -1)
    {
        SendClientMessage(playerid, 0xCC0000AA, "You can't use commands in an event!")
        return 0;
    }
    return 1;
}



Also, PVars are basically the same as new IsInEvent[MAX_PLAYERS] = 0;

pawn Code:
CMD:vartest(playerid)
{
    SetPVarInt(playerid, "SomeVar", 0);
    printf("Somevar: %i", GetPVarInt(playerid, "SomeVar"));
    return 1;
}
That's an example
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)