Sync 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: Sync Command (
/showthread.php?tid=513165)
Sync Command -
Blackazur - 14.05.2014
Hello, how can i make that you must use wait all 3 minutes to use this command?
Код:
CMD:sync(playerid)
{
ClearAnimations(playerid);
return 1;
}
Re: Sync Command -
Ciandlah - 14.05.2014
Add a variable thats disables usage then set a timer to enable it. Simple
Re: Sync Command -
Madd92 - 14.05.2014
Create a variable for every user and save the unix timestamp (
gettime() + 3 * 60) when the command is executed and test if when it is executed again, the saved timestamp is bigger than the one
gettime() returns then. If it is, give them a message or what ever that he has to wait.
Edit: please don't use a timer, it's not necessary and takes up a lot of performance for many users/commands.
Re: Sync Command -
Abagail - 14.05.2014
pawn Код:
CMD:sync(playerid, params[])
{
if(SyncTimer == 0) {
SyncTimer[playerid] = 180;
ClearAnimations(playerid);
}
else return SendClientMessage(playerid, -1, "You must wait %d seconds before using this command again.", SyncTimer);
return 1;
}
timer UpdateSyncTimer[1000](playerid)
{
if(SyncTimer > 0) SyncTimer--;
return 1;
}
Re: Sync Command -
Ciandlah - 14.05.2014
Why use timestamp? settimer is much easier
Re: Sync Command -
Madd92 - 14.05.2014
Quote:
Originally Posted by Abagail
pawn Код:
CMD:sync(playerid, params[]) { if(SyncTimer == 0) { SyncTimer[playerid] = 180; ClearAnimations(playerid); } else return SendClientMessage(playerid, -1, "You must wait %d seconds before using this command again.", SyncTimer); return 1; }
timer UpdateSyncTimer[1000](playerid) { if(SyncTimer > 0) SyncTimer--; return 1; }
|
Quote:
Originally Posted by Ciandlah
Why use timestamp? settimer is much easier
|
Why use a timer? You really don't need it and it slows down your whole game mode especially if you have many players or several different commands with timeouts. And it's not even easier...
I recommend not to use timers where ever you don't need them. Performance over memory. But if you do, please do not complain about your server lagging.
Re: Sync Command -
Vince - 14.05.2014
Quote:
Originally Posted by Ciandlah
Why use timestamp? settimer is much easier
|
Why learn to drive a car? Pedaling a bike is much easier.
Re: Sync Command -
Beckett - 14.05.2014
Read
this.