17.07.2011, 18:09
Let's say I need to get a player's vehicle ID two times. Which version would be more faster and better and less memory consuming?
Version 1:
Version 2:
I would also like to know, that in such a situation, should I use 'if' or 'else if' or 'else', in the second condition?
Version 1:
pawn Код:
if(GetPlayerVehicleID(playerid) == CPcar)
{
SetPlayerFacingAngle(playerid, 36.12);
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, This is a CP car!);
return 1;
}
}
if(GetPlayerVehicleID(playerid) == CPtruck)
{
SetPlayerFacingAngle(playerid, 31.13);
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, This is a CP truck!);
return 1;
}
}
pawn Код:
new veh;
veh = GetPlayerVehicleID(playerid);
if(veh == CPcar)
{
SetPlayerFacingAngle(playerid, 36.12);
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, This is a CP car!);
return 1;
}
}
if(veh == CPtruck)
{
SetPlayerFacingAngle(playerid, 31.13);
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, This is a CP truck!);
return 1;
}
}