In the DM mode how to prohibit players to use the command
#1

In the DM mode how to prohibit players to use the command
Reply
#2

Use if statement.
Reply
#3

If you are using OnPlayerCommandText, then simply return 0 or 1 whenever a player types one, must be on the top.
Example:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(dm_check[playerid]) return SendClientMessage(playerid, -1, "You cannot use commands while you are in DM.");
    return 1;
}
SendClientMessage always return 1, so no Unknown Command error will appear. In case you want to enable some commands. Declare this code under those commands. Make sure you have a returning value in those commands.

In case of zcmd, we'll do same but in zcmd's custom callback:
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(dm_check[playerid]) return SendClientMessage(playerid, -1, "You cannot use commands while you are in DM.");
    return 1;
}
NOTE: dm_check[playerid] is your variable or boolean which checks if the player is in deathmatch or not.

You can also perform those checks in each command.
Reply
#4

Quote:
Originally Posted by Gammix
Посмотреть сообщение
If you are using OnPlayerCommandText, then simply return 0 or 1 whenever a player types one, must be on the top.
Example:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(dm_check[playerid]) return SendClientMessage(playerid, -1, "You cannot use commands while you are in DM.");
    return 1;
}
SendClientMessage always return 1, so no Unknown Command error will appear. In case you want to enable some commands. Declare this code under those commands. Make sure you have a returning value in those commands.

In case of zcmd, we'll do same but in zcmd's custom callback:
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(dm_check[playerid]) return SendClientMessage(playerid, -1, "You cannot use commands while you are in DM.");
    return 1;
}
NOTE: dm_check[playerid] is your variable or boolean which checks if the player is in deathmatch or not.

You can also perform those checks in each command.
Thankes you
Reply
#5

D:\samp037_svr_R1_win32\gamemodes\pickup.pwn(103) : error 029: invalid expression, assumed zero
D:\samp037_svr_R1_win32\gamemodes\pickup.pwn(103) : warning 215: expression has no effect
D:\samp037_svr_R1_win32\gamemodes\pickup.pwn(103) : error 001: expected token: ";", but found "]"
D:\samp037_svr_R1_win32\gamemodes\pickup.pwn(103) : error 029: invalid expression, assumed zero
D:\samp037_svr_R1_win32\gamemodes\pickup.pwn(103) : fatal error 107: too many error messages on one line
Appear such errors?How do
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)