mjau Posted February 12, 2012 Share Posted February 12, 2012 Hi i have started creating a new gamemode and well when i was doing the vehicles system i stumbled over a problem when it was finsihed, it worked and stuff but the problem is: In the script i use createVehicle to create the vehicle player bought then i set the elemtndata on the vehicle to the players acc name but the problem is if my server crashes or any other thing wich can make the resource stop the vehicle i created dissapers, so does the element data wich means a player looses all his cars. how can i make the vehicle getting saved and the elementdata too on resource stop ? if u need code ill pm it Link to comment
TAPL Posted February 12, 2012 Share Posted February 12, 2012 so how about if player reconnect? how can i make the vehicle getting saved and the elementdata too on resource stop ? i don't know what you are trying to do, but as you said you are saved the elemtndata to the players acc name so you can do the same to save vehicle model id in account when the player bought it for example (you shouldn't use it because if you server crash there will not be Event onResourceStop) addEventHandler("onResourceStop",resourceRoot, function() for i, player in ipairs(getElementsByType("player")) do local veh = getPedOccupiedVehicle(player) if veh then local Model = getElementModel(veh) setAccountData(player,"vehModel",Model) end end end if you saved vehicle model id in account you can get it when the resource start Example: addEventHandler("onResourceStart",resourceRoot, function() for i, player in ipairs(getElementsByType("player")) do local Model = getAccountData(player,"vehModel") if Model then local x, y, z = getElementPosition(player) createVehicle(Model, x, y+3, z) end end end Link to comment
mjau Posted February 12, 2012 Author Share Posted February 12, 2012 reconnnect is no probelm cuz the data is on the vehicle i use getAccouuntName to get the name and then i make it loop trough all vehicles and a if check makes all the vehicles with element data equal to acc name pop up in my grid ... I just need a way to save the vehicle so it never dissaperas then the element data doesnt either Edit and waht you said would worked but look players are allowed to have unlimited amount of cars... Link to comment
TAPL Posted February 12, 2012 Share Posted February 12, 2012 this is not problem, you can save all vehicles models in table and set them in AccountData using toJSON and fromJSON toJSON fromJSON Link to comment
mjau Posted February 12, 2012 Author Share Posted February 12, 2012 What if he got 3 infernuses ? Link to comment
TAPL Posted February 12, 2012 Share Posted February 12, 2012 put infernuses model id in the table 3 times Link to comment
mjau Posted February 12, 2012 Author Share Posted February 12, 2012 k ill do this and tirgger the save with a timer wich updates it every min then ill make sure not too many cars are lost on crash Link to comment
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