Faction Vehicles help.
#1

I'd want to restrict police cars (id 598.) from all other factions but police. At the moment I've got 2 factions: civilians(pTeam[playerid] == team_civ) and cops (pTeam[playerid] == team_lspd). And I can't figure out how to remove player from a vehicle since the function RemovePlayerFromVehicle doesn't work in the callback OnPlayerEnterVehicle. So is there any way to do this?
Reply
#2

Quote:
Originally Posted by Heisenbergx2
Посмотреть сообщение
I'd want to restrict police cars (id 598.) from all other factions but police. At the moment I've got 2 factions: civilians(pTeam[playerid] == team_civ) and cops (pTeam[playerid] == team_lspd). And I can't figure out how to remove player from a vehicle since the function RemovePlayerFromVehicle doesn't work in the callback OnPlayerEnterVehicle. So is there any way to do this?
EDIT: I think I can do this if someone gives me the correct function and the callback.
EDIT2: Fail... didnt' mean to double post
Reply
#3

You use OnPlayerStateChange, like this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicle = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicle) == 598)
        {
            if(pTeam[playerid] != team_lspd)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, 0xFFFFFFFF, "You're not a cop.");
                return 1;
            }
        }
    }
    return 1;
}
Reply
#4

You can either:

1)
pawn Код:
public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
    if(!ispassenger && pTeam[playerid] != team_lspd && GetVehicleModel(vehicleid) == 598)
    {
        new Float:pos[3];
        GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
        SetPlayerPos(playerid,pos[0],pos[1],pos[2]);
        SendClientMessage(playerid,-1,"This vehicle is owned by LSPD.");
    }
    return 1;
}
or

pawn Код:
new lspdcar[3];
lspdcar[0] = CreateVehicle(..);
lspdcar[1] = CreateVehicle(..);
lspdcar[2] = CreateVehicle(..);

public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
    for(new i = 0; i < sizeof(lspdcar); i++)
    {
        if(vehicleid == lspdcar[i] && pTeam[playerid] != team_lspd)
        {
            new Float:pos[3];
            GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
            SetPlayerPos(playerid,pos[0],pos[1],pos[2]);
            SendClientMessage(playerid,-1,"This vehicle is owned by LSPD.");
        }
    }
    return 1
}
EDIT: Or do what's said up above.
Reply
#5

Thanks guys, got it working now!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)