PDA

View Full Version : Just for green team


Face9000
09/11/2013, 08:54 PM
Ok so, i have a custom vehicle and i want to disable the use for TEAM_BLUE, so i did in this way:


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?

Konstantinos
09/11/2013, 08:58 PM
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.


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.

Face9000
09/11/2013, 09:00 PM
Oh, thanks.