Cronoss Posted February 22, 2022 Share Posted February 22, 2022 I'm trying to make a gearbox system; I was testing "setElementSpeed",I used all the parameters needed, but still don't work for some reason, the console and debugscript2 don't send me any error, I put a "iprint" and it prints in the console, so the function "velocittt" runs... here it's the full code: function getElementSpeed(theElement, unit) assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")") local elementType = getElementType(theElement) assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")") 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)") unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit)) local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456) return (Vector3(getElementVelocity(theElement)) * mult).length end function setElementSpeed(element, unit, speed) local unit = unit or 0 local speed = tonumber(speed) or 0 local acSpeed = getElementSpeed(element, unit) if acSpeed and acSpeed~=0 then local diff = speed/acSpeed if diff ~= diff then return false end local x, y, z = getElementVelocity(element) return setElementVelocity(element, x*diff, y*diff, z*diff) end return false end function velocittt(thePlayer, cmd) local veh = getPedOccupiedVehicle(thePlayer) local speed1set = setElementSpeed(veh, "km/h", 10) ------Doesn't work end addCommandHandler("vel", velocittt) Link to comment
marcelluss Posted February 22, 2022 Share Posted February 22, 2022 The speed must be constantly set for this function to work. To do this, use a timer or a render to constantly maintain the speed. I don 't know for sure if it is possible to replace the shooting effect , but I can offer an option to create an object and count the trajectory of the bullet ( and already apply your shader to the object itself ) 1 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