Jump to content

[Question] upgrades


Stranger

Recommended Posts

will i trid like this :

function spawn (Name,carName) 
if getElementData(Name, "haveCar") == "no" then 
-- code 
local owner = getAccountName(getPlayerAccount(Name)) 
Vehicle = createVehicle(carModel, x, y, z) 
getAccountData (owner "upgrades") 
end 
addEvent("spawn_car", true) 
addEventHandler("spawn_car", getRootElement(), spawn) 
  
function destroy (Name) 
Acc = getAccountName(getPlayerAccount(Name)) 
-- code 
setAccountData (Acc, "upgrades", getVehicleUpgrades (Vehicle)) 
end 
addEvent("destroy_car", true) 
addEventHandler("destroy_car", getRootElement(), destroy) 

but not working

Link to comment
will i trid like this :

function spawn (Name,carName) 
if getElementData(Name, "haveCar") == "no" then 
-- code 
local owner = getAccountName(getPlayerAccount(Name)) 
Vehicle = createVehicle(carModel, x, y, z) 
getAccountData (owner "upgrades") 
end 
addEvent("spawn_car", true) 
addEventHandler("spawn_car", getRootElement(), spawn) 
  
function destroy (Name) 
Acc = getAccountName(getPlayerAccount(Name)) 
-- code 
setAccountData (Acc, "upgrades", getVehicleUpgrades (Vehicle)) 
end 
addEvent("destroy_car", true) 
addEventHandler("destroy_car", getRootElement(), destroy) 

but not working

This function returns a table of all the upgrades on a specifed vehicle.

Link to comment
can you just tell me what i have to use, to make it save ? i know i have to use

'getVehicleUpgrades'

but, can you tell me , what the right thing i have to use it !

You must get the values from the table which is the function i gave you above so you can simply :

    if vehicle then 
        for _,iUpgrades in ipairs ( getVehicleUpgrades ( vehicle ) ) do 
            -- Your Stuff  
        end 
    end 

This is just an example and vehicle doesn't return for something here you must check if the vehicle exists in your script.

Link to comment

will this is the code:

function spawn (Name,carName) 
if getElementData(Name, "haveCar") == "no" then 
local owner = getAccountName(getPlayerAccount(Name)) 
local carModel = getVehicleModelFromName(carName) 
local x,y,z = getElementPosition(Name) 
Vehicle = createVehicle(carModel, x, y, z) 
-- code 
getAccountData (owner, "upgrades") 
end 
addEvent("spawn_car", true) 
addEventHandler("spawn_car", getRootElement(), spawn) 

this the destroy vehicle side:

function destroy (Name) 
Acc = getAccountName(getPlayerAccount(Name)) 
if getElementData(Name, "haveCar") == "yes" and getElementData(Vehicle, "owner") == Acc then 
-- code 
if Vehicle then 
for _,Upgrades in ipairs ( getVehicleUpgrades ( Vehicle ) ) do 
setAccountData (Acc, "upgrades", Upgrades) 
end 
addEvent("destroy_car", true) 
addEventHandler("destroy_car", getRootElement(), destroy) 
Edited by Guest
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...