Giving a vehicle a unique id
#1

Ok, ive finally made my vehicle system partly work... problem is that its not setting a unique id meaning that if i would to buy 2 cars it would only kick me out one of them if i wasnt the owner..

So whats wrong?

pawn Код:
//out of the call back
new vehicles[100];

//in callback
new ID = 0;
while(ID < sizeof(vehicles) && vehicles[ID])
{
    ID++;
}
vehicles[ID] = ID;
Reply
#2

pawn Код:
new vehicles[100]; // You should use more than 100...
new countveh = 0;
So, when you create a vehicle:
pawn Код:
vehicles[countveh] = CreateVehicle(blah blah blah);
countveh++;
So, if you want to check if a player drives a specific vehicle, just do:
pawn Код:
if (GetPlayerVehicleID(playerid) == vehicles[countveh])
If you want to destroy all vehicles:
pawn Код:
for(new i=0;i<100;i++)
{
DestroyVehicle(vehicles[i]);
vehicles[i] = -1;
}
countveh = 0;
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)