[REP+]count the seconds/minutes from start to finish of race?
#1

hey guys,

i searched on ****** for this but couldnt specifically find this...

my question is:

how to make it that when a player starts at his race( i have a command for that etc, i just need a timer with right funcs) a timer gets started and when he reaches the finish(also have a thingy for that under onplayerupdate ) that the timer stops and checks the time it took the player to reach the finish...
and if the time is faster then the fastest driven time of that race it says to EVERYONE online that the record is broken and also what the previous time was and what the new highscore is... so something like this comes ingame:

Player [drifters]niels has broken the record of Niels44 with a time of 1 minute and 12 seconds, previous record was: 1 minute and 15 seconds.


how can i make this?

greets niels

also REP+ for the ones who help me
Reply
#2

Do you need milliseconds as well? If not, then something simple like this may suffice:
pawn Код:
new
    gStartTime[MAX_PLAYERS];

// Start
gStartTime[playerid] = gettime();

// Finish
new
    totalSeconds = gettime() - gStartTime[playerid],
    seconds = totalSeconds % 60,
    minutes = (totalSeconds - seconds) / 60;

printf("Finished in %d minutes and %d seconds", minutes, seconds);
Reply
#3

hmm thnx i hope it will work , also i cant get on my server files atm, but whne i can, ill test it , if works, you get REP+

EDIT: yup works thnx i will REP+ you now ,

also how to make it that it saves the highscore of the race to a file(with dini or y_ini or wutever), and when a player beats that time it RE-saves it and also sends a msg to everyone that the record is broken?
Reply
#4

anyone?
Reply
#5

lol how many times i have to bump this thread? XD

ow for the case you dont know what my seconds question was, it was in my previous msgs:

Quote:

also how to make it that it saves the highscore of the race to a file(with dini or y_ini or wutever), and when a player beats that time it RE-saves it and also sends a msg to everyone that the record is broken?

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)