Jump to content

Big problem


mjau

Recommended Posts

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

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

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

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