Jump to content

[HELP] Give internal ID to vehicle?


John_Scott

Recommended Posts

Posted

Hi!

I yould like to create a vehicle shop with a duplication protection, so I would like to add an internal ID to every bought vehicle, and when the player spawn that, the scrip remove the old one.

(If I buy a Bullet, go away and spawn it, again go away, again spawn it, the script remove the first Bullet)

Thanks for the helping!

Posted

You can store the vehicles in a table.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Something like this is what I wrote years ago.

local vehicles = {} 
  
function makeMyCar(player,command,modelid) 
    if vehicles[player] then 
        if vehicles[player][2] then 
            destroyElement(vehicles[player][2]) 
        end 
        vehicles[player][2] = vehicles[player][1] 
        local x,y,z = getElementPosition(player) 
        vehicles[player][1] = createVehicle(modelid,x,y,z) 
        warpPedIntoVehicle(player,vehicles[player][1]) 
    else 
        vehicles[player] = {} 
        vehicles[player][1] = createVehicle(modelid,x,y,z) 
        warpPedIntoVehicle(player,vehicles[player][1]) 
    end 
end 
  
addCommandHandler("vi",makeMyCar) 

"The humble beet is the answer to all riddles." - Rolf

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