GetPlayerVehicleID Help
#1

Hello. I have a problem with this function. Well, not with this function exactly.

I have a MySQL vehicle system. If I destroy a car, all upper id's from the destroyed cars goes -1.
So when I enter to another car, GetPlayerVehicleID don't help me because the samp id's are not the same as MySQL car id. They are created in order but if I destroy a car, the id of MySQL is the same so if I do something on antother car, obviously gets the id from GetPlayerVehicleID and changes the "destroyed" car.

Any suggestions on how I can get the MySQL id?

Example:
Код:
User: test
// Parkandhide 4 destroys the vehicle and then, using /getcarback 4 will respawn the car
I destroy (using, for example /parkandhide 4) vehicleid 4, on MySQL id:4 and owner: test
I enter vehicleid 4 (was vehicleid 5, but vehicle on id 4 was destroyed), on MySQL id:5 and owner: test2
I do, for example, /lockcar and I can do the lock because i'm doing GetPlayerVehicleID(playerid) and in MySQL the id 4 is my car.

Anyone please? Is for a public release, credits will be keeped.
Reply
#2

Anyone?
Reply
#3

You use a variable attached to the vehicle ID that tracks the MySQL ID... It's not a good plan to assume that the MySQL ID can be used to even track the vehicle by it's ID. If you spawn another vehicle, it will take over the ID that's lowest.

VehicleMySQL[MAX_VEHICLES] and use that to track it's "ID". You can then use a for loop to find that car in the vehicle pool.
Reply
#4

Can you give me an example please?

Код:
enum Cars
{
	Model,CarID,Locked,Name[20],
	Float:Carx,Float:Cary,Float:Carz,Float:Cara,
	Owner[30],Price,Sell,Color1,Color2,
	Float:Expox,Float:Expoy,Float:Expoz,Float:Expoa,
	E1,E2,E3,E4,E5,A1,A2,A3,A4,A5,Stats,Plate[20],
	Keys1[30],Keys2[30],Keys3[30],Keys4[30],TotalKeys,
}

new VehicleSystem[MAX_VEHICLES][Cars];

// Example of work
new vehid = GetPlayerVehicleID(playerid);
for (new i; i<MAX_VEHICLES;i++)
{
     // An example, using format and sendclientmessage will list all car id's
     VehicleSystem[i][CarID];
}
But what happens when a car is destroyed? The 'vehid' will change so will get another row of MySQL and not the correct row because the id on samp is different.
Reply
#5

Before you destroy the vehicle, you take that vehicle's ID.

You take the ID and do this.

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) {
    if(pVehKey > destroyedVehKey && pVehKey != defaultkey) {
        pVehKey--;
    }
}
edit:

and you can't use GetPlayerVehicleID and store it into MySQL to get to know the owner of the veh, you need to have a temp key and a static key... if you don't know what that is just PM me.
Reply
#6

Quote:
Originally Posted by venomlivno8
Посмотреть сообщение
if you don't know what that is just PM me.
Don't defeat the purpose of the forums, explain the reasons here.

OP: stop confusing yourself by thinking that the VehicleID of the server, needs to mean anything.


The only reason for the VehicleID is so the script can track the vehicles. What you want to do is have individual variables, for each vehicle.

Which really, the Variables should be what you are looking at, NOT the VehicleID.
Reply
#7

bump
Reply
#8

Why are you bumping this? What isn't clear for you?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)