Data comparison.
#1

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 ?
Reply
#2

BUMP!

Anyone ?
Reply
#3

pawn Код:
if ( TMn [ playerid ] <= LMin && TSc [ playerid ] <= LSec)
{
           //Functions.
}
Try this, maybe it work
Reply
#4

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.
Reply
#5

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 -
Код:
LMin = 1
LSec = 49
and I completed the round in -
Код:
TMn = 0
TSc = 53
So, it didn't detected it as a new record.
NOTE: I have debugged too.
Reply
#6

Quote:
Originally Posted by Ronaldo_raul™
Посмотреть сообщение
Nearly, but there is a bug.

Situation was -
Код:
LMin = 1
LSec = 49
and I completed the round in -
Код:
TMn = 0
TSc = 53
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
Reply
#7

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 ^^
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)