How to make text wait before it appears
#1

So,hi, i am new to scripting, and i was searching for this this. But didn't found anything about it, so i would like to get small help with this thing. Anyone knows how to make text appear little bit later with pause after pressing hotkey button? In my case i would like make little pause after pressing N button for lights so players wouldn't do spam, by pressing N button again and again...
Reply
#2

https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange

That's what you need.
Reply
#3

If you don't want players to spam, then an anti spam would be the solution:

GetTickCount() returns the amount of milliseconds since server started, you can do the following

pawn Код:
if(KEYS == KEY_NO)
{
    if(GetPVarInt(playerid,"lastpress") > GetTickCount())
             return 1;

    // insert your code

    SetPVarInt(playerid,"lastpress", GetTickCount()+500); //500 MS before the function can be executed again.

}
You assign a variable the current time+500 MS. When the key is pressed again, it will check if the current time is less than that variable that you previously set, and this means that 500 MS haven't passed.
By using timers, without this kind of checks what you're going to achieve is that the timer gets sent multiple times.

However if you just want to delay the action (players would still be able to spam it), refeer to the post above.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)