Jump to content

get/setElementSpeed


Hazard|

Recommended Posts

Hello,

This is about a training script I need help with. The case is that when you do /sl then it saves the location for the vehicle,

and when you do /ll then it loads the location of the sl.

what I want to do is that when you do /sl then it saves the speed&location of the vehicle and when you do /ll then it loads the location and the speed of the vehicle.

getElementSpeed 
setElementSpeed 

My code is below, the issue is that it doesn't save the speed when you do /sl, could you try to fix it? it's pretty easy, I can see that now, but I get errors

function TrainingSL() 
    local car = getPedOccupiedVehicle(localPlayer) 
    if not car then return end 
    x, y, z = getElementPosition(car) 
    rx, ry, rz = getElementRotation(car) 
    sx, sy, sz = getElementVelocity(car) 
    tx, ty, tz = getVehicleTurnVelocity(car) 
    nitro = getVehicleUpgradeOnSlot(car)  
    model = getElementModel(car) 
    health = getElementHealth(car) 
    outputChatBox("(/SL) Location saved.", source) 
    local speed = getElementSpeed(car) 
end 
addCommandHandler("SL", TrainingSL) 
addCommandHandler("sl", TrainingSL) 
  
function TrainingLL() 
    if not x then 
        outputChatBox("(/LL) No locations saved.", source) 
    else 
        local car = getPedOccupiedVehicle(localPlayer) 
        if not car then return end 
        setElementVelocity(car,0,0,0) 
                setVehicleTurnVelocity(car,0,0,0) 
        setElementFrozen(car, true) 
        setElementHealth(car, health) 
        setElementPosition(car, x, y, z) 
        setElementRotation(car, rx, ry, rz) 
        triggerServerEvent('syncModel', resourceRoot, car, model) 
        setElementModel(car, model) 
        fixVehicle(car) 
        setTimer(setElementFrozen,50,1,car,false) 
        triggerServerEvent('syncModel', resourceRoot, car, spm) 
        outputChatBox("(/LL) Location loaded.", source) 
        setElementSpeed(car, speed) 
    end 
end 
addCommandHandler("LL", TrainingLL) 
addCommandHandler("ll", TrainingLL) 
  

ty

Link to comment

Hello again, I'm using get/setElementVelocity now, @removed getElementSpeed.

Still I have the same issue, it doesn't work. This is what I have for now.

function TrainingSL() 
    local car = getPedOccupiedVehicle(localPlayer) 
    if not car then return end 
    vX, vY, vZ = getElementVelocity(car) 
    x, y, z = getElementPosition(car) 
    rx, ry, rz = getElementRotation(car) 
    tx, ty, tz = getVehicleTurnVelocity(car) 
    nitro = getVehicleUpgradeOnSlot(car) 
    model = getElementModel(car) 
    health = getElementHealth(car) 
    outputChatBox("(/SL) Location saved.", source) 
end 
addCommandHandler("SL", TrainingSL) 
addCommandHandler("sl", TrainingSL) 
  
function TrainingLL() 
    if not x then 
        outputChatBox("(/LL) No locations saved.", source) 
    else 
        local car = getPedOccupiedVehicle(localPlayer) 
        if not car then return end 
        setElementPosition(car, x, y, z) 
        setElementVelocity(car, vX, vY, vZ) 
        setVehicleTurnVelocity(car,0,0,0) 
        setElementFrozen(car, true) 
        setElementHealth(car, health) 
        setElementRotation(car, rx, ry, rz) 
        setElementModel(car, model) 
        setTimer(setElementFrozen,50,1,car,false) 
        outputChatBox("(/LL) Location loaded.", source) 
    end 
end 
addCommandHandler("LL", TrainingLL) 
addCommandHandler("ll", TrainingLL) 

I hope you can help me, I want it to save the speed of the vehicle when you do /sl, THEN you will recieve the speed that's saved in /sl when you do /ll, so when you do ll you get the same speed you had when you did /sl.

thx.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...