Results 1 to 3 of 3

Thread: Search nickname for his part

  1. #1
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts

    Search nickname for his part

    I make the team for a chat, for example:
    Code:
    Player1 name: ^1Su^7per^3-^2Game^5r^8!!!
    Player2 say: !mute super
    and now Player2 no inaudible Player1.
    How to make a determination on the nick introduced its parts.
    PRE TY

  2. #2
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Code:
    isSubStr(name1, name2)

  3. The Following User Says Thank You to Ni3ls For This Useful Post:

    maxdamage99 (14th October 2015)

  4. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    PHP Code:

    findplayerbydata
    (string)
    {
        
    //assumes you'd rather call a player by its name than by its entitynumber
        //doesnt check for entitynumber at all atm
        
    if(!isdefined(string))
            return 
    undefined;
        
    string stripcolors(tolower(string));

        
    tmp "";
        for(
    0string.sizei++)
        {
            if(
    isint(string[i]))
                
    tmp += string[i];
            else
            {
                if(
    string[i] != " ")
                
    tmp "";
                break;
            }
        }
        
    players getentarray("player""classname");
        if(
    tmp != "")
        {
            for(
    0players.sizei++)
            {
                if(!
    isdefined(players[i].izno) || !isdefined(players[i].izno["login_completed"]))
                    continue;
                if(
    players[igetentitynumber() == int(tmp))
                    return 
    players[i];
            }
        }

        
    BONUS_FOR_CHARS_IN_ORDER 50;
        
    BONUS_CORRECT_CHAR 25;
        
    BONUS_FOR_COMPLETE 200;
        
    best_player undefined;

        
    best_score 0;

        for(
    0players.sizei++)
        {
            
    score 0;
            
    previous_correct_char = -1;
            
    name stripcolors(tolower(players[i].name));
            
    found false;
            for(
    0name.size string.size 1j++)
            {
                
    tmp getsubstr(namejstring.size);
                if(
    tmp == string)
                {
                    
    score += (BONUS_FOR_CHARS_IN_ORDER BONUS_CORRECT_CHAR) * string.size BONUS_FOR_COMPLETE;
                    
    found true;
                    break;
                }
            }
            if(!
    found)
            {
                
    used = [];
                for(
    0name.sizej++)
                {
                    for(
    0string.sizek++)
                    {
                        if(
    isdefined(used[k]))
                            continue;
                        if(
    name[j] == string[k])
                        {
                            
    used[k] = true;
                            if(
    == previous_correct_char 1)
                                
    score += BONUS_FOR_CHARS_IN_ORDER;
                            
    previous_correct_char j;
                            
    score += BONUS_CORRECT_CHAR;
                        }
                    }
                }
            }
            if(
    score best_score)
            {
                
    best_score score;
                
    best_player players[i];
            }
            else if(
    score == best_score)
                
    best_player undefined;
        }
        if(
    isdefined(best_player))
        {
            if(
    best_score BONUS_CORRECT_CHAR string.size)
                return 
    best_player;
        }
        return;

    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. The Following User Says Thank You to IzNoGoD For This Useful Post:

    DaWe (26th August 2016)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •