SA-MP Forums Archive
Disable all commands except one? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Disable all commands except one? (/showthread.php?tid=429283)



Disable all commands except one? - Morten_Guado - 08.04.2013

Hi, I'm trying to disable all comands except one from a filterscript.

Basicly, when a player enters to a DM, his commands are disabled, except /pm.

I'm using pVars because the DM is in the gamemode, but the /pm command is in a FS.

So, this is my code:

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(GetPVarInt(playerid,"InDM") ==1 && strcmp(cmdtext,"/pm") !=0)
    {
    return 1;
    }
return 0;
}
I use previous code because I don't want to put in all other commands:

pawn Code:
if(GetPVarInt(playerid,"InDM") ==1)
{
return 0;
}
It works fine. Disables all commands except /pm, but here is the problem:

If I type /pm, it shows a message with pm parameters, but if I type let's say "/pm 1" it doesn't work.
It's because the code only allows to type "/pm" not "/pm id".

My question is:

How can I disable all commands except /pm with its parameter, which is playerid?


Hope I've been clear.

Any help would be appreciated.
Thanks in advance.


Re: Disable all commands except one? - MP2 - 09.04.2013

Very easy. Put the command(s) you wish to have available at the top of OnPlayerCommandText.

Under that command:

pawn Code:
if(GetPVarInt(playerid, "InDM") == 1) return SendClientMessage(playerid, COLOR_RED, "Commands disabled in DM.");
Job's a good'un.


Re: Disable all commands except one? - Morten_Guado - 09.04.2013

Quote:
Originally Posted by MP2
View Post
Very easy. Put the command(s) you wish to have available at the top of OnPlayerCommandText.

Under that command:

pawn Code:
if(GetPVarInt(playerid, "InDM") == 1) return SendClientMessage(playerid, COLOR_RED, "Commands disabled in DM.");
Job's a good'un.
Thanks a lot!
It really worked.


Re: Disable all commands except one? - Scenario - 09.04.2013

For future reference, y_commands offers inbuilt features that could make this a MUCH easier task.