sscanf problem.
#6

From sscanf thread:
Quote:

Users can now optionally return an ARRAY of users instead of just one. This array is just a list of matched IDs, followed by "INVALID_PLAYER_ID". Given the following players:

Код:
0) ******
1) [CLAN]******
2) Jake
3) Alex
4) Hass
This code:

pawn Код:
new ids[3], i;
if (sscanf("Le", "?<MATCH_NAME_PARTIAL=1>u[3]", ids)) printf("Error in input");
for (i = 0; ids[i] != INVALID_PLAYER_ID; ++i)
{
    if (ids[i] == cellmin)
    {
        printf("Too many matches");
        break;
    }
    printf("id = %d", ids[i]);
}
if (i == 0) printf("No matching players found.");
Will output:

Код:
id = 0
id = 1
Too many matches
Searching "Les" instead will give:

Код:
id = 0
id = 1
And searching without "MATCH_NAME_PARTIAL" will give:

Код:
No matching players found.
Basically, if an array of size "N" is passed, this code will return the first N-1 results. If there are less than "N" players whose name matches the given name then that many players will be returned and the next slot will be "INVALID_PLAYER_ID" to indicate the end of the list. On the other hand if there are MORE than "N - 1" players whose name matches the given pattern, then the last slot will be "cellmin" to indicate this fact.

When combined with "U" and returning the default, the first slot is always exactly the default value (even if that's not a valid connected player) and the next slot is always "INVALID_PLAYER_ID".

Reply


Messages In This Thread
sscanf problem. - by Dayrion - 11.11.2017, 01:33
Re: sscanf problem. - by JaydenJason - 11.11.2017, 01:35
Re: sscanf problem. - by Dayrion - 11.11.2017, 01:45
Re: sscanf problem. - by adammal - 11.11.2017, 05:29
Re: sscanf problem. - by Lucases - 11.11.2017, 05:54
Re: sscanf problem. - by Konstantinos - 11.11.2017, 08:37
Re: sscanf problem. - by Dayrion - 11.11.2017, 12:29
Re: sscanf problem. - by Dayrion - 12.11.2017, 13:20
Re: sscanf problem. - by Dayrion - 13.11.2017, 11:49
Re: sscanf problem. - by Dayrion - 14.11.2017, 15:05

Forum Jump:


Users browsing this thread: 1 Guest(s)