Command Timer Help! - 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: Command Timer Help! (
/showthread.php?tid=243094)
Command Timer Help! -
Niko_boy - 21.03.2011
hi this is my code
pawn Code:
if(!strcmp("/vr", cmdtext, true))
{
{
if(IsPlayerInAnyVehicle(playerid))
{
new VehicleID;
VehicleID = GetPlayerVehicleID(playerid);
RepairVehicle(VehicleID);
return SendClientMessage(playerid, YELLOW," Sucessfully Fixed The Vehicle ");
}
else return SendClientMessage(playerid,RED,"ERROR: You are not in a Vehicle!");
}
return 1;
}
i wanna make command text timer like player cant use it again and again..
Like He Can Use It Only Once In 2 min and if he used it he must wait for 2 min.
_________________________________________
I have searched alot on forums but not got any solution . . . . . . . . . . . . . . . . . . . . . . . . . . . .
AW: Command Timer Help! -
Pablo Borsellino - 21.03.2011
Here, without any timers
At the top of the Script:
pawn Code:
new WaitTimeForCMD[MAX_PLAYERS];
OnPlayerCommandText:
pawn Code:
if(!strcmp("/vr", cmdtext, true))
{
if(IsPlayerInAnyVehicle(playerid))
{
if((GetTickCount()-WaitTimeForCMD[playerid])>120000)return SendClientMessage(playerid,RED,"ERROR: Wait 2Minutes to use this CMD again!");
new VehicleID;
VehicleID = GetPlayerVehicleID(playerid);
RepairVehicle(VehicleID);
WaitTimeForCMD[playerid]=GetTickCount();
return SendClientMessage(playerid,YELLOW," Sucessfully Fixed The Vehicle ");
}
else return SendClientMessage(playerid,RED,"ERROR: You are not in a Vehicle!");
}
Re: AW: Command Timer Help! -
Niko_boy - 21.03.2011
Quote:
Originally Posted by Pablo Borsellino
Here, without any timers
At the top of the Script:
pawn Code:
new WaitTimeForCMD[MAX_PLAYERS];
OnPlayerCommandText:
pawn Code:
if(!strcmp("/vr", cmdtext, true)) { if(IsPlayerInAnyVehicle(playerid)) { if((GetTickCount()-WaitTimeForCMD[playerid])>120000)return SendClientMessage(playerid,RED,"ERROR: Wait 2Minutes to use this CMD again!"); new VehicleID; VehicleID = GetPlayerVehicleID(playerid); RepairVehicle(VehicleID); WaitTimeForCMD[playerid]=GetTickCount(); return SendClientMessage(playerid,YELLOW," Sucessfully Fixed The Vehicle "); } else return SendClientMessage(playerid,RED,"ERROR: You are not in a Vehicle!"); }
|
what is gettickcount is that settimer
AW: Command Timer Help! -
Pablo Borsellino - 21.03.2011
No gettickcount is'nt SetTimer. Read »this«! A gettickcount is something like a timestamp gettime() but the timestamp starts from zero if the Server starts Its better for your ressources if you use this method and not SetTimer.