Id vehicle - 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: Id vehicle (
/showthread.php?tid=591118)
Id vehicle -
Mister0 - 08.10.2015
Hi, i Created 20 cars, and I want to check the small id of the vehicle. I know when I start the server the lowest id is
CreatedCarsOn[0] but I destroy the smallest id and I creat Another car, and how can I check The lowest Id from this 20 vehicles. I try this but on't work. is it a simple way to find?
PHP код:
TennIdCreated()
{
new smallid;
if(CreatedCarsOn[0]<CreatedCarsOn[1])
smallid = CreatedCarsOn[1];
if(CreatedCarsOn[1]<smallid)
smallid = CreatedCarsOn[1];
if(CreatedCarsOn[2]<smallid)
smallid = CreatedCarsOn[2];
if(CreatedCarsOn[3]<smallid)
smallid = CreatedCarsOn[3];
if(CreatedCarsOn[4]<smallid)
smallid = CreatedCarsOn[4];
if(CreatedCarsOn[5]<smallid)
smallid = CreatedCarsOn[5];
if(CreatedCarsOn[6]<smallid)
smallid = CreatedCarsOn[6];
if(CreatedCarsOn[7]<smallid)
smallid = CreatedCarsOn[7];
if(CreatedCarsOn[8]<smallid)
smallid = CreatedCarsOn[8];
if(CreatedCarsOn[9]<smallid)
smallid = CreatedCarsOn[9];
if(CreatedCarsOn[10]<smallid)
smallid = CreatedCarsOn[10];
if(CreatedCarsOn[11]<smallid)
smallid = CreatedCarsOn[11];
if(CreatedCarsOn[12]<smallid)
smallid = CreatedCarsOn[12];
if(CreatedCarsOn[13]<smallid)
smallid = CreatedCarsOn[13];
if(CreatedCarsOn[14]<smallid)
smallid = CreatedCarsOn[14];
if(CreatedCarsOn[15]<smallid)
smallid = CreatedCarsOn[15];
if(CreatedCarsOn[16]<smallid)
smallid = CreatedCarsOn[16];
if(CreatedCarsOn[17]<smallid)
smallid = CreatedCarsOn[17];
if(CreatedCarsOn[18]<smallid)
smallid = CreatedCarsOn[18];
if(CreatedCarsOn[19]<smallid)
smallid = CreatedCarsOn[19];
if(CreatedCarsOn[20]<smallid)
smallid = CreatedCarsOn[20];
return smallid;
}
Re: Id vehicle -
AbyssMorgan - 08.10.2015
Do you want to calculate the vehicles?
Код:
stock CountVehicles(){
new cnt=0;
for(new i = 1; i <= MAX_VEHICLES; i++){
if(IsValidVehicle(i)){
cnt += 1;
}
}
return cnt;
}
Re: Id vehicle -
d3ll - 08.10.2015
Try this:
PHP код:
TennIdCreated()
{
new smallid = 20; // 20 vehicles created
for(new vid = 1; vid < sizeof(CreatedCarsOn); vid++) // there is no vehicle ID 0 in SA-MP, starts from 1.
{
if(CreatedCarsOn[vid] != INVALID_VEHICLE_ID) // created vehicle
{
if(CreatedCarsOn[vid] > smallid) continue; // vehicle ID is larger than the smallid, skip it.
smallid = CreatedCarsOn[vid];
}
else continue;
}
return smallid;
}
Re: Id vehicle -
Sew_Sumi - 08.10.2015
https://sampwiki.blast.hk/wiki/IsValidVehicle
Should look at this one maybe to help out in amongst this.