Jump to content

Change vehicle handling for 1 vehicle


knightscript

Recommended Posts

Posted

This script will add a command which when executed will change player's vehicle mass to 300.

  
function setVehicleMass(thePlayer) 
    local pVehicle = getPedOccupiedVehicle(thePlayer) 
    if pVehicle then 
        setVehicleHandling (pVehicle, "mass", 300.0) 
    end 
end 
addCommandHandler("mass",setVehicleMass) 
  

Posted

Wow, it works, thank you so much, one last thing, i have the following code:

  
function OwnerCar(player) 
    local account = getAccountName(getPlayerAccount(player)) 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Owners")) then 
        x,y,z = getElementPosition(player) 
        veh = createVehicle("602",x,y,z) 
      end 
end 
  

and its CommandHandler

addCommandHandler("MyCar",OwnerCar) 

I would like to know how can i despawn my old car? because if i put /MyCar twice it will spawn a new one, and i just want to spawn 1. i know it is with DestroyElement, but i do not know exactly how, thank you.

Posted
function OwnerCar(player) 
    local account = getAccountName(getPlayerAccount(player)) 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Owners")) then 
        if (isElement(getElementData(player, "spawnedCar"))) then 
            destroyElement(getElementData(player, "spawnedCar")) 
        end 
        local x,y,z = getElementPosition(player) 
        local veh = createVehicle("602",x,y,z) 
        setElementData(player, "spawnedCar", veh) 
     end 
end 
  

Posted

Add this,

addEventHandler("onPlayerQuit", getRootElement(), function() 
    destroyElement(getElementData(source, "spawnedCar")) 
end) 

EDIT nvm you found it.

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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...