Time counter for race?
#1

I've do a race with Streamer Incognito 2.6.1
It works perfectly but I don't know how to make a time counter
Example: I start the race and on finish of the race, a message that says: "Player" has finished the race in "1:00:00" minutes ( that's only a example of minutes )
What should I do?
Reply
#2

a race-time counter can be done even without timers - just use the checkpoints (assuming youre using (race)checkpoints) to trigger the GetTickCount() function. it returns the server uptime in milliseconds, this way you can let the server store the starting time. the value of the milliseconds doesnt matter at all:
as soon the player touches the end-checkpoint, simply subtract the start time from the (larger) end time: you will. get the duration between those 2 checkpoints.
pawn Код:
OnPlayerEnterRaceCheckpoint(playerid):
//start race condition = true (first checkpoint, player just joined the /race):
SetPVarInt(playerid,"RaceStartMS",GetTickCount());//store the server time (ms) in a pvar

//end race condition = true (last CP, this only should trigger at the very last CP):
SetPVarInt(playerid,"RaceEndMS",GetTickCount());//store the server time (ms) in another pvar
new TimeDifferenceMS=GetPVarInt(playerid,"RaceStartMS")-GetPVarInt(playerid,"RaceEndMS");
let it print out the result of GetTickCount()-GetPVarInt(playerid,"RaceStartMS") at any checkpoint, thats the fastest way to see why its so neat
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)