z24d Posted October 4, 2015 Posted October 4, 2015 function getElementSpeed(theElement, unit) -- Check arguments for errors assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")") assert(getElementType(theElement) == "player" or getElementType(theElement) == "ped" or getElementType(theElement) == "object" or getElementType(theElement) == "vehicle", "Invalid element type @ getElementSpeed (player/ped/object/vehicle expected, got " .. getElementType(theElement) .. ")") assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)") -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit)) -- Setup our multiplier to convert the velocity to the specified unit local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456) -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit return (Vector3(getElementVelocity(theElement)) * mult).length end local screenW, screenH = guiGetScreenSize() addEventHandler("onClientRender", root, function() if isPedInVehicle(source) then local elementSpeed = getElementSpeed(source, km/h) dxDrawText("Your Speed:"..elementSpeed, screenW * 0.7680, screenH * 0.9245, screenW * 0.9969, screenH * 0.9805, tocolor(48, 255, 0, 255), 1.50, "pricedown", "left", "top", false, false, false, true, false) end end ) ? فين البربلم؟ التكست مايطلع
z24d Posted October 4, 2015 Author Posted October 4, 2015 + وش الفرق بين onClientRender+onClientPreRender?
LoOs Posted October 5, 2015 Posted October 5, 2015 + وش الفرق بينonClientRender+onClientPreRender? الفرق onClientRender = ريندر كل جزء بالثانية onClientPreRender = ريندر x2
z24d Posted October 5, 2015 Author Posted October 5, 2015 وش الأفضل للدي أكس ؟ من الرندر والبري رندر؟ + الكود ماله رب : ( ابيه طبلون لكن ماضبط
LoOs Posted October 5, 2015 Posted October 5, 2015 وش الأفضل للدي أكس ؟ من الرندر والبري رندر؟+ الكود ماله رب : ( ابيه طبلون لكن ماضبط استعمل بدال الفنكشن المفيد getElementVelocity + الافضل رندر عشان مايتسبب بلاق , لان الرندر افضل والبري رندر تستعمله في الاشياء الي تحتاج سرعة بزيادة,
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