Results 1 to 10 of 28

Thread: Kicking bots

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Private First Class php's Avatar
    Join Date
    Nov 2012
    Posts
    142
    Thanks
    28
    Thanked 116 Times in 59 Posts
    For changing bot names;

    PHP Code:

    void PlayerCmd_renamebot
    (int a1) {
        
    charkey Script_GetString(0);
        
    char userinfo[MAX_STRING_CHARS];
        
    getuserinfo(a1userinfosizeof(userinfo));
        
        
    /*char* value = Info_ValueForKey(userinfo, key);
        if(value == NULL)
            Script_AddString("");
        else
            Script_AddString(value);*/
        
    Info_SetValueForKey(userinfo"name"key);
        
    setuserinfo(a1userinfo);
        
        
    client_tcl getclient(a1);
        if(
    cl) {
            
    memcpy(&cl->name[0], key32);
            
    cl->name[31] = '\0';
        }
        
        
    printf("name = %s\n"cl->name);

    I didn't check if it only works with cl->name or userinfo so I set both and I really don't care to find out.
    As for name changing instantly, just call *_UserinfoChanged (harder way for non-libcod people)
    For convience I held on to the q3/wolf SDK name conventions so you can look it up yourself what it does and all.

    Easier way is just to use the builtin script function

    UpdateClientNames()
    Module: Level
    MP Only

    Summary:
    Update all of the client names: only works in 'manual_change' mode
    Usage:

    PHP Code:
    newname "harry you're a wizard";
    players=getentarray("player","classname");
    for(
    i=0;i<players.size;i++){
        if(
    players[iisbot()) {
            
    players[irenamebot(newname);
    }
    updateclientnames(); //calling it for every bot name change in a loop is not recommended except when you're only changing one bot name
    //since it's a loop let's call it at the end
    //it will notify in a iprintln with "bot<number> changed name to <newname>"
    //so find the UserinfoChanged or set the start of that string (hex edit) to \0

    PHP Code:
    void PlayerCmd_isbot(int a1) {
        
    client_tcl getclient(a1);
        if(
    cl) {
            if(
    cl->remoteAddress.type == NA_BOT)
                
    Script_AddBool(true);
            else
                
    Script_AddBool(false);
        } else {
            
    Script_AddBool(false);
        }

    As for the CoDExtended functions if you'd like to convert them to libcod, just look up the Q3/WOLF SDK
    a1 = entityNumber
    getclient = function gets client_t pointer for number
    Last edited by php; 24th May 2014 at 11:53.

  2. The Following User Says Thank You to php For This Useful Post:

    filthy_freak_ (24th May 2014)

Posting Permissions

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