Driving license
#1

Hello. I wanted to remind myself how it's done when getting into a vehicle, it popped up the message that "You do not have a driving license, you decide to leave the vehicle!". How to make it work well?

Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) //test123
{
	if(playerid == vehicleid)
	{
		if(PlayerInfo[playerid][DrivingLicense] == 0)
		{
			SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
			ClearAnimations(playerid);
		}
	}

	return 1;
}
Reply
#2

Try this. I didn't test it.
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate){
    if(newstate == PLAYER_STATE_DRIVER){
        if(PlayerInfo[playerid][pDrivingLicense] == 0){
            SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
Reply
#3

Thank you also works nicely.
It works but I'm not sure if this is correct for this public.

Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) //test123
{
	if(vehicleid)
	{
		if(PlayerInfo[playerid][DrivingLicense] == 0)
		{
			SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
        	        ClearAnimations(playerid);
		}
	}

	return 1;
}
Or
Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) //test123
{
	if(PlayerInfo[playerid][DrivingLicense] == 0)
	{
		SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
                ClearAnimations(playerid);
	}

	return 1;
}
Reply
#4

They both do the same thing, but I would recommend OnPlayerStateChange
Reply
#5

Yes, but OnPlayerEnterVehicle has my plus that it does not get into the vehicle just shows the message by clicking "F" or "Enter". I want to make sure I do not do the wrong thing in OnPlayerEnterVehicle. Later it may happen that it will be bugs.
Reply
#6

Just Get the player pos and set the player pos!

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) //test123
{
    if(playerid == vehicleid)
    {
        if(PlayerInfo[playerid][DrivingLicense] == 0)
        {
                     new Float:POS[3];
                    GetPlayerPos(playerid, POS[0], POS[1], POS[2]);
                     SetPlayerPos(playerid, POS[0], POS[1], POS[2]);
            SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
                      return true;
        }
    }

    return 1;
}
Reply
#7

Oh, that's good for me too. Thanks . What should I do with this " if(playerid == vehicleid) " ?
Reply
#8

Quote:
Originally Posted by KamilPolska
View Post
Oh, that's good for me too. Thanks . What should I do with this " if(playerid == vehicleid) " ?
Remove that if statement!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)