sscanf2 MATCH_NAME_PARTIAL
#1

well ok idk but how is this gonna work first how can i make it globally to 1, after that how can we make if the player types uchiha and the name is sasuke_uchiha it will work with making MATCH_NAME_PARTIAL but how to do that if there are 3 online player 1 me and other two Sasuke_uchiha and Itachi_Uchiha if i type uchiha it should say "Uchiha is found in multiple name please be more specific" and i am using specifiers "U".
Reply
#2

MATCH_NAME_PARTIAL:
pawn Код:
Currently sscanf will search for players by name, and will ALWAYS search for player whose name STARTS with the specified string. If you have, say "[CLAN]******" connected and someone types "******", sscanf will not find "[CLAN]******" because there name doesn't start with the specified name. This option, when set to 1, will search ANYWHERE in the player's name for the given string.
CELLMIN_ON_MATCHES:

pawn Код:
Whatever the value of "MATCH_NAME_PARTIAL", the first found player will always be returned, so if you do a search for "_" on an RP server, you could get almost anyone. To detect this case, if more than one player will match the specified string then sscanf will return an ID of "cellmin" instead. This can be combined with "U" for a lot more power:
pawn Код:
sscanf(params, "?<CELLMIN_ON_MATCHES=1>U(-1)", id);
    if (id == -1)
    {
        // No player was entered.
    }
    else if (id == cellmin)
    {
        // Multiple matches found
    }
    else if (id == INVALID_PLAYER_ID)
    {
        // Entered player is not connected.
    }
    else
    {
        // Found just one player.
    }
Reply
#3

Код:
CMD:check(playerid, params[])
{
	if(gLogged[playerid] == 0) return SendLanguageMessage(playerid, COLOR_WHITE, LoginOnlyEN, LoginOnlyRO);
	if(PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pHelper] < 1) return SendLanguageMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You are not admin or a helper.", "{FFFFCC}Eroare: Nu esti admin sau helper.");
	if(AccountLocked[playerid] == 0) return SendLanguageMessage(playerid, COLOR_WHITE, "{FFB870}Error: Your account is locked. Type /unlockacc to unlock it and use this command.", "{FFB870}Eroare: Contul tau este blocat. Scrie /unlockacc pentru a il debloca si pentru a folosi aceasta comanda.");
	new id[16];
	if(sscanf(params, "u[16]",id)) return SendLanguageMessage(playerid, COLOR_WHITE, "{B8DBFF}Synthax: /check <Name/Playerid>","{B8DBFF}Sintaxa: /check <Nume/ID>");
        if(!CheckMultipleNames(playerid, id)) return 1;
 	if(id[0] == INVALID_PLAYER_ID) return SendLanguageMessage(playerid, COLOR_WHITE, PlayerOfflineEN, PlayerOfflineRO);
	if(!IsPlayerConnected(id[0])) return SendLanguageMessage(playerid, COLOR_WHITE, PlayerOfflineEN, PlayerOfflineRO);
	ShowStats(playerid, id[0]);
	return 1;
}

stock CheckMultipleNames(playerid, array[])
{
    new strfound[180], yesno , foundplayer, name[MAX_PLAYER_NAME];
    for(new i = 0; array[i] != INVALID_PLAYER_ID; i++)
	{
        GetPlayerName(array[i], name, sizeof(name));
        if (array[i] == cellmin)
		{
            if(yesno == 0)
			{
				SendLanguageMessage(playerid, 0xFFFFFFFF, "{FFFFCC}Too many players matched your search. Use one of these IDs.", "{FFFFCC}Prea multi jucatori corespund cautarii. Foloseste unul dintre aceste ID-uri.");
				format(strfound, sizeof(strfound), "{FFFFCC}ID: (%d) %s", foundplayer, GetName(foundplayer));
				SendClientMessage(playerid, 0xFFFFFFFF, strfound);
			}
			yesno ++;
		    format(strfound, sizeof(strfound), "{FFFFCC}ID: (%d) %s", array[i], name);
			SendClientMessage(playerid, 0xFFFFFFFF, strfound);
        }
        foundplayer = array[i];
    }
    if(yesno > 0) return 0;
	return 1;
}
I have a problem celmin is always equal "--".
But the number of matches is higher than 15, I need to shot Too many matches, how to edit the CheckMultipleNames ?
Reply
#4

pawn Код:
CMD:check(playerid, params[])
{
    if(gLogged[playerid] == 0) SendLanguageMessage(playerid, COLOR_WHITE, LoginOnlyEN, LoginOnlyRO);
    else if(PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pHelper] < 1) SendLanguageMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You are not admin or a helper.", "{FFFFCC}Eroare: Nu esti admin sau helper.");
    else if(AccountLocked[playerid] == 0) SendLanguageMessage(playerid, COLOR_WHITE, "{FFB870}Error: Your account is locked. Type /unlockacc to unlock it and use this command.", "{FFB870}Eroare: Contul tau este blocat. Scrie /unlockacc pentru a il debloca si pentru a folosi aceasta comanda.");
    else
    {
        new id;
        sscanf(params, "?<CELLMIN_ON_MATCHES=1>U(-1)", id);
        if(id == -1)
        {
            // No player was entered.
            SendLanguageMessage(playerid, COLOR_WHITE, "{B8DBFF}Synthax: /check <Name/Playerid>","{B8DBFF}Sintaxa: /check <Nume/ID>");
        }
        else if(id == cellmin)
        {
            // Multiple matches found
            // Uchiha is found in multiple name please be more specific
            SendLanguageMessage(playerid, 0xFFFFFFFF, "{FFFFCC}Player is found in multiple name please be more specific.", "{FFFFCC}Prea multi jucatori corespund cautarii. Foloseste unul dintre aceste ID-uri.");
        }
        else if(id == INVALID_PLAYER_ID)
        {
            // Entered player is not connected.
            SendLanguageMessage(playerid, COLOR_WHITE, PlayerOfflineEN, PlayerOfflineRO);
        }
        else
        {
            // Found just one player.
            ShowStats(playerid, id);
        }
    }
    return 1;
}
?
Reply
#5

I want to use stock CheckMultipleNames, but this it does not work because cellmin is always equal with --.
Reply
#6

Bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)