drk Posted February 11, 2012 Author Posted February 11, 2012 How can I convert miliseconds to seconds ( ms outputed by getTimePassed() )??
Kenix Posted February 11, 2012 Posted February 11, 2012 function msToSeconds( int ) if type( int ) == 'number' then return int/1000 end return false end
drk Posted February 11, 2012 Author Posted February 11, 2012 msToSeconds ( time ) ? time = exports.race:getTimePassed()
drk Posted February 11, 2012 Author Posted February 11, 2012 It's possible to set the text of a dx text in server side ?
Kenix Posted February 11, 2012 Posted February 11, 2012 (edited) No. You need use setElementData/getElementData. Algorithm. Map started -> sql request if map have in table then setElementData -> get data -> draw in( onClientRender ). Edited February 12, 2012 by Guest
Kenix Posted February 11, 2012 Posted February 11, 2012 (edited) You can use https://wiki.multitheftauto.com/wiki/Ser ... _functions. But drawing functions in client side https://wiki.multitheftauto.com/wiki/Cli ... _functions better anyway. Edited February 11, 2012 by Guest
drk Posted February 11, 2012 Author Posted February 11, 2012 Now it working, but when I change the map and put the other again it don't gets my top. Appear: No one
Kenix Posted February 11, 2012 Posted February 11, 2012 Now it working, but when I change the map and put the other again it don't gets my top. Appear: No one Show code.
drk Posted February 11, 2012 Author Posted February 11, 2012 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
Castillo Posted February 11, 2012 Posted February 11, 2012 You can split the string and then compare it. Use: split
drk Posted February 12, 2012 Author Posted February 12, 2012 Like this? old = split(theTime[1]['time'],':')
Castillo Posted February 12, 2012 Posted February 12, 2012 local data = split(theTime[1]['time'], ':') if data[1] then print(data[1]) end if data[2] then print(data[2]) end
drk Posted February 12, 2012 Author Posted February 12, 2012 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"
Castillo Posted February 12, 2012 Posted February 12, 2012 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.."'" )
drk Posted February 12, 2012 Author Posted February 12, 2012 Thanks dude. It worked. Now I can solve my level system script error
drk Posted February 13, 2012 Author Posted February 13, 2012 How can I get the map name without using onGamemodeMapStart? Because when a player joins the player get Top name: False Time: False because no map has been started for the local.
Kenix Posted February 13, 2012 Posted February 13, 2012 function currentMapName( ) return getResourceName( exports[ 'mapmanager']:getRunningGamemodeMap( ) ) end
drk Posted February 13, 2012 Author Posted February 13, 2012 \õ/ MTA SA Wiki have this functions in Resources page?
Kenix Posted February 13, 2012 Posted February 13, 2012 https://wiki.multitheftauto.com/wiki/Mapmanager ?
drk Posted February 13, 2012 Author Posted February 13, 2012 Ye, thanks for all. I will start searching there before create a topic or reply with a noob question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now