question about commands
#1

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

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

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

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
Reply
#5

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

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);

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)