SA-MP Forums Archive
Need a little help. - 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: Need a little help. (/showthread.php?tid=631368)



Need a little help. - Jihanz - 28.03.2017

When the passengers get into the taxi (instead of the driver), the command refused to enter the taxi and it says "You are not a Taxi Driver" it means that you have to become the taxi driver first to get into the vehicle. How to make it possible for a passengers to get into the taxi without joining the Taxi Driver job first, and forbidden for them to enter the 1st seat driver.

my public OnPlayerEnterVehicle
PHP код:
    if(PlayerInfo[playerid][pJobTaxi] == 1)
    {
        }
    else {
        if(
modelid == 420 || modelid == 438)
        {
            
RemovePlayerFromVehicle(playerid);
            
ClearAnimations(playerid);
            return 
SendClientMessage(playerid0xFF0000FF"You are not a Taxi Driver");
        }
        else if(
modelid == 420 || modelid == 438){
             
PutPlayerInVehicle(playeridvehicleid1);
        }
    } 
Thanks before.


Re: Need a little help. - Sew_Sumi - 28.03.2017

Use a state check... You've obviously got this code in the callback, but you aren't checking if they are a driver or a passenger.

You should almost be using OnPlayerStateChange as it's more reliable, but it could be done OnPlayerEnterVehicle by checking "ispassenger".


Re: Need a little help. - Jihanz - 28.03.2017

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Use a state check... You've obviously got this code in the callback, but you aren't checking if they are a driver or a passenger.

You should almost be using OnPlayerStateChange as it's more reliable, but it could be done OnPlayerEnterVehicle by checking "ispassenger".
can you give example ?


Re: Need a little help. - Feynman - 28.03.2017

Try this.

Код HTML:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
	{
	    switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
	    {
	        case 420, 438:
	        {
	            if(PlayerData[playerid][pJobTaxi])
	            {
	                //start a job
				}
				else
				{
				    RemovePlayerFromVehicle(playerid); //player is not a taxi driver, then remove him from vehicle
				    
				    SendClientMessage(playerid, 0xFF0000FF, "You are not a Taxi Driver");
				}
			}
		}
	}
	return true;
}



Re: Need a little help. - Jihanz - 28.03.2017

Quote:
Originally Posted by Feynman
Посмотреть сообщение
Try this.

Код HTML:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
	{
	    switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
	    {
	        case 420, 438:
	        {
	            if(PlayerData[playerid][pJobTaxi])
	            {
	                //start a job
				}
				else
				{
				    RemovePlayerFromVehicle(playerid); //player is not a taxi driver, then remove him from vehicle
				    
				    SendClientMessage(playerid, 0xFF0000FF, "You are not a Taxi Driver");
				}
			}
		}
	}
	return true;
}
Solved Thanks