Simple Question about GetPlayerVehicleID
#1

Alright, in my database I have a field 'id' which is set to auto_increment. If I were to get the data of the field 'id', can I just use GetPlayerVehicleID because it's gonna be same as the id in the table? By the way I am talking about cars table where all the server vehicles are stored.
Reply
#2

More info needs to be provided to answer your question properly. (mysql table structure, saving/loading pawn code)

But to take a wild guess out of the blue, i'd say right away, this is not possible the way you describe it.

As already said, if you provide more info what you actually would like to achieve and show us some code what is
not working they way it should, i'd be glad to help you out here

regards, wolf.
Reply
#3

If you only create vehicles during OnGameModeInit and nowhere else in your code, it could work.
But if you're creating vehicles elsewhere and delete a few during the entire session your server is running, your id's WILL be messed up.

You should not store vehicle-id's in a database for saving.


I'm not using a database, just ordinary files to store my mission-vehicles (vehicles already present near spawn-locations).
It only stores the model, coordinates, rotation and colors.
My gamemode holds 400 mission-vehicles for example, with ID's 1 to 400.

Players are also able to buy house-vehicles, which get destroyed when the player leaves the server.
The server is running and all mission vehicles are loaded. So far so good.
Then, player A joins the server and owns 2 vehicles for example.
Upon joining the server, his house-vehicles are loaded and they get ID's 401 to 402.
Then player B joins the server and has 4 house-vehicles. They get ID's 403 to 406.

Now player A buys a new vehicle which gets ID 407.

Both players disconnect and all vehicles of both players are unloaded, so ID's 401 to 407 are available again.
Now player A re-joins the server and his vehicles are loaded, all 3 of them.
Previously they had ID's 401, 402 and 407, right?

Now they will get ID's 401, 402 and 403, because those slots are available.
The ID's are messed up as you can see.

Storing vehicleid's is just NOT-DONE. Only save the data about the vehicles, not their id.
Reply
#4

I have created a MySQL Dynamic Car Saving System, where I want to make a feature that if some player sits on a car created by this script, and as he types /deleteveh it'd delete the particular vehicle he's on. So that's why I was wondering if GetPlayerVehicleID would work good for this. But as PowerPC said, it can conflict if other cars are being created, so bad idea.

Any suggestions please?
Reply
#5

For what I'll do it by MY style. Create 2 Columns, ID and Vehicle Model ID. The ID is the number of vehicles that is set using AUTO_INCREMENT and once the vehicle is created, I'll use mysql_insert_id and GetVehicleModel and insert both to the database.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)