No, just check the opposite state and open a bracket after it, I've optimized this code for you, uncompiled though
pawn Код:
public OnPlayerUpdate(playerid)
{
if(gPlayerInfo[playerid][pTeam] == TEAM_MARINES || !IsPlayerInAnyVehicle(playerid)) AvoidSAMAttacksOnPlayer(playerid, usabasesam);
else if(gPlayerInfo[playerid][pTeam] != TEAM_MARINES) EnableSAMAttacksOnPlayer(playerid, usabasesam);
if(IsSAMMissileChasing(playerid) && samwarning[playerid] == 0)
{
SendClientMessage(playerid, RED, "**RADAR WARNING:::SAM TARGETED**");
samwarning[playerid] = 1;
PlayerPlaySound(playerid,1138,0.0,0.0,0.0);
SetTimerEx("SamWarnTimer", 3000, 0, "i", playerid);
}
//SAM targeting only aircraft & not marines
new state = GetPlayerState(playerid);
if(gPlayerInfo[playerid][pTeam] != TEAM_MARINES && (state == PLAYER_STATE_DRIVER || state == PLAYER_STATE_PASSENGER))
{
switch(GetVehicleModel(GetPlayerVehicleID(playerid))
{
case 520, 425, 447, 432, 548, 417, 487, 488, 497, 563, 469, 460, 476, 511, 512, 513, 519, 553, 577, 592, 593:
{
EnableSAMAttacksOnPlayer(playerid, usabasesam);
}
default:
{
AvoidSAMAttacksOnPlayer(playerid, usabasesam);
}
}
}
return 1;
}
Also incase you wanna use it as a timer
pawn Код:
public OnGameModeInit()
{
SetTimer("OneSecondTimer", 1000, 1);
return 1;
}
forward OneSecondTimer();
public OneSecondTimer()
{
for(new playerid; playerid<MAX_PLAYERS; playerid++)//You should use foreach or playerpoolsize(0.3.7 R2) instead
{
if(gPlayerInfo[playerid][pTeam] == TEAM_MARINES || !IsPlayerInAnyVehicle(playerid)) AvoidSAMAttacksOnPlayer(playerid, usabasesam);
else if(gPlayerInfo[playerid][pTeam] != TEAM_MARINES) EnableSAMAttacksOnPlayer(playerid, usabasesam);
if(IsSAMMissileChasing(playerid) && samwarning[playerid] == 0)
{
SendClientMessage(playerid, RED, "**RADAR WARNING:::SAM TARGETED**");
samwarning[playerid] = 1;
PlayerPlaySound(playerid,1138,0.0,0.0,0.0);
SetTimerEx("SamWarnTimer", 3000, 0, "i", playerid);
}
//SAM targeting only aircraft & not marines
new state = GetPlayerState(playerid);
if(gPlayerInfo[playerid][pTeam] != TEAM_MARINES && (state == PLAYER_STATE_DRIVER || state == PLAYER_STATE_PASSENGER))
{
switch(GetVehicleModel(GetPlayerVehicleID(playerid))
{
case 520, 425, 447, 432, 548, 417, 487, 488, 497, 563, 469, 460, 476, 511, 512, 513, 519, 553, 577, 592, 593:
{
EnableSAMAttacksOnPlayer(playerid, usabasesam);
}
default:
{
AvoidSAMAttacksOnPlayer(playerid, usabasesam);
}
}
}
}
return 1;
}