08.11.2010, 14:55
Well i have this script and what its supposed to do is when u spawn it will find a unocupied vehicle and put u in it.
well it works kind of as i can move the wheels of a car when i spawn. But my player isnt sat in the seat, And a few secs later i die, I think its trying to put me in all the vehicles. So i need to make it stop searching when it finds 1 unoccpued vehicle. How?
well it works kind of as i can move the wheels of a car when i spawn. But my player isnt sat in the seat, And a few secs later i die, I think its trying to put me in all the vehicles. So i need to make it stop searching when it finds 1 unoccpued vehicle. How?
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(IsVehicleOccupied(i))
{
GameTextForPlayer(playerid, "There are no more cars left.", 2500, 3);
}
else if(!IsVehicleOccupied(i))
{
PutPlayerInVehicle(playerid, i, 0);
}
}
return 1;
}
stock IsVehicleOccupied(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
{
if(GetPlayerVehicleID(i) == vehicleid)
{
return 1;
}
}
}
return 0;
}