viewing paste Unknown #6103 | Text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
    char temp0[100];
    struct map_session_data *pl_sd;
    struct s_mapiterator* iter;
    int j, count;
    int pl_GM_level, GM_level;
    char match_text[100];
    int flag = 0;
    char player_name[NAME_LENGTH];
 
    nullpo_retr(-1, sd);
 
    memset(atcmd_output, '\0', sizeof(atcmd_output));
    memset(match_text, '\0', sizeof(match_text));
    memset(player_name, '\0', sizeof(player_name));
 
    if (sscanf(message, "%99[^\n]", match_text) < 1)
        strcpy(match_text, "");
    else
        flag = 1;
    for (j = 0; match_text[j]; j++)
        match_text[j] = TOLOWER(match_text[j]);
 
    count = 0;
    GM_level = pc_isGM(sd);
 
    iter = mapit_getallusers();
    for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
    {
        pl_GM_level = pc_isGM(pl_sd);
        if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
        {// you can look only lower or same level
            memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
            for (j = 0; player_name[j]; j++)
                player_name[j] = TOLOWER(player_name[j]);
            if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
 
                if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
                    sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
                } else {
                    atcmd_output[0]=0;
                }
                //Player name
                sprintf(temp0, msg_txt(333), pl_sd->status.name);
                strcat(atcmd_output,temp0);
                //Player title, if exists
                if (pl_GM_level > 0) {
                    //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
                    sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
                    strcat(atcmd_output,temp0);
                }
                //Players Location: map x y
                sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
                strcat(atcmd_output,temp0);
                if( pl_sd->state.autotrade ){
                    if(!flag)
                        count++;
                    continue;
                }
                clif_displaymessage(fd, atcmd_output);
                count++;
            }
        }
    }
    mapit_free(iter);
 
    if (count == 0)
        clif_displaymessage(fd, msg_txt(28)); // No player found.
    else if (count == 1)
        clif_displaymessage(fd, msg_txt(29)); // 1 player found.
    else {
        sprintf(atcmd_output, msg_txt(30), count); // %d players found.
        clif_displaymessage(fd, atcmd_output);
    }
 
    return 0;
}
Viewed 735 times, submitted by Guest.