SA-MP Forums Archive
OnPlayerEnterVehicle help? - 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: OnPlayerEnterVehicle help? (/showthread.php?tid=553445)



OnPlayerEnterVehicle help? - Jing_Chan - 29.12.2014

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:x, Float:y, Float:z;
    if(GetPlayerSurfingVehicleID(playerid) == vehicleid)
    {
        new Float:hp;
        GetPlayerHealth(playerid,hp);
        GetPlayerPos(playerid, x, y, z);
        if(!PlayerInfo[playerid][pMask]) format(string, sizeof(string), "* %s slipped off the top of the vehicle and fell.", PlayerRPName(playerid));
        else format(string, sizeof(string), "* Stranger slipped off the top of the vehicle and fell.");
        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        SetPlayerPos(playerid, x+3, y+3, z+1);
        SetPlayerHealth(playerid,hp-3);
        PlayerPlaySound(playerid, 1130, 0.0, 0.0, 0.0);
        LoopingAnim(playerid,"PED","BIKE_fallR",4.0,0,1,1,1,0);
    }
    if(PlayerInfo[playerid][pCarLic] = 0) {
    SendClientMessage(playerid, COLOR_RED, "Be careful, you don't have a drivers license! If you get pulled over without one you'll be arrested!");
    return 1;
    }
    else if(IsATaxiCar(vehicleid) && !ispassenger || IsABus(vehicleid) && !ispassenger)
    {
        if(PlayerInfo[playerid][pMember] != 10 && PlayerInfo[playerid][pJob] != 14)
        {
            displayCenterHUDInfo(playerid,  "You are not a~n~~y~Taxi Driver~w~.", 8); //display for 8 seconds
            PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
            ClearAnimations(playerid);
        }
    }
    else if(IsANewsCar(vehicleid) && !ispassenger)
    {
        if(PlayerInfo[playerid][pMember] != 9 && !IsAnAgent(playerid))
        {
            displayCenterHUDInfo(playerid,  "You are not a member of the~n~~b~News Agency~w~.", 8); //display for 8 seconds
            PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
            ClearAnimations(playerid);
        }
    }
    else if(IsAnAmbulance(vehicleid) && !ispassenger)
    {
        if(PlayerInfo[playerid][pMember] != 4 && !IsAnAgent(playerid))
        {
            displayCenterHUDInfo(playerid,  "You are not a member of the~n~~r~LSMFD~w~.", 8); //display for 8 seconds

            PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
            ClearAnimations(playerid);
        }
    }
    else if(IsAVipCar(vehicleid) && !ispassenger)
    {
        if(IsAVipCar(vehicleid))
        {
            if(IsABronzeCar(vehicleid) && PlayerInfo[playerid][pDonateRank] <= 0)
            {
                displayCenterHUDInfo(playerid,  "~w~You are not a~n~~y~bronze ~p~VIP~w~.", 8); //display for 8 seconds
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                ClearAnimations(playerid);
            }
            if(IsASilverCar(vehicleid) && PlayerInfo[playerid][pDonateRank] <= 1)
            {
                displayCenterHUDInfo(playerid,  "~w~You are not a ~b~~h~~h~~h~silver ~p~VIP~w~.", 8); //display for 8 seconds
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                ClearAnimations(playerid);
            }
            if(IsAGoldCar(vehicleid) && PlayerInfo[playerid][pDonateRank] <= 2)
            {
                displayCenterHUDInfo(playerid,  "~w~You are not a~n~~y~gold ~p~VIP~w~.", 8); //display for 8 seconds
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                ClearAnimations(playerid);
            }
        }
    }
    else if(RapidResKitActive[playerid] == 1)
    {
        if(!ispassenger || ispassenger)
        {
            SendClientMessage(playerid, COLOR_GREY, "You can't enter a vehicle while using a rapid response kit, '/droprrk' in order to drop it.");
            PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
            ClearAnimations(playerid);
        }
    }
    for(new i = 0; i < 4; i++)
    {
        if(SenateCar[i] == vehicleid && !ispassenger)
        {
            if(!IsASenate(playerid) && !IsAnAgent(playerid))
            {
                displayCenterHUDInfo(playerid,  "You are not a member of the~n~~r~Senate~w~.", 8); //display for 8 seconds
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                ClearAnimations(playerid);
            }
        }
    }
    for(new i = 0; i < 5; i++)
    {
        if(FBICar[i] == vehicleid && !ispassenger)
        {
            if(!IsAFBI(playerid) && !IsAnAgent(playerid))
            {
                displayCenterHUDInfo(playerid,  "You are not a member of the~n~~b~FBI~w~.", 8); //display for 8 seconds
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                ClearAnimations(playerid);
            }
        }
    }
    for(new i = 0; i < 32; i++)
    {
        if(LSPDCar[i] == vehicleid && !ispassenger)
        {
            if(!IsACop(playerid) && !IsAnAgent(playerid))
            {
                displayCenterHUDInfo(playerid,  "You are not a member of the~n~~b~LSPD/FBI/SAST~w~.", 8); //display for 8 seconds
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                ClearAnimations(playerid);
            }
        }
    }
    for(new i = 0; i < 9; i++)
    {
        if(NGCar[i] == vehicleid && !ispassenger)
        {
            if(!IsANG(playerid) && !IsAnAgent(playerid))
            {
                displayCenterHUDInfo(playerid,  "You are not a member of the~n~~g~Prison Guards~w~.", 8); //display for 8 seconds
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                ClearAnimations(playerid);
            }
        }
    }
    for(new i = 0; i < 26; i++)
    {
        if(SASTCar[i] == vehicleid && !ispassenger)
        {
            if(!IsACop(playerid) && !IsAnAgent(playerid))
            {
                displayCenterHUDInfo(playerid,  "You are not a member of the~n~~b~LSPD/FBI/SAST~w~.", 8); //display for 8 seconds
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                ClearAnimations(playerid);
            }
        }
    }
    new Model = GetVehicleModel(vehicleid);
    if(Model == 427 && !ispassenger)
    {
        GetPlayerArmour(playerid, StoreArmour[playerid]);
    }
    if(PlayerTied[playerid] != 0) { ClearAnimations(playerid); }
    if(PlayerCuffed[playerid] != 0) { ClearAnimations(playerid); }
    if(PlayerFrozen[playerid] != 0) { ClearAnimations(playerid); }
    if(RapidResKitActive[playerid] != 0) { ClearAnimations(playerid); }
    if(PlayerJustDied[playerid] != 0) { ClearAnimations(playerid); }
    return 1;
}
That's my OnPlayerEnterVehicle, this is the bit specifically wrong.

pawn Код:
}
    if(PlayerInfo[playerid][pCarLic] = 0) {
    SendClientMessage(playerid, COLOR_RED, "Be careful, you don't have a drivers license! If you get pulled over without one you'll be arrested!");
    return 1;
    }
The message doesn't send when I don't have a license? Have I misplaced it?


Re: OnPlayerEnterVehicle help? - jackx3rx - 29.12.2014

pawn Код:
}
    if(PlayerInfo[playerid][pCarLic] == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "Be careful! You don't have a drivers license!");
        return 1;
    }
Remember if you're checking CarLic is zero, you need two equal signs - "==".

In your case, it only had one, so it got confused.


Re: OnPlayerEnterVehicle help? - Jing_Chan - 29.12.2014

Quote:
Originally Posted by jackx3rx
Посмотреть сообщение
pawn Код:
}
    if(PlayerInfo[playerid][pCarLic] == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "Be careful! You don't have a drivers license!");
        return 1;
    }
Remember if you're checking CarLic is zero, you need two equal signs - "==".

In your case, it only had one, so it got confused.
Thank you.