Some problems - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Some problems (
/showthread.php?tid=181727)
How to enable/disable some commands? - [L3th4l] - 07.10.2010
Simple question, when i put a player in a mini-game, how can i disable all cmds, but just enable 1 or 2?
Re: Some problems -
iggy1 - 07.10.2010
Put a check in on PlayerCommandText (or its equivalent) check if a player is in a mingame if he is, then compare the command to the commands you want to be enabled. If they are not the right ones return 0.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(InMinigame[playerid] == 1)
{
if(!strcmp(cmdtext,"/shop")true)//allow this command
{
//do somethnig
return 1;
}
return 0;//or you could send a message saying command not available in minigames
}
return 0;
}
EDIT: to disable all is very easy
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(InMinigame[playerid] == 1)return 0;//or you could send a message saying command not available in minigames
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
"InMinigame" being a variable that you initialise at 1 when a player enters a minigame.