#1

Hey all. I want that you can't spam a command. How to check if this is still running?

Plant[playerid] = SetTimerEx("PlantTimer",10000,false,"i",playerid);
Reply
#2

Try adding this at the beginning of your PlantTimer function:
pawn Код:
Plant[playerid] = -1; // -1 means that the timer is not running for playerid
Then, when you want to check to see if the timer is running (in OnPlayerCommandText I assume), you can put this at the top:
pawn Код:
if(Plant[playerid] != -1) // Check to see if the timer is running for playerid
    return 1; // + SendClientMessage here if you want to tell the player "Do not spam commands" or w/e!
}

// Your code continues here
I don't know what timerids start at, so you might be able to set Plant[playerid] to 0 if they timerids start at 1. This would make the check to see if the timer is running prettier! Anyway...

Hope this helps!
Reply
#3

Quote:
Originally Posted by Benjo
Посмотреть сообщение
Try adding this at the beginning of your PlantTimer function:
pawn Код:
Plant[playerid] = -1; // -1 means that the timer is not running for playerid
Then, when you want to check to see if the timer is running (in OnPlayerCommandText I assume), you can put this at the top:
pawn Код:
if(Plant[playerid] != -1) // Check to see if the timer is running for playerid
    return 1; // + SendClientMessage here if you want to tell the player "Do not spam commands" or w/e!
}

// Your code continues here
I don't know what timerids start at, so you might be able to set Plant[playerid] to 0 if they timerids start at 1. This would make the check to see if the timer is running prettier! Anyway...

Hope this helps!
Haha. That I didn't think of this earlier :P Thanks mate
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
Why not just use GetTickCount and check the time elapsed since the last use?
I will look at that later. Thankyou. I now have another problem. You might want to read my thread about it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)