SA-MP Forums Archive
Only for the person who is driving - 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: Only for the person who is driving (/showthread.php?tid=280938)



Only for the person who is driving - Kingunit - 03.09.2011

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;
}



Re: Only for the person who is driving - Davz*|*Criss - 03.09.2011

Try something GetPlayerState! Search it.

I cant help you cuz my shit pc is offz


Re: Only for the person who is driving - Kingunit - 03.09.2011

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.


Re: Only for the person who is driving - =WoR=Varth - 03.09.2011

https://sampwiki.blast.hk/wiki/GetPlayerVehicleSeat


Re: Only for the person who is driving - Improvement™ - 03.09.2011

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.


Re: Only for the person who is driving - Kingunit - 03.09.2011

Thank you - varthshenon and Improvement™. Both repped!


Re: Only for the person who is driving - Kar - 03.09.2011

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


Re: Only for the person who is driving - Kingunit - 03.09.2011

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


Re: Only for the person who is driving - Kar - 03.09.2011

No problem.


Re: Only for the person who is driving - dowster - 04.09.2011

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