Car restriction.
#1

Alright, so i'm having a problem.

Currently only a few faction vehicles seems to be restricted.
For example: Only National Guards, Police Department and FBI have restricted vehicles, while all have the same script....
I'm sure this aint something i need to adjust ingame.

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        if(IsDMVCar(vehicleid))
        {
            if(!LicenseTest[playerid])
            {
                new Float:pos[3];
                GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
                SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
                SendClientMessage(playerid, COLOR_ORANGE, "You are not taking a drivers license test.");
            }
            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))
        {
                new Float:pos[3];
                GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
                SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
        }
        else if(IsFamVehicle(vehicleid) && Fam[vehicleid] != PlayerInfo[playerid][pFam] && !IsACop(playerid))
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to a family.");
        }
        else if(IsLeoVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 1)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the NYPD.");
        }
        else if(IsLSFMDVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 5)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the LSFMD.");
        }
        else if(IsNewsVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 4)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the News Agency.");
        }
        else if(IsFBIVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 6)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the FBI.");
        }
        else if(IsNGVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 7)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the NG.");
        }
        else if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TRUCKER)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Truckers.");
        }
        else if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the GOV.");
        }
        else if(IsHitmanVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 3)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the NYPD.");
        }

    }
    return 1;
}


Stocks:
pawn Code:
stock IsGovVehicle(vehicleid)
{
    for(new i=0; i<12; i++)
    {
        if(vehicleid == FacInfo[2][fCars][i]) return 1;
    }
    return 0;
}

stock IsDMVCar(vehicleid)
{
    for(new i=0; i<5; i++)
    {
        if(vehicleid == DMVCar[i]) return 1;
    }
    return 0;
}

stock IsDLCar(vehicleid)
{
    for(new i=0; i<12; i++)
    {
        if(vehicleid == DLCar[i]) return 1;
    }
    return 0;
}


stock IsNewsVehicle(vehicleid)
{
    for(new i=0; i<8; i++)
    {
        if(vehicleid == FacInfo[4][fCars][i]) return 1;
    }
    return 0;
}

stock IsHitmanVehicle(vehicleid)
{
    for(new i=0; i<8; i++)
    {
        if(vehicleid == FacInfo[3][fCars][i]) return 1;
    }
    return 0;
}

stock IsLSFMDVehicle(vehicleid)
{
    for(new i=0; i<8; i++)
    {
        if(vehicleid == FacInfo[5][fCars][i]) return 1;
    }
    return 0;
}
stock IsLeoVehicle(vehicleid)
{
    for(new i=0; i<26; i++)
    {
        if(vehicleid == FacInfo[1][fCars][i]) return 1;
    }
    return 0;
}
stock IsAPlane(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 460,464,476,511,512,513,519,520,553,577,592,593: return 1;
    }
    return 0;
}
stock IsFBIVehicle(vehicleid)
{
    for(new i=0; i<15; i++)
    {
        if(vehicleid == FacInfo[6][fCars][i]) return 1;
    }
    return 0;
}
stock IsNGVehicle(vehicleid)
{
    for(new i=0; i<15; i++)
    {
        if(vehicleid == FacInfo[7][fCars][i]) return 1;
    }
    return 0;
}
Example of each faction vehicle:
pawn Code:
// Police Vehicles
    FacInfo[1][fCars][0] = CreateVehicle(596,1601.9502,-1683.9442,5.5580,90.0662,0,1,1200); // Crusier1

    //hitman
    FacInfo[3][fCars][0] = CreateVehicle(560, 1669.6621, -1706.6215, 15.1910, 90.0000, 1, 1, 100); //sultan 1

    // SA News Vehicles
    FacInfo[4][fCars][0] = CreateVehicle(582,770.3323,-1334.0879,13.5999,178.7927,1,3,1800); // News1

    //LSFMD
    FacInfo[5][fCars][0] = CreateVehicle(416,1544.3696,-2167.7627,13.8116,271.1999,1,3,1800); //

    //FBI
    FacInfo[6][fCars][0] = CreateVehicle(490,277.9093,-1534.6960,24.7224,235.6933,0,0,1800); // Crusier1

    // NG
    FacInfo[7][fCars][0] = CreateVehicle(470,1099.2081,-1775.6332,13.3372,89.1093,1,1,1800); //

    // Government Vehicles
    FacInfo[2][fCars][0] = CreateVehicle(507,1454.8049,-1749.6432,13.4354,359.8442,0,0,1800); // Gov

I really need help with this.
Reply
#2

i really need help with this, please.
Reply
#3

I know someone can help me, please?
Reply
#4

Instead of:

pawn Code:
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
You can better use:
pawn Code:
ClearAnimations(playerid);
I don't know if that fixes it but it's also something to change.
Reply
#5

Thanks for that :P I will try if it works
Reply
#6

didnt work :/
Reply
#7

Bump.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)