Posts: 460
Threads: 42
Joined: Nov 2009
Reputation:
0
Allright so I made a car system and everything worked fine until I wanted to modify it so that it's not the name that's saved into the carsystem file on carowner. Instead I wanted to make that it saves the carid into a variable called PlayerInfo[playerid][vKey1] also a vkey2. This is because people should be able to change names. Now I realized that if I buy a vehicle (spawns when clicking on a dialog), then spawn another vehicle with /vcreate that I had before and then spawn another one with the dialog buy buying it. Now if I delete the car that I created with /vcreate and restart the server, then second cars ID is degraded by 1 which means the players doesn't own that vehicle anymore. Now I need suggestions on how I actually can fix this so that it won't bug everytime when people are doing /vscrap or anything. Any suggestions are welcome.
Posts: 687
Threads: 28
Joined: Mar 2010
Reputation:
0
I'm pretty sure you're assigning variables to a returned CreateVehicle, so when it deletes the variables will messup, or am I mistaken?
Posts: 460
Threads: 42
Joined: Nov 2009
Reputation:
0
Yes, I bought vehicle ID 40, spawned vehicle 41 and bought vehicle 42. Then I deleted 41, restarted and then the 42 was suddenly vehicle ID 41. So, do you have any suggestions?
Posts: 460
Threads: 42
Joined: Nov 2009
Reputation:
0
I'm storing the vehicle ID into a PlayerInfo[playerid][vKey1] variable and then when you enter it checks if the vehicle ID of that vehicle is the same. Rest of the vehicle info is saved into a .cfg file.
Posts: 460
Threads: 42
Joined: Nov 2009
Reputation:
0
Yeah, I was actually thinking about creating something similar to that. I just need to make that when a player buys a vehicle it sets a global variable up by one step so that the vehicles doesn't mess up and become the same ID ,am I right? Also, I'm using this MAX_CARS thing and not MAX_VEHICLES but I'm using GetPlayerVehicleID(playerid) so that's the problem am I right? It counts with the MAX_VEHICLES, not MAX_CARS.
Posts: 460
Threads: 42
Joined: Nov 2009
Reputation:
0
I don't really understand at the moment. So you mean that when a player buys a vehicle the MAX_VEHICLES ID is stored into a variable. And then I have to check it with another fuction if the variable ID is the same as the vKey1. Well what happens if I delete several vehicles so that the MAX_VEHICLES is degraded by a few steps. If a player buys a vehicle then it can become the same as any other vehicle's ID. Got any suggestion on fixing that?