08.12.2012, 13:03
When I try to apply foreach, commands where you need to enter a players name say that there is no such player, what did I do wrong?
Original:
With foreach:
And can I replace something like this with foreach, if yes, how?
Original:
Код:
stock GetPlayeridMid(name[])
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
new gPlayerName[MAX_PLAYER_NAME];
GetPlayerName(i, gPlayerName, MAX_PLAYER_NAME);
if(strfind(gPlayerName, name, true) != -1)
{
return i;
}
}
}
return INVALID_PLAYER_ID;
}
Код:
stock GetPlayeridMid(name[])
{
foreach(Player, i)
{
new gPlayerName[MAX_PLAYER_NAME];
GetPlayerName(i, gPlayerName, MAX_PLAYER_NAME);
if(strfind(gPlayerName, name, true) != -1)
{
return i;
}
}
return INVALID_PLAYER_ID;
}
Код:
new AutoSavet[MAX_PLAYERS];



The original change works fine.