30.08.2017, 02:55
You must use strcat, format or strcpy (macro) to copy a string to another string. Although this isn't needed in actuality, try this:
GetPlayerPoolSize() exists. Use it (if you're on 0.3.7)!
Strreplace must support multiple characters for search and replace parameter, when one is only required you could simplify things and make it more optimized with a simple loop, an if-then and a replacement code. Strfind can become slow (if that's what it uses)!
PHP код:
new params[] = "Paulice", matchesFound[MAX_PLAYERS];
for(new i = 0, j = GetPlayerPoolSize(), k = 0; i <= j; i ++)
{
if(IsPlayerConnected(i) && strfind(ReturnName(i, 0), params, true) != -1)
{
matchesFound[k ++] = i;
if(k >= 5)
{
break;
}
}
}
stock ReturnName(playerid, underScore = 1)
{
new playersName[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, playersName, sizeof(playersName));
if(!underScore)
{
for(new i = 0, j = strlen(playersName); i < j; i ++)
{
if(playersName[i] == '_')
{
playersName[i] = ' ';
}
}
}
return playersName;
}
Strreplace must support multiple characters for search and replace parameter, when one is only required you could simplify things and make it more optimized with a simple loop, an if-then and a replacement code. Strfind can become slow (if that's what it uses)!