restricted faction cars help
#3

your issue is that you don't understand the functions. onplayerenterehicle is called when a player enters a vehicle but they are not physically in it yet so it will always mess you up and you cannot remove someone from a vehicle that they are not is so it simply fails. you need to rewrite the code so that most of the work is done under onplayerstatechange.

I'm feeling generous so I did it for ya lol:

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    LastCar[playerid] = vehicleid;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new gun,tmp,engine,lights,alarm,doors,bonnet,boot,objective;
    #pragma unused tmp
    if(newstate == PLAYER_STATE_PASSENGER) SetPlayerArmedWeapon(playerid,0);
    if(newstate == PLAYER_STATE_PASSENGER) {
        if(newstate == PLAYER_STATE_PASSENGER) {
            GetPlayerWeaponData(playerid,4,gun,tmp);
            if(gun)SetPlayerArmedWeapon(playerid,gun);
            else SetPlayerArmedWeapon(playerid,0);
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT) {
        if(LicenseTest[playerid]) {
            DisablePlayerCheckpoint(playerid);
            LicenseTest[playerid] = 0;
            CP[playerid] = 0;
            SetVehicleToRespawn(LastCar[playerid]);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Driving Center: You have left your car, therefore your test has been failed.");
        }
    }
    if(newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER) {
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
        if(!engine) SendClientMessage(playerid, COLOR_WHITE, "You can start or stop the vehicle's engine using {FF6347}/engine{FFFFFF}.");
        //if(!engine) GameTextForPlayer(playerid, "~w~/engine to turn on/off the vehicle engine.", 3500, 3);
        if(!PlayerInfo[playerid][pCarLic]) SendClientMessage(playerid, COLOR_LIGHTRED, " You don't have a drivers license, beware of cops.");
        //if(IsATowTruck(vehicleid)) SendClientMessage(playerid, COLOR_WHITE, "You can tow a vehicle using {FF6347}/tow{FFFFFF}.");
        if(IsDMVCar(vehicleid)) {
            if(!LicenseTest[playerid]) {
                SendClientMessage(playerid, COLOR_ORANGE, "You are not taking a drivers license test.");
                ClearAnimations(playerid,true);
            }
            else {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "* GPS: Finish the test by driving through all of the checkpoints on your GPS.");
                SetPlayerCheckpoint(playerid,980.1932,-1407.9902,13.0956,5);
                SendClientMessage(playerid, COLOR_RED, "If you exit the car your test will be failed and it will have to be re-done.");
            }
        }
        if(IsDLCar(vehicleid)) ClearAnimations(playerid,true);
        else if(IsFamVehicle(vehicleid) && Fam[vehicleid] != PlayerInfo[playerid][pFam] && !IsACop(playerid)) {
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to a family.");
            ClearAnimations(playerid,true);
            print("Family cars loaded successfully.");
        }
        else if(IsLeoVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 1) {
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the LSPD.");
            ClearAnimations(playerid,true);
            print("Police Cars loaded successfully.");
        }
        else if(IsLSFMDVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 5) {
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the LSFMD.");
            ClearAnimations(playerid,true);
            print("LSFMD cars loaded successfully.");
        }
        else if(IsNewsVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 4) {
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the News Agency.");
            ClearAnimations(playerid,true);
            print("News cars loaded successfully.");
        }
        else if(IsFBIVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 6) {
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the FBI.");
            ClearAnimations(playerid,true);
            print("FBI cars loaded successfully.");
        }
        else if(IsNGVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 7) {
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the NG.");
            ClearAnimations(playerid,true);
            print("NG cars loaded successfully.");
        }
        else if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TRUCKER) {
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Truckers.");
            ClearAnimations(playerid,true);
            print("Trucks cars loaded successfully.");
        }
        else if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2) {
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the GOV.");
            ClearAnimations(playerid,true);
            print("Gov cars loaded successfully.");
        }
    }
    return 1;
}
remove everything you originally posted from your gm and replace with this.
Reply


Messages In This Thread
restricted faction cars help - by lulo356 - 12.05.2014, 02:24
Re : restricted faction cars help - by Ramoboss - 12.05.2014, 03:10
Re: restricted faction cars help - by CJay9209 - 12.05.2014, 04:22
Re: restricted faction cars help - by lulo356 - 12.05.2014, 17:30
Re: restricted faction cars help - by lulo356 - 12.05.2014, 17:41
Re: restricted faction cars help - by lulo356 - 12.05.2014, 17:45
Re: restricted faction cars help - by lulo356 - 13.05.2014, 08:05
Re: restricted faction cars help - by IceBilizard - 13.05.2014, 08:17
Re: restricted faction cars help - by Madd92 - 13.05.2014, 08:23
Re: restricted faction cars help - by Madd92 - 13.05.2014, 14:04

Forum Jump:


Users browsing this thread: 1 Guest(s)