--DESCRIPTION: calculates total distance travelled by player --DESCRIPTION: [@Mode=1(1=Total_Distance,2=From_Start)] changes between any movement adding to the total movement --DESCRIPTION: or only calculating how far the player moves away from the starting location --DESCRIPTION: [IgnoreY!=0] will allow you to ignore altitude changes and jumping etc --DESCRIPTION: which is handy for a flat map or where you only care about the birds-eye distance local dis_travelled = 0 local x1,y1,z1,x2,y2,z2 g_distance_travelled = {} function distance_travelled_properties(e, mode, ignorey) g_distance_travelled[e].mode = mode g_distance_travelled[e].ignorey = ignorey end function distance_travelled_init(e) g_distance_travelled[e] = {} end function distance_travelled_main(e) x2 = g_PlayerPosX y2 = g_PlayerPosY z2 = g_PlayerPosZ if x1 == nil then x1,y1,z1 = x2,y2,z2 return end local y = 0 if g_distance_travelled[e].ignorey == 0 then y = math.abs(y2-y1)*0.25 end if g_distance_travelled[e].mode == 1 then local x3,y3,z3 = x2-x1,y,z2-z1 dis_travelled = dis_travelled + math.sqrt(x3^2+y3^2+z3^2) x1,y1,z1 = x2,y2,z2 else local x3,y3,z3 = x2-x1,y,z2-z1 dis_travelled = math.sqrt(x3^2+y3^2+z3^2) end Prompt(round(dis_travelled*0.01,1).."m") end --main function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end