Virus xD Posted August 14, 2010 Share Posted August 14, 2010 Soz for my bad english i have problem whit my script (distancemeter) wher is problem? function startdistance (thePlayer, seat, jacked) distancemeter ( thePlayer ) end addEventHandler ("onVehicleEnter", getRootElement(), startdistance ) function distancemeter ( thePlayer ) meterX = getElementData ( thePlayer, "X" ) meterY = getElementData ( thePlayer, "Y" ) local meterX2, meterY2, meterZ2 = getElementPosition (thePlayer) Distancedrived = getDistanceBetweenPoints2D ( meterX, meterY, meterX2, meterY2 ) if ( Distancedrived ) then checkdistanced = getElementData ( thePlayer, "distance" ) if ( distance ) then setElementData ( thePlayer, "distance", Distancedrived ) local X, Y, Z = getElementPosition (thePlayer) setElementData ( thePlayer, "X", X ) setElementData ( thePlayer, Y", Y ) setTimer ( distancemeter, 1000, 1, thePlayer ) else local X, Y, Z = getElementPosition (thePlayer) setElementData ( thePlayer, "X", X ) setElementData ( thePlayer, "Y", Y ) local newdistance = checkdistanced+Distancedrived newdistance2 = newdistance setElementData ( thePlayer, "distance", newdistance2 ) setTimer ( distancemeter, 1000, 1, thePlayer ) end end end function vehExit ( thePlayer, seat, jacked ) exitdistance = getElementData ( thePlayer, "distance" ) outputChatBox("You drive: " .. exitdistance .. " meters.", thePlayer) setElementData ( thePlayer, "distance", false ) end addEventHandler ( "onVehicleExit", getRootElement(), vehExit ) ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ how to cut out all the figures after the decimal point Link to comment
dzek (varez) Posted August 14, 2010 Share Posted August 14, 2010 lua highlighter on forums are showing your error (notice that half of script is red) for rounding values: function round2(num, idp) return tonumber(string.format("%." .. (idp or 0) .. "f", num)) end -- usage: outputChatBox("PI: "..round2(22/7, 2)) -- will output PI: 3.14 Link to comment
Virus xD Posted August 15, 2010 Author Share Posted August 15, 2010 ty varez +respekt lock free Link to comment
Recommended Posts