03.09.2017, 04:55
(
Последний раз редактировалось Paulice; 03.09.2017 в 20:49.
Причина: Implemented the use of DeletePVar
)
Here's some code you can use to disable individual commands:
PHP код:
#include <sscanf>
#include <zcmd>
public OnPlayerCommandReceived(playerid, cmdtext[])
{
new cmd[29], null;
sscanf(cmdtext, "s[29]i", cmd, null);
if(GetPVarInt(playerid, cmd))
{
SendClientMessage(playerid, 0xFF0000FF, "That command is disabled for you!");
return 0;
}
return 1;
}
CMD:disable(playerid, params[])
{
if(isnull(params))
{
SendClientMessage(playerid, 0xFF0000FF, "Usage: /disable (/command)");
}
else if(!IsValidCommand(params))
{
SendClientMessage(playerid, 0xFF0000FF, "Please enter a valid command!");
}
else
{
SetPVarInt(playerid, params, 1);
SendClientMessage(playerid, 0xFFF000FF, "You have disabled a command for yourself!");
}
return 1;
}
CMD:enable(playerid, params[])
{
if(isnull(params))
{
SendClientMessage(playerid, 0xFF0000FF, "Usage: /enable (/command)");
}
else if(!IsValidCommand(params))
{
SendClientMessage(playerid, 0xFF0000FF, "Please enter a valid command!");
}
else
{
DeletePVar(playerid, params); // can also be SetPVarInt(playerid, params, 0); but not recommended as PVars are limited
SendClientMessage(playerid, 0xFFF000FF, "You have enabled a command for yourself!");
}
return 1;
}
CMD:cmd1(playerid, params[])
{
SendClientMessage(playerid, 0xFFF000FF, "You have used /cmd1!");
return 1;
}
CMD:cmd2(playerid, params[])
{
SendClientMessage(playerid, 0xFFF000FF, "You have used /cmd2!");
return 1;
}
IsValidCommand(const command[])
{
if(command[0] == EOS || command[0] != '/' || strlen(command) > 28 || strfind(command, " ", true) != -1)
{
return false;
}
return true;
}