Just for green team - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Just for green team (
/showthread.php?tid=474826)
Just for green team -
Face9000 - 09.11.2013
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?
Re: Just for green team -
Konstantinos - 09.11.2013
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.
Re: Just for green team -
Face9000 - 09.11.2013
Oh, thanks.