Disable all commands except one?
#1

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.
Reply
#2

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.
Reply
#3

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.
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)