Only for the person who is driving
#1

I made a short code that if a player enters the vehicle without a license he will get a warning. But also the persons who aren't driving are getting that message. I want that only the person who is driving is getting that message. Someone TIPS?

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(PlayerInfo[playerid][Driverlic] == 0) return SendClientMessage(playerid,COLOR_ORANGE,"[WARNING]"#COL_LRED" You are driving without a driver license!");

    return 1;
}
Reply
#2

Try something GetPlayerState! Search it.

I cant help you cuz my shit pc is offz
Reply
#3

Having this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
    {
        if(PlayerInfo[playerid][Driverlic] == 0) return SendClientMessage(playerid,COLOR_ORANGE,"[WARNING]"#COL_LRED" You are driving without a driver license!");
    }
    return 1;
}
Doens't work - if a player without a license enter the vehicle he don't get the message.
Reply
#4

https://sampwiki.blast.hk/wiki/GetPlayerVehicleSeat
Reply
#5

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    printf("[print] %s Driverlic = %d", PlayerName, PlayerInfo[playerid][Driverlic]);

    if(PlayerInfo[playerid][Driverlic] == 0) return SendClientMessage(playerid,COLOR_ORANGE,"[WARNING]"#COL_LRED" You are driving without a driver license!");
    return 1;
}
Perhaps try this code, and post the output.
Reply
#6

Thank you - varthshenon and Improvement™. Both repped!
Reply
#7

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        if(PlayerInfo[playerid][Driverlic] == 0) return SendClientMessage(playerid,COLOR_ORANGE,"[WARNING]"#COL_LRED" You are driving without a driver license!");
    }
    return 1;
}
the ispassenger argument is pretty obvious
Reply
#8

Thank you Kar. That one looks the best I think. Repped+
Reply
#9

No problem.
Reply
#10

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if((PlayerInfo[playerid][Driverlic] == 0) & (!ispassenger)) return SendClientMessage(playerid,COLOR_ORANGE,"[WARNING]"#COL_LRED" You are driving without a driver license!");

    return 1;
}
i just had to one-line it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)