koragg Posted October 18, 2016 Author Share Posted October 18, 2016 Yea I noticed the size is nil, but why Link to comment
Gravestone Posted October 18, 2016 Share Posted October 18, 2016 5 minutes ago, koragg said: Yea I noticed the size is nil, but why Did you replace the getAll function with mine? Link to comment
koragg Posted October 18, 2016 Author Share Posted October 18, 2016 3 hours ago, Gravestone said: Did you replace the getAll function with mine? Well, I replaced everything with yours. Link to comment
Gravestone Posted October 18, 2016 Share Posted October 18, 2016 8 minutes ago, koragg said: Well, I replaced everything with yours. It works fine for me. Link to comment
koragg Posted October 18, 2016 Author Share Posted October 18, 2016 Got it to show like this but if on some cps it indeed shows close to 0 meters when I'm infront of them, on larger ones it still shows noticably bigger number --http://lua-users.org/wiki/FormattingNumbers function round(val, decimal) if (decimal) then return math.floor( (val * 10^decimal) + 0.5) / (10^decimal) else return math.floor(val+0.5) end end local sx_, sy_ = guiGetScreenSize ( ) local sx, sy = sx_/1440, sy_/900 function distanceFromPlayerToCheckpoint(player, i) g_Checkpoints = getAll("checkpoint") local checkpoint = g_Checkpoints[getElementData(player, "race.checkpoint")] if checkpoint == nil then return false end local x, y, z = getElementPosition(player) for i, v in ipairs(checkpoint) do outputChatBox(unpack(v)) end return getDistanceBetweenPoints3D(x, y, z, unpack(checkpoint.position)), unpack(checkpoint.size) end function getAll(name) local result = {} for i,element in ipairs(getElementsByType(name)) do result[i] = {} result[i].id = getElementID(element) or i local position = { tonumber(getElementData(element,"posX")), tonumber(getElementData(element,"posY")), tonumber(getElementData(element,"posZ")) } local size = { tonumber(getElementData(element, "size")) } result[i].position = position; result[i].size = size; end return result end function draw() local distance, size = distanceFromPlayerToCheckpoint(localPlayer) if distance and size then dxDrawText(distance-size.." m to next checkpoint", sx_ * 0.8734, sy_ * 0.2009, sx_ * 0.9510, sy_ * 0.2259, tocolor(254, 254, 34, 255), 1*sy, "default-bold", "center", "top", false, false, false, false, false) end end addEventHandler("onClientRender", root, draw) Also I can't seem to round the number. Link to comment
aka Blue Posted October 18, 2016 Share Posted October 18, 2016 math.floor( distance-size ) (? 1 Link to comment
koragg Posted October 18, 2016 Author Share Posted October 18, 2016 (edited) 18 minutes ago, aka Blue said: math.floor( distance-size ) (? thanks, never knew I can use that instead of the 'round' function :v On normal sized cps (not huge) it says 4m when I'm infront of them (that's ok) but on bigger cps it says 20m, when I am literally infront of it. It is better than before though so thanks people Edited October 18, 2016 by koragg ok......some huge cps are fine, on other big ones it says not 4 but 20m when i am infront of it hmm Link to comment
Gravestone Posted October 19, 2016 Share Posted October 19, 2016 18 hours ago, koragg said: thanks, never knew I can use that instead of the 'round' function :v On normal sized cps (not huge) it says 4m when I'm infront of them (that's ok) but on bigger cps it says 20m, when I am literally infront of it. It is better than before though so thanks people 20 m when you're infront of it? Can you send me a screenshot? It works perfectly for me whether the size is big or small. Link to comment
koragg Posted October 19, 2016 Author Share Posted October 19, 2016 But strange thing is that on most maps it's fine, but on some like this one it isn't. Link to comment
Gravestone Posted October 19, 2016 Share Posted October 19, 2016 That's actually GTA 16 meters ;D 1 Link to comment
koragg Posted October 19, 2016 Author Share Posted October 19, 2016 (edited) 40 minutes ago, Gravestone said: That's actually GTA 16 meters ;D Edited October 19, 2016 by koragg in that case, thanks very much for the help bro :p Link to comment
Gravestone Posted October 19, 2016 Share Posted October 19, 2016 Just now, koragg said: Yeah, haha. 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