/heal once - 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: /heal once (
/showthread.php?tid=125863)
/heal once -
John Rockie - 06.02.2010
Hi, how can i make /heal only work one time in one player life.
So when u die and respawn again you can use it only one time again.
Thanks.
Re: /heal once -
Miguel - 06.02.2010
Use a global variable:
pawn Код:
new Available[MAX_PLAYERS]; // 0 if it is and 1 if it is not available
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/heal", true) == 0)
{
if(Available[playerid] == 0) // we check if the commad is available
{
// this is the command effect (if the command is available)
Available[playerid] = 1; // this is one of the most important lines (we set the command unavailable)
}
else
{
SendClientMessage(playerid, COLOR, "You'll have to wait to use this command"); // this is what happen if it is not available
}
return 1;
}
return 0;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
Available[playerid] = 0; // we reset the variable, setting it back to available or "0"
return 1;
}
Re: /heal once -
John Rockie - 06.02.2010
Thanks Bud