Checking occupied 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Checking occupied vehicle? (
/showthread.php?tid=177791)
Checking occupied vehicle? -
Jochemd - 19.09.2010
Hello,
I believe there was a function to check if a vehicle is occupied... Now I can't find it. Does anyone know what it was?
Regards, Jochem
Re: Checking occupied vehicle? -
MadeMan - 19.09.2010
There is no native function to check that, but you can make your own.
Re: Checking occupied vehicle? -
Jochemd - 19.09.2010
I did with a simple loop.
But I don't know if it would work with if(IsVehicleOccupied(vehicleid))
pawn Код:
stock IsVehicleOccupied(vehicleid)
{
for(new i =0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInVehicle(i,vehicleid))
{
return 1;
}
}
return 0;
}
Re: Checking occupied vehicle? -
Conroy - 19.09.2010
pawn Код:
stock IsVehicleOccupied(vehid)
{
for(new i; i <= MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
if(IsPlayerInVehicle(i, vehid)) return 1;
}
}
return 0;
}
Re: Checking occupied vehicle? -
Jochemd - 19.09.2010
Why using IsPlayerConnected? It was unneeded or is it needed?
Re: Checking occupied vehicle? -
LarzI - 19.09.2010
Not needed..
The player cannot be inside a vehicle if *he's not connected.
Re: Checking occupied vehicle? -
Conroy - 19.09.2010
I do that with all for statements, it's a habit I've gotten into. It wouldn't do any harm being there anyway.
-Conroy
Re: Checking occupied vehicle? -
LarzI - 19.09.2010
Quote:
Originally Posted by Conroy
I do that with all for statements, it's a habit I've gotten into. It wouldn't do any harm being there anyway.
-Conroy
|
Well you're actually wrong.
The code is slower with an unecesarry check like that.