Giving a vehicle a unique id - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Giving a vehicle a unique id (
/showthread.php?tid=410238)
Giving a vehicle a unique id -
thefatshizms - 24.01.2013
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;
Re: Giving a vehicle a unique id -
ReDevilGames - 24.01.2013
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;