Just for green team
#1

Ok so, i have a custom vehicle and i want to disable the use for TEAM_BLUE, so i did in this way:

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        new vehicleidk;
        vehicleidk = GetPlayerVehicleID(playerid);
        if(vehicleidk == Sultan)
        {
            if(gTeam[playerid] == TEAM_BLUE)
            {
            SendClientMessage(playerid,0xAA3333AA,"** Team blue can't steal the Sultan. Protect it!");
            RemovePlayerFromVehicle(playerid);
            return 0;
            }
        }
        return 1;
}
I have 2 teams: BLUE and GREEN. ONLY green should be allowed to take the Sultan, but doesn't work. Blue are allowed, how to fix it?
Reply
#2

Quote:

This callback is called when a player starts to enter a vehicle, meaning the player is not in vehicle yet at the time this callback is called.

They're NOT IN the vehicle when it will be called; therebefore vehicleidk will be 0 and it cannot remove the player when they're not actually in the vehicle.

Use OnPlayerStateChange instead.

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetPlayerVehicleID(playerid) == Sultan && gTeam[playerid] == TEAM_BLUE)
        {
            SendClientMessage(playerid,0xAA3333AA,"** Team blue can't steal the Sultan. Protect it!");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
I assume "Sultan" is vehicleid and not modelid.
Reply
#3

Oh, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)