Help: gettickcount
#1

i tried to make this.. but dosent work... what is wrong ?

pawn Код:
new
    TimeTickCount[MAX_PLAYERS];
// ...

if(variable[playerid] != 0)
{
    // Functions here

    TimeTickCount[playerid] = GetTickCount();

    if(GetTickCount() - TimeTickCount[playerid] == 4)
    {
        // Functions here

        return 1;
    }

    return 1;
}
Reply
#2

What are you even trying to do? If you're following the tutorial by Southclaw, I suggest you re-read it a bit more thoroughly...
Reply
#3

yes.. i have read the tutorial by southclaw... i re-read now
Reply
#4

if you compare a player-saved timestamp with the GetTickCount, then its a good idea to change the == to a >=
pawn Код:
if(variable[playerid] != 0)
{
    // Functions here
    if(GetTickCount() - TimeTickCount[playerid] >= 4000)
    {
        TimeTickCount[playerid] = GetTickCount();//save the new servertime after the command: the player has to wait 4 seconds in order to pass the second command execution
        // Functions here
        return 1;
    }
    return 1;
}
this prevents the function execution to at least 4 ms in between. do you want a delay of 4 seconds btw? if so, change the 4 to 4000 - its milliseconds.
Reply
#5

dosent work.. your code..

this is the function with a timer

pawn Код:
if(user_vehicle[playerid] != 0)
{
    GameTextForPlayer(playerid, "Respawning...", 4000, 1);
    SetTimerEx("ResetCamera", 4000, false, "i", playerid);
   
    // ...
}

forward ResetCamera(playerid);
public ResetCamera(playerid)
{
   
    // ...
}
how to transform it ?
Reply
#6

as far i can see, the player is supposed to respawn after 4 seconds, after doing.. what? a timer is only required if the script cant expect any input from a player (like a repeating /command, where the script can evaluate the time differences between), which seems not to be the case after dying/waiting to spawn.
does the user_vehicle[playerid] check gets called by a command, entering a checkpoiint/pickup?
if you cant connect the upper action to be called by another one, then you are almost forced to use a timer ><

oh, how to transform? best way: save the script (add the current date to the filename, so you will keep that backup), save it again with the old name (else you'll work with/quick-save the backup), then erase all timer relating stuff, and compledetly rewrite it.
using the GetTickCount depends on any other script running so it can compare the saved player-tick with the actual..
lets watch your post above: time= 11:10
if you would bump it @ 11:11, then its 1 minute between. too few to be honest ^^
the formula works simple:
if you post, then the time gets saved in your variable: 11:10.
after some time (without any interaction between you<->forum), you post again.
the server subtracts the actual time (11:11, which is indeed "bigger") minus yours (11.10), and the result is simply the difference.
since you had to DO the interaction (post to start time calculation), the server "knows" when, and how long it took you to spam
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)