Time counter for race?
#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


Messages In This Thread
Time counter for race? - by Dovahkiin96 - 03.07.2012, 07:52
Re: Time counter for race? - by Babul - 03.07.2012, 09:22

Forum Jump:


Users browsing this thread: 2 Guest(s)