Jump to content

Where to save top hunter data


drk

Recommended Posts

  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

How can I compare the time passed with the top time ?

                local time = exports.race:getTimePassed( ) 
                local min, sec = convertTime(time) 
  
                --if time is better than the top 1 
                theTime = executeSQLQuery( "SELECT time FROM Top WHERE map = '" ..mapName.. "'" ) 
                if time >= theTime[1]['time'] then 
                triggerEvent('onGotTop',source) 
  
                --update top 
                executeSQLQuery( "UPDATE Top SET player= '"..player.."', time= '"..min..":"..sec.."' WHERE map='"..mapName.."'" ) 

I don't know how I can compare because theTime[1]['time'] is a string :S

Link to comment
                local min, sec = convertTime(time) 
  
                --if time is better than the top 1 
                theTime = executeSQLQuery( "SELECT time FROM Top WHERE map = '" ..mapName.. "'" ) 
                local old = split(theTime[1]['time'],':') 
                if old[1] < time and old[2] < time then 
                triggerEvent('onGotTop',source) 
  
                --update top 
                executeSQLQuery( "UPDATE Top SET player= '"..player.."', time= '"..min..":"..sec.."' WHERE map='"..mapName.."'" ) 

But time variable is only one, if I compare with min and sec it will return string and I will get error "Attempt to compare string with number" :S

Link to comment
                local min, sec = convertTime(time) 
  
                --if time is better than the top 1 
                theTime = executeSQLQuery( "SELECT time FROM Top WHERE map = '" ..mapName.. "'" ) 
                local old = split(theTime[1]['time'],':') 
                if (tonumber(old[1]) < min and tonumber(old[2]) < sec) then 
                triggerEvent('onGotTop',source) 
  
                --update top 
                executeSQLQuery( "UPDATE Top SET player= '"..player.."', time= '"..min..":"..sec.."' WHERE map='"..mapName.."'" ) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...