1LoL1 Posted February 7, 2016 Share Posted February 7, 2016 Hello, i have this code but i don't know really why not work i want when i go traveled 100 meters i get 1x getElementData "M" i i go traveled 1000 meters i get 1 getElementData "KM" but not work function () if (isPedInVehicle(getLocalPlayer())) then x,y,z = getElementPosition(getLocalPlayer()) oX,oY,oZ = getElementPosition(getLocalPlayer()) distanceTraveled = getDistanceBetweenPoints3D(x,y,z,oX,oY,oZ) if distanceTraveled == 100 then setElementData(localPlayer, "M", (getElementData(localPlayer, "M") or 0) + 1) elseif distanceTraveled == 1000 then setElementData(localPlayer, "KM", (getElementData(localPlayer, "KM") or 0) + 1) end end end Link to comment
Bonsai Posted February 7, 2016 Share Posted February 7, 2016 Where do you always find these codes? And why are they never working.. That code doesn't make much sense like that. The distance would be always 0?! Also its unlikely to hit exactly 100 or 1000. Link to comment
1LoL1 Posted February 7, 2016 Author Share Posted February 7, 2016 Where do you always find these codes?And why are they never working.. That code doesn't make much sense like that. The distance would be always 0?! Also its unlikely to hit exactly 100 or 1000. 1 - in comunity or created by me? 2 - idk 3 - Yes because I want him to fix Link to comment
Bonus Posted February 8, 2016 Share Posted February 8, 2016 First at all I don't understand why you dont use local there. Why make the variables global? You compare the distance between the player and ... the player! That makes no sense. Bonsai wrote it, its hard to hit exactly 100. Well, I dont even know when this function gets called. You should look if the distance is >= 100 and < 1000. If so add math.floor ( distance / 100 ) to ElementData "M". If distance >= 1000 then add math.floor ( distance / 1000 ) to "KM". You should really learn the basics Or learn to read the code ... 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