Creating a timer
#1

is there any way of creating a timer without using forwards and new publics?

Thanks
Reply
#2

No There Is No Other Way. Don't Be Lazy Creating Publics And Forwards
Reply
#3

im not being lazy im tryin to figure a way of making a timer in a public becase i need the time to start on player spawn because its a death timer when the player dies they will be put in hospital for the set amount of time you get me?
Reply
#4

Yes there is but it is essentially re-inventing the wheel.

It involves many variables OnPlayerUpdate (Or another fast ticking function) and GetTickCount.
Reply
#5

it matters if you are on windows or another OC

in windows you just could use tickcount or GetTickcount

pawn Код:
new TimeAlive[MAX_PLAYERS];
pawn Код:
//OnPlayerSpawn
    TimeAlive[playerid] = tickcount();
pawn Код:
//OnPlayerDeath
    TimeAlive[playerid] = tickcount() - TimeAlive[playerid];
TimeAlive[playerid] stores, after the second call, the time in milliseconds between spawn and death


If you use any other OS in which tickcount() doesnt work you could use a reapeating 1 second timer

pawn Код:
//OnPlayerSpawn
    TimeAlive[playerid] = 0; // resets the tracker
pawn Код:
//Timer which gets called each second
    for(new i; i < MAX_PLAYERS; ++i) {
        TimeAlive[i]++;
    }
TimeAlive[playerid] stores in this case the time in seconds
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)