IsVehicleEmpty(carid) function - 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: IsVehicleEmpty(carid) function (
/showthread.php?tid=160125)
IsVehicleEmpty(carid) function -
ikey07 - 15.07.2010
So finaly I need a help, maybe someone can help.
What I need is, to check if some exact car is empty.
I need it for a event, if some event car is empty set his VW to 9999.
I have tried many ways, maybe someone have some ideas?
Last way I tried like this.
pawn Код:
public IsVehicleEmpty(carid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInVehicle(i,carid))
{
return 1;
}
}
}
return 0;
}
I know that return 1; shouldn't be in loop, but its not work anyway.
Re: IsVehicleEmpty(carid) function -
bigcomfycouch - 15.07.2010
pawn Код:
IsVehicleEmpty(carid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsPlayerInVehicle(i, carid)) return 0;
}
return 1;
}
Re: IsVehicleEmpty(carid) function -
ikey07 - 15.07.2010
not working in this way.
thx anyway
Re: IsVehicleEmpty(carid) function -
Hiddos - 15.07.2010
Might try this:
pawn Код:
stock IsVehicleEmpty(vehicleid)
{
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerVehicleID(i) == vehicleid) return 0;
}
return 1;
}
Unsure about it though.
Re: IsVehicleEmpty(carid) function -
ikey07 - 15.07.2010
EDIT
Ops, Im idiot, I made cmd /test [carid]
but I forget to write carid in game xDDD
Both versions working great, Thx Guys