SA-MP Forums Archive
question about commands - 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: question about commands (/showthread.php?tid=428388)



question about commands - HurtLocker - 05.04.2013

Is there any way to detect if a player enters command (/**)? What I want to do is a player who is in dm the only command he can enters is /exitdm. If he is in dm and enters a command (not /exitdm) then a message returns that he cant use commands in dm.


Re: question about commands - L.Hudson - 05.04.2013

Just create a variable like
pawn Код:
new IsInDM[MAX_PLAYERS];
and on each command put
pawn Код:
if(IsInDM[playerid]) return SendClientMessage(playerid, -1, "You are not allowed to enter commands in a DM.");



Re: question about commands - SilverKiller - 05.04.2013

Make :

pawn Код:
new DM[MAX_PLAYERS]; // At Top
In OnPlayerConnect :

pawn Код:
DM[playerid] = 0;
And in your command :

pawn Код:
DM[playerid] = 1;
Then in the other commands where we will block the command if he is in the DM :

pawn Код:
if(DM[playerid] == 1) return SendClientMessage(playerid, -1, "You can't use this command in a DeathMatch!");
And in /exitdm add :

pawn Код:
DM[playerid] = 0;
Hope i helped.

EDIT : Too late.


Re: question about commands - HurtLocker - 05.04.2013

Your both solutions have a lot of work for my gm's commands which are a lot. I had already thought of this way... Thanks anyway. Geia soy patrioti. Both locations: GetPlayerPos(playerid); xD


Re: question about commands - Ronaldo_raul™ - 05.04.2013

To detect the command entered by player:
Are you using ZCMD ?

Do not allow player to use any command except /exitdm:
What is the variable or Bool you are using to check if the player is in DMing area or not ?

pawn Код:
if ( IsInDM == 1 ) return SendClientMessage ( playerid , -1 , "You are not allowed to use this command while being in a DMing area!" ) ;
Replace IsInDM with your variable.


Re: question about commands - Pottus - 05.04.2013

Try making a nice define like this....

Код:
#define IN_DM(%0) if(IsInDM[%0]) return SendClientMessage(%0, -1, "You are not allowed to enter commands in a DM.");
Then slap it in your commands by far the cleanest easiest and fastest way....

Код:
CMD:mycommand(playerid, arg[])
{
    IN_DM(playerid);

}