28.12.2011, 19:11
Each if statement is evaluated, so once the condition is true the code within the local scope is executed. If false, the check is then passed to the next statement and continues until a check if verified. Code optimization referrers to altering code, to make it more efficient for use. I've made a minor optimization to your code. Since each one of your if statements contains an if(!ispassenger) check, it may be called once. This allows multiple checks without reference to that specific check.
You must be in a vehicle and skin other than the id's listed.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!ispassenger)
{
if(GetVehicleModel(vehicleid) == 525) if(GetPlayerSkin(playerid) != 50)
if(GetVehicleModel(vehicleid) == 596) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 283 || GetPlayerSkin(playerid) != 281)
if(GetVehicleModel(vehicleid) == 597) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 283 || GetPlayerSkin(playerid) != 281 || GetPlayerSkin(playerid) != 288)
if(GetVehicleModel(vehicleid) == 598) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 283 || GetPlayerSkin(playerid) != 281 || GetPlayerSkin(playerid) != 288)
if(GetVehicleModel(vehicleid) == 490) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 281 || GetPlayerSkin(playerid) != 288 || GetPlayerSkin(playerid) != 283)
if(GetVehicleModel(vehicleid) == 427) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 283 || GetPlayerSkin(playerid) != 288 || GetPlayerSkin(playerid) != 281)
ClearAnimations(playerid);
}
return true;
}