Help Add CMD limit in this system - 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: Help Add CMD limit in this system (
/showthread.php?tid=310420)
Help Add CMD limit in this system -
dickyodie - 12.01.2012
how to add time limit for this system so player must wait 1 second for use this system again
Код:
//-----------[barrel trap]----------------//
if (newkeys == KEY_SUBMISSION)
{
if(IsPlayerInAnyVehicle(playerid))
{
new
Float:x,
Float:y,
Float:z;
{
if(GetPlayerMoney(playerid) >= 2000)
{
GetPlayerPos(playerid, x, y, z);
CreateObject(1225,x,y,z, 0.00, 0.00, 0.00);
SendClientMessage(playerid,purple,"You have put a trap");
GivePlayerMoney(playerid, -2000);
}
else
{
SendClientMessage(playerid,purple,"You Dont Have Enough Money");
}
}
}
return 1;
SORRY MY BAD ENGLISH
Re: Help Add CMD limit in this system -
JamesC - 12.01.2012
There are several ways you can do this, all require you to create a variable to store the time when the player used the system last or if the player has used it. The first method is using a timer, when the command is successfully performed, set a player variable to 1 and
SetTimerEx for the desired amount of time to reset the variable. You can then write a conditional statement before to check if the variable equals 0, if not, don't do anything.
The second and third methods are closely related. Instead of a
boolean, you need to store the current tick count using
GetTickCount or a unix timestamp using
gettime when the command is successfully performed, then evaluate the variable against the count / time when the command is next performed.
I'm sure someone will come along and script the entire thing for you but I just wanted to encourage you to learn to do things by yourself.