PDA

View Full Version : Block commands in dm zone


Tadas
20/02/2014, 05:56 PM
Hello, how can I block commands in dm zone?

Tadas
20/02/2014, 06:49 PM
Anyone ? Please guys :/

MattTucker
20/02/2014, 07:07 PM
Can you explain "block commands"?

If you mean like if he the player is inside DM he can't use a command? If so, create a new variable

new inDM[MAX_PLAYERS]; Add it on top of your script and check the command that the player uses to join deathmatch

And add this inside the code

inDM[playerid] = 1;

After that, check the command you want to block, for example "/hi" (just for illustration)

CMD:hi(playerid, params[])
{
if(inDM[playerid] == 1) return SendClientMessage(playerid, -1, "You can't use this command while being in dm zone!");
GivePlayerMoney(playerid, 1000);
return 1;
}

Full code:
new inDM[MAX_PLAYERS]; // On top of the script

CMD:joindm(playerid, params[])
{
// bla bla bla bla
inDM[playerid] = 1; // You will need to place this line inside the code of the "joindm" or "dmzone" whatever it is
// bla bla bla bla ------- To define that the player is inside the DM zone.
return 1;
}

CMD:hi(playerid, params[])
{
if(inDM[playerid] == 1) return SendClientMessage(playerid, -1, "You can't use this command while being in dm zone!");
// The above line is simple, if the player inside the DM zone, it will "return" (A.K.A stopping the command for him)
// Sending that message.
GivePlayerMoney(playerid, 1000);
return 1;
}

Unfriendly
20/02/2014, 07:46 PM
You could try doing this using gangzones. Make invisible gangzones for the dm areas. Then check if a player is in any of those zones each time they do a command.

Tadas
21/02/2014, 02:06 PM
Thank you very much MattTucker!

+Rep for you :)

MattTucker
22/02/2014, 12:07 AM
Thank you very much MattTucker!

+Rep for you :)

Thank you :)