drk Posted February 11, 2012 Author Share Posted February 11, 2012 How can I convert miliseconds to seconds ( ms outputed by getTimePassed() )?? Link to comment
Kenix Posted February 11, 2012 Share Posted February 11, 2012 function msToSeconds( int ) if type( int ) == 'number' then return int/1000 end return false end Link to comment
drk Posted February 11, 2012 Author Share Posted February 11, 2012 msToSeconds ( time ) ? time = exports.race:getTimePassed() Link to comment
drk Posted February 11, 2012 Author Share Posted February 11, 2012 Thanks dude. It worked ! Link to comment
drk Posted February 11, 2012 Author Share Posted February 11, 2012 It's possible to set the text of a dx text in server side ? Link to comment
Kenix Posted February 11, 2012 Share 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 Link to comment
Kenix Posted February 11, 2012 Share 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 Link to comment
drk Posted February 11, 2012 Author Share 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 Link to comment
Kenix Posted February 11, 2012 Share 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. Link to comment
drk Posted February 11, 2012 Author Share Posted February 11, 2012 I'll send full code via PM. Link to comment
drk Posted February 11, 2012 Author Share 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 Link to comment
Castillo Posted February 11, 2012 Share Posted February 11, 2012 You can split the string and then compare it. Use: split Link to comment
drk Posted February 12, 2012 Author Share Posted February 12, 2012 Like this? old = split(theTime[1]['time'],':') Link to comment
Castillo Posted February 12, 2012 Share 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 Link to comment
drk Posted February 12, 2012 Author Share 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" Link to comment
Castillo Posted February 12, 2012 Share 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.."'" ) Link to comment
drk Posted February 12, 2012 Author Share Posted February 12, 2012 Thanks dude. It worked. Now I can solve my level system script error Link to comment
drk Posted February 13, 2012 Author Share 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. Link to comment
Kenix Posted February 13, 2012 Share Posted February 13, 2012 function currentMapName( ) return getResourceName( exports[ 'mapmanager']:getRunningGamemodeMap( ) ) end Link to comment
drk Posted February 13, 2012 Author Share Posted February 13, 2012 \õ/ MTA SA Wiki have this functions in Resources page? Link to comment
Kenix Posted February 13, 2012 Share Posted February 13, 2012 https://wiki.multitheftauto.com/wiki/Mapmanager ? Link to comment
drk Posted February 13, 2012 Author Share Posted February 13, 2012 Ye, thanks for all. I will start searching there before create a topic or reply with a noob question Link to comment
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