Sync Command
#1

Hello, how can i make that you must use wait all 3 minutes to use this command?

Код:
CMD:sync(playerid)
{
    ClearAnimations(playerid);
	return 1;
}
Reply
#2

Add a variable thats disables usage then set a timer to enable it. Simple
Reply
#3

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.
Reply
#4

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;
}
Reply
#5

Why use timestamp? settimer is much easier
Reply
#6

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.
Reply
#7

Quote:
Originally Posted by Ciandlah
Посмотреть сообщение
Why use timestamp? settimer is much easier
Why learn to drive a car? Pedaling a bike is much easier.
Reply
#8

Read this.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)