OnPlayerEnterVehicle help
#1

Hello guys, i made a job script ..it has been compiled successfuly but one problem is !
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
   if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
     {
     if ((Pizzajob) == 1)
        {
        SendClientMessage(playerid,0xF5FF00FF, "[JOBHELP]:Use /deliverpizza to start your job");
        }
        else if ((Pizzajob) == 0)
		{
		 RemovePlayerFromVehicle(playerid);
	    }
     }
}
When Pizzajob = 1 i recieve the message but when Pizzajob = 0 the play won't be ejected :/
Reply
#2

OnPlayerEnterVehicle is called when a player starts to enter a vehicle, so the player is not in yet. Use OnPlayerStateChange instead.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
        {
            if (Pizzajob == 1) SendClientMessage(playerid,0xF5FF00FF, "[JOBHELP]:Use /deliverpizza to start your job");
            else if (Pizzajob == 0) RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
Reply
#3

or you could simply use the code you have there and change the check to use vehicleid instead - also remove the brackets around Pizzajob:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if (GetVehicleModel(vehicleid) == 448) {
        if ((Pizzajob) == 1) {
            SendClientMessage(playerid,0xF5FF00FF, "[JOBHELP]: Use /deliverpizza to start your job");
        }
        else {
            new Float:pos[3];
            GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
            SetPlayerPos(playerid,pos[0],pos[1],pos[2]);
            SendClientMessage(playerid,0xF5FF00FF, "[JOBHELP]: Prevented from entering Vehicle. You are not currently employed in Pizza Delivery");
        }
    }
}
this code simply stops the person from entering completely
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)