Checking if vehicle is still occupied after exiting it (urgent)
#5

Quote:
Originally Posted by dazman14
Посмотреть сообщение
Would this work also in OnPlayerExitVehicle.

Код:
for(new i = 0; i < MAX_PLAYERS; i++)
    {
		if(IsPlayerConnected(i))
		{
			if(IsPlayerInVehicle(i, vehicleid)) 
			{
				if(GetPlayerState(i) != PLAYER_STATE_DRIVER) 
				{
                                        return 1;
				}
			}
		}
		
    }
Where it returns 1 it stops the below code which happens to be a parking code ive got which i don't want initiated if a player is still in vehicle.
Quote:
Originally Posted by Ahmad45123
Посмотреть сообщение
You don't have to loop for the playerid... You already have it in the callback as a parameter.
And it may work, yes... But the one that @Ballu Miaa stated is more efficient
Yeah i guess therefore i attempted to code something you want. It is untested code and run some tests that it does the job or not?

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
   if(IsPlayerConnected(playerid))
   {
        if(IsPlayerInVehicle(playerid, vehicleid))
        {
            if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
            {
                        //Your code.
                    return 1;
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)