Problem with license thing
#1

I have made my own pilot license script, but the problem is, that it is bugged. (before you ask the code that i put under onplayerentervehicle is below) The thing that is bugged is that it allows the person to enter the plane even if the person doesn't have a license. Anyone know how to fix this?
Code:
PHP код:
//under onplayerentervehicle
    
if(IsAPlane(vehicleid))
        {
            if(
PlayerInfo[playerid][pPilotLic] < 1)
            {
                 new 
Float:pos[3];
                 
GetPlayerPos(playeridpos[0], pos[1], pos[2]);
                 
SetPlayerPos(playeridpos[0], pos[1], pos[2]);
                  
SendClientMessage(playeridCOLOR_ORANGE"You cannot use this vehicle.");
            }
        } 
Reply
#2

Use ClearAnimations() instead of Get/SetPlayerPos. Or use the OnPlayerStateChange callback.
Reply
#3

Still nothing
Reply
#4

Just a guess but,

replace
pawn Код:
SendClientMessage(playerid, COLOR_ORANGE, "You cannot use this vehicle.");
with
pawn Код:
return SendClientMessage(playerid, COLOR_ORANGE, "You cannot use this vehicle.");
Reply
#5

Did that, still got nothing (didn't even receive the message)
Reply
#6

Well, I read this thread: https://sampforum.blast.hk/showthread.php?tid=362499&page=2

It's better if you kick him out of the vehicle once his state changed to driver.
Reply
#7

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(IsAPlane(vehicle))
        {
            if(PlayerInfo[playerid][pPilotLic] < 1)
            {
                 new Float:pos[3];
                 RemovePlayerFromVehicle(playerid);
                 SendClientMessage(playerid, COLOR_ORANGE, "You cannot use this vehicle.");
            }
        }  
    }
    return 1;
}
Reply
#8

Didn't work
Reply
#9

Never mind, added a bit of extra code, now it works, please lock this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)