Jump to content

Change vehicle handling for 1 vehicle


knightscript

Recommended Posts

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) 
  

Link to comment

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.

Link to comment
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 
  

Link to comment

Solved with the following code:

  addEventHandler( "onPlayerQuit", getRootElement( ),function() 
       if (isElement(getElementData(source, "knightcar1"))) then 
        destroyElement(getElementData(source, "knightcar1")) 
        outputDebugString ( "1 car by Knight Destroyed." ) 
        end 
  end) 

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