Data comparison. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Data comparison. (
/showthread.php?tid=388167)
Data comparison. -
Ronaldo_raul™ - 27.10.2012
I am making "Best Times" and I wanna compare variables and get the best time. So, assume
LMin and
LSec is the varaible in which I loaded the the times from the database and
TMn and
TSc is the player variables which have the data that the time taken by the player.
So, I tried many things to compare the variables.
pawn Код:
if ( LMin >= TMn [ playerid ] && LSec >= TSc [ playerid ] )
{
//Functions.
}
I want to get the Best Time, so anyone can help ?
Re: Data comparison. -
Ronaldo_raul™ - 28.10.2012
BUMP!
Anyone ?
Re: Data comparison. -
AK47317 - 28.10.2012
pawn Код:
if ( TMn [ playerid ] <= LMin && TSc [ playerid ] <= LSec)
{
//Functions.
}
Try this, maybe it work
Re: Data comparison. -
Ainseri - 28.10.2012
Quote:
Originally Posted by AK47317
pawn Код:
if ( TMn [ playerid ] <= LMin && TSc [ playerid ] <= LSec) { //Functions. }
Try this, maybe it work
|
I think this is definitely the best way.
Re: Data comparison. -
Ronaldo_raul™ - 28.10.2012
Quote:
Originally Posted by AK47317
pawn Код:
if ( TMn [ playerid ] <= LMin && TSc [ playerid ] <= LSec) { //Functions. }
Try this, maybe it work
|
Nearly, but there is a bug.
Situation was -
and I completed the round in -
So, it didn't detected it as a new record.
NOTE: I have debugged too.
AW: Re: Data comparison. -
Nero_3D - 28.10.2012
Quote:
Originally Posted by Ronaldo_raul™
Nearly, but there is a bug.
Situation was -
and I completed the round in -
So, it didn't detected it as a new record.
NOTE: I have debugged too.
|
The best thing would be to store and save the seconds (including the minutes)
So you only need one variable instead of two for each player (would save (MAX_PLAYERS + 1) cells)
To your problem, that should do the job
pawn Код:
if ((TMn [ playerid ] < LMin) || (TMn [ playerid ] == LMin && TSc [ playerid ] < LSec)) {}
or if you change it into seconds
pawn Код:
if((TMn [ playerid ] * 60 + TSc [ playerid ]) < (LMin * 60 + LSec)) {}
I dont know which one is faster but just using seconds at all would be better
Re: AW: Re: Data comparison. -
Ronaldo_raul™ - 28.10.2012
Quote:
Originally Posted by Nero_3D
The best thing would be to store and save the seconds (including the minutes)
So you only need one variable instead of two for each player (would save (MAX_PLAYERS + 1) cells)
To your problem, that should do the job
pawn Код:
if ((TMn [ playerid ] < LMin) || (TMn [ playerid ] == LMin && TSc [ playerid ] < LSec)) {}
or if you change it into seconds
pawn Код:
if((TMn [ playerid ] * 60 + TSc [ playerid ]) < (LMin * 60 + LSec)) {}
I dont know which one is faster but just using seconds at all would be better
|
OH! MY GOD, Thank you so much. Seems, the second method looks faster (Haven't tested yet.)
@AK47317, Thank you for trying.
+rep to all of you ^^