Timer for a command - 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)
+--- Thread: Timer for a command (
/showthread.php?tid=619082)
Timer for a command -
Gotham - 13.10.2016
Hi guys,
I want to create a timer so that the player will not abuse that command.In this case it's a heal command
so, if you want the code I will paste it (I think it is unnecessary).
Re: Timer for a command -
StrikerZ - 13.10.2016
PHP код:
new Healstop; //on top of script
CMD:heal(playerid, params[])//your command here
{
if(Healstop > gettime())
{
SendClientMessage(playerid, -1 ,"You need to wait 1 minute before using /heal again");
}
else
{
//your code here
Healstop = gettime() + 60;
}
return 1;
}
Re: Timer for a command -
Gotham - 13.10.2016
Where should I add "setplayerhealth" then?
Edit:Sorry didn't pay good attention.Thanks!
Re: Timer for a command -
Hunud - 13.10.2016
Inside command
Re: Timer for a command -
StrikerZ - 13.10.2016
PHP код:
CMD:heal(playerid, params[])
{
if(Healstop > gettime())
{
SendClientMessage(playerid, -1 ,"You need to wait 1 minute before using /heal again");
}
else
{
//ADD your command code here setplayerhealth and all other things
Healstop = gettime() + 60;
}
return 1;
}
Re: Timer for a command -
Dayrion - 13.10.2016
This will block the command for everybody and not per player.
PHP код:
new HealTime[MAX_PLAYERS];
CMD:heal(playerid, params[])
{
if(HealTime[playerid] > gettime())
{
SendClientMessage(playerid, -1 ,"You need to wait 1 minute before using /heal again");
}
else
{
//ADD your command code here setplayerhealth and all other things
HealTime[playerid] = gettime() + 60;
}
return 1;
}
Re: Timer for a command -
Gotham - 13.10.2016
Don't you guys read the "Edit"?._., anyways thanks to all