Hazard| Posted June 25, 2014 Share Posted June 25, 2014 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
Et-win Posted June 25, 2014 Share Posted June 25, 2014 local speed = getElementSpeed(car) Remove local. Btw, why saving the speed, if velocity is actually the speed? Link to comment
Hazard| Posted June 26, 2014 Author Share Posted June 26, 2014 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
Moderators Citizen Posted June 26, 2014 Moderators Share Posted June 26, 2014 Comment the line 25 and see if it work. Link to comment
Hazard| Posted June 26, 2014 Author Share Posted June 26, 2014 Thank you @Citizen, it works , makes sense too 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