SA-MP Forums Archive
[Ajuda] Comando /search - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Comando /search (/showthread.php?tid=595695)



Comando /search - F1N4L - 06.12.2015

Bom pessoa, editei este code de um FS e coloquei no meu GM, ele funciona da seguinte forma:
PHP код:
CMD:rreports(playerid, params[])
{
    new 
name[MAX_PLAYER_NAME];
    if(
sscanf(params, "s[24]", name)) return SendClientMessage(playerid, COLOR_THISTLE, "USAGE: /rreports [playername]");
    
SendClientMessage(playerid, COLOR_ORANGE_RED, " ");
    new 
string[150], arg[56];
    
format(string, sizeof(string), "- Search result for %s:\n", name);
    
SendClientMessage(playerid, COLOR_DODGER_BLUE, string);
    new 
count = 0;
    for(new 
i = 1, j = DB::GetHighestRegisteredKey(gGlobal[s_bugreporttable]); i <= j; i++)
    {
        new 
uName[MAX_PLAYER_NAME];
          
DB::GetStringEntry(gGlobal[s_bugreporttable], i, "username", uName);
        if(
strfind(uName, name, true) != -1)
        {
            
count += 1;
            
            
strcat(string, " [Bug Report: ");
            
DB::GetStringEntry(gGlobal[s_bugreporttable], i, "bugreport", arg);
            
strcat(string, arg);
            
strcat(string, " | Date: ");
            
DB::GetStringEntry(gGlobal[s_bugreporttable], i, "date", arg);
            
strcat(string, arg);
            
strcat(string, "]");
            
SendClientMessage(playerid, COLOR_DODGER_BLUE, string);
        }
    }
    if(! 
count) return SendClientMessage(playerid, COLOR_DODGER_BLUE, "- No account found with that part of name!");
    return 
1;
} 
Ele procura os dados de report do player, do qual estou pesquisando o nome.
Mas quero fazer algo parecido, porйm ele precisa procurar TODOS que reportaram:

PHP код:
CMD:sreports(playerid, params[])
{
    new 
name[MAX_PLAYER_NAME];
    
SendClientMessage(playerid, COLOR_ORANGE_RED, " ");
    new 
string[150], arg[56];
    
format(string, sizeof(string), "- Search result for %s:\n", name);
    
SendClientMessage(playerid, COLOR_DODGER_BLUE, string);
    new 
count = 0;
    for(new 
i = 1, j = DB::GetHighestRegisteredKey(gGlobal[s_bugreporttable]); i <= j; i++)
    {
        new 
uName[MAX_PLAYER_NAME];
          
DB::GetStringEntry(gGlobal[s_bugreporttable], i, "username", uName);
        if(
strfind(gUser[playerid][u_ifbugexist] == 1, true) != -1)
        {
            if(
gUser[playerid][u_ifbugexist] == 1)
            {
            
count += 1;
            
            
strcat(string, " [Bug Report: ");
            
DB::GetStringEntry(gGlobal[s_bugreporttable], i, "bugreport", arg);
            
strcat(string, arg);
            
strcat(string, " | Date: ");
            
DB::GetStringEntry(gGlobal[s_bugreporttable], i, "date", arg);
            
strcat(string, arg);
            
strcat(string, "]");
            
SendClientMessage(playerid, COLOR_DODGER_BLUE, string);
            }
        }
    }
    if(! 
count) return SendClientMessage(playerid, COLOR_DODGER_BLUE, "- No account found with that part of name!");
    return 
1;
} 
ta errado, mas й mais ou menos isso...