Faction Restricted Vehicles opened for everyone
#1

Hello everyone,
I was working on the zGaming script. I decided to add new faction (SAFD), okay everything is good.
Added restriction on OnPlayerEnterVehicle and such things, but here's a problem. Whoever try's to enter any faction vehicle, he's free to do so. It should of Remove him from the car, but it's not working :S.

Here's the code :
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        if(IsDMVCar(vehicleid))
        {
            if(!LicenseTest[playerid])
            {
                RemovePlayerFromVehicle(playerid);
                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,2040.7101,-1930.1340,13.4667,5);
                SendClientMessage(playerid, COLOR_RED, "If you exit the car your test will be failed and it will have to be re-done.");
            }
        }
        else if(IsFamVehicle(vehicleid) && Fam[vehicleid] != PlayerInfo[playerid][pFam] && !IsACop(playerid))
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_ORANGE, " This vehicle is restricted to a family.");
        }
        else if(IsLeoVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 1)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_ORANGE, " This vehicle is restricted to the SAPD faction.");
        }
        else if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_ORANGE, " This vehicle is restricted to the GOV faction.");
        }
        else if(IsNewsVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 4)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_ORANGE, " This vehicle is restricted to the News Agency faction.");
        }
        else if(IsSAFDVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 5)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_ORANGE, " This vehicle is restricted to the SAFD faction.");
        }
        else if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TRUCKER)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_ORANGE, " This vehicle is restricted to Truckers.");
        }
    }
    return 1;
}
pawn Код:
stock IsGovVehicle(vehicleid)
{
    for(new i=0; i<7; 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 IsNewsVehicle(vehicleid)
{
    for(new i=0; i<7; i++)
    {
        if(vehicleid == FacInfo[4][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 IsSAFDVehicle(vehicleid)
{
    for(new i=0; i<8; i++)
    {
        if(vehicleid == FacInfo[5][fCars][i]) return 1;
    }
    return 0;
}

stock IsFamVehicle(vehicleid)
{
    for(new idx=1; idx<MAX_FAMILIES; idx++)
    {
        for(new v=0; v<50; v++)
        {
            if(vehicleid == FamInfo[idx][fVeh][v]) return 1;
        }
    }
    return 0;
}
Anyone have idea why it's not working ? :S

Thanks in advance !
Reply
#2

Same problem, help!
Reply
#3

OnPlayerEnterVehicle is called when the player hits the enter key, not when the enter animation is finished and the player is completely in their vehicle. Instead, use OnPlayerStateChange with the wiki's example as a guideline.
Reply
#4

you can use at OnPlayerEnterVehicle but you'll need to replace the RemovePlayerFromVehicle(playerid); with
GetPlayerPos(playerid,x,y,z);
SetPlayerPos(playerid,x,y,z);

this will stop player to get in vehicle, in case you want to use at OnPlayerEnterVehicle
Reply
#5

Quote:
Originally Posted by mineralo
Посмотреть сообщение
you can use at OnPlayerEnterVehicle but you'll need to replace the RemovePlayerFromVehicle(playerid); with
GetPlayerPos(playerid,x,y,z);
SetPlayerPos(playerid,x,y,z);

this will stop player to get in vehicle, in case you want to use at OnPlayerEnterVehicle
Can you edit it and reply with it? Cant seem to find out how to do this
Reply
#6

Quote:
Originally Posted by mineralo
Посмотреть сообщение
you can use at OnPlayerEnterVehicle but you'll need to replace the RemovePlayerFromVehicle(playerid); with
GetPlayerPos(playerid,x,y,z);
SetPlayerPos(playerid,x,y,z);

this will stop player to get in vehicle, in case you want to use at OnPlayerEnterVehicle
It was like this, but I've changed it to RemovePlayerFromVehicle

Thanks anyways, I'll test it and tell you if it's working
Reply
#7

Nope it's still not working, anyone can help ? :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)