Таки не вводите людей в заблуждение. Switch вызывает функцию 1 раз и уже работает с результатом. Даже если мы введём 100 членов для сравнения.
Вот вам банальный код как пример:
PHP код:
stock GetPlayerAnimationIndexEx(playerid)
{
print("\nФункция GetPlayerAnimationIndex вызвана\n");
return GetPlayerAnimationIndex(playerid);
}
#define GetPlayerAnimationIndex GetPlayerAnimationIndexEx
public OnPlayerConnect(playerid)
{
switch(GetPlayerAnimationIndex(playerid))
{
case 1195, 1196, 1197:
{
ClearAnimations(playerid, 0);
ApplyAnimation( playerid, "PED", "KO_skid_back", 4.1, 0, 0, 0, 0, 0 );
SetTimerEx("AntiBH", 500, 0, "d", playerid);
return 1;
}
case 12, 123, 357:
{
ClearAnimations(playerid, 0);
ApplyAnimation( playerid, "PED", "KO_skid_back", 4.1, 0, 0, 0, 0, 0 );
SetTimerEx("AntiBH", 500, 0, "d", playerid);
return 1;
}
case 11, 5, 65:
{
ClearAnimations(playerid, 0);
ApplyAnimation( playerid, "PED", "KO_skid_back", 4.1, 0, 0, 0, 0, 0 );
SetTimerEx("AntiBH", 500, 0, "d", playerid);
return 1;
}
}
switch(GetPlayerAnimationIndex(playerid))
{
case 1195, 1196, 1197:
{
ClearAnimations(playerid, 0);
ApplyAnimation( playerid, "PED", "KO_skid_back", 4.1, 0, 0, 0, 0, 0 );
SetTimerEx("AntiBH", 500, 0, "d", playerid);
return 1;
}
case 12, 123, 357:
{
ClearAnimations(playerid, 0);
ApplyAnimation( playerid, "PED", "KO_skid_back", 4.1, 0, 0, 0, 0, 0 );
SetTimerEx("AntiBH", 500, 0, "d", playerid);
return 1;
}
case 11, 5, 65:
{
ClearAnimations(playerid, 0);
ApplyAnimation( playerid, "PED", "KO_skid_back", 4.1, 0, 0, 0, 0, 0 );
SetTimerEx("AntiBH", 500, 0, "d", playerid);
return 1;
}
}
return 1;
}
В консоль выдаст ровно 2 сообщения. Когда такой код:
PHP код:
stock GetPlayerAnimationIndexEx(playerid)
{
print("\nФункция GetPlayerAnimationIndex вызвана\n");
return GetPlayerAnimationIndex(playerid);
}
#define GetPlayerAnimationIndex GetPlayerAnimationIndexEx
public OnPlayerConnect(playerid)
{
if(GetPlayerAnimationIndex(playerid) == 1195 || GetPlayerAnimationIndex(playerid) == 1196 || GetPlayerAnimationIndex(playerid) == 1197)
{
ClearAnimations(playerid, 0);
ApplyAnimation( playerid, "PED", "KO_skid_back", 4.1, 0, 0, 0, 0, 0 );
SetTimerEx("AntiBH", 500, 0, "d", playerid);
return 1;
}
return 1;
}
Естественно выдаст 3. Хотя может вы говорите не о том...