Stranger Posted March 22, 2014 Posted March 22, 2014 hello, i was wondering, how can i save the upgrades of the vehicle that i have it ?
iPrestege Posted March 22, 2014 Posted March 22, 2014 hello, i was wondering, how can i save the upgrades of the vehicle that i have it ? getVehicleUpgrades And save them with any save ways.
Stranger Posted March 22, 2014 Author Posted March 22, 2014 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
iPrestege Posted March 22, 2014 Posted March 22, 2014 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.
Stranger Posted March 22, 2014 Author Posted March 22, 2014 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 !
iPrestege Posted March 22, 2014 Posted March 22, 2014 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.
Stranger Posted March 22, 2014 Author Posted March 22, 2014 will, i did what you said but same thing !
Stranger Posted March 22, 2014 Author Posted March 22, 2014 (edited) 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 March 22, 2014 by Guest
Karuzo Posted March 22, 2014 Posted March 22, 2014 You're using serverside functions in clientside scripts, that won't work.
Stranger Posted March 22, 2014 Author Posted March 22, 2014 sorry, for writing the name 'client side', the right name is 'destroy vehicle side' ^_^"
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