Page 3 of 3 FirstFirst 123
Results 21 to 28 of 28

Thread: Kicking bots

  1. #21
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by filthy_freak_ View Post
    Before I attempt to implement the method into my libcod, I have a quick question;

    Why is it
    Code:
    void PlayerCmd_renamebot(int a1) {
    instead of
    Code:
    void PlayerCmd_renamebot(string newname) {
    since you do
    Code:
    players[i] renamebot(newname);
    a1 is like he said the entity number. The parameters you use are stored in the stack of cod script. They get retrieved by Script_GetString(0). (different function in libcod)

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

    filthy_freak_ (24th May 2014)

  3. #22
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by Mitch View Post
    a1 is like he said the entity number. The parameters you use are stored in the stack of cod script. They get retrieved by Script_GetString(0). (different function in libcod)
    Ahh that makes sense, thanks the explanation.

  4. #23
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Because it is a method being called on a player, and the integer is the entitynumber.

    The function itself gets the string you want, using getStackString() or something named quite similar.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. #24
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Alright so keep in mind that libcod is new for me so I don't understand it much at all.

    That being said... I have a really noob problem.

    I'm getting this when compiling;
    Code:
    ##### COMPILE cod2_1_0 GSC_PLAYER.CPP #####
    gsc_player.cpp: In function "void PlayerCmd_renamebot(int)":
    gsc_player.cpp:59:35: error: "Script_GetString" was not declared in this scope
    gsc_player.cpp:60:19: error: "MAX_STRING_CHARS" was not declared in this scope
    gsc_player.cpp:61:21: error: "userinfo" was not declared in this scope
    gsc_player.cpp:61:47: error: "getuserinfo" was not declared in this scope
    gsc_player.cpp:68:46: error: "Info_SetValueForKey" was not declared in this scope
    gsc_player.cpp:69:29: error: "setuserinfo" was not declared in this scope
    gsc_player.cpp:71:5: error: "client_t" was not declared in this scope
    gsc_player.cpp:71:15: error: "cl" was not declared in this scope
    gsc_player.cpp:71:32: error "getclient" was not declared in this scope
    So i'm guessing those functions don't exist?

    Edit: aha... looking through the q3 source code I see some of these methods... might be able to work this out
    Edit2: Yeah.. nah. Do I really have to move over all these methods from the q3 source? Some of them require more methods (Example: "getuserinfo" requires "Q_strncpyz" which requires "strncpy" etc) which is making this a mess for me to understand/work out.

    Is it possible for you to supply a precompiled version?
    Last edited by filthy_freak_; 24th May 2014 at 20:27.

  6. #25
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Lol i'm dumb I only just realized that your code was for cod1 CodExtended.

    Could someone with the skills change the bot names for cod2 using libcod and share the code? Would be a very very very useful feature for me. =D

  7. #26
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    I'm getting some weird errors when kicking meatbots.

    Basically, I created a monitor (code below) to add a bot if team size < 6, and remove a bot if team size > 6 && there is at least one bot in the team.

    The problem is:
    I join the server and a team, the bot is kicked;
    The bot is still in the server, although the slot was freed (first image);
    The bot still counts as being in the team I joined, so the server keeps trying to kick it constantly;
    When I leave the server, this "ghost" bot rejoins the team (the server shows 11 players only, since its slot was freed);
    When I reconnect, I use the slot of the kicked bot. The team score hud is duplicated (second image), and, as a spectator, I keep aiming at the other bots (which is what meatbot's check enemy function does, in an infinite loop);
    At this moment, when I join the same team I joined earler, I get disconnected - it seems that I have self.isbot defined (the kicked bot had this it defined), so I count as a bot and the bot monitor tries to kick me to make room for myself, lol;
    After I disconnect, the server keeps trying to kick whoever is in the slot I was using, so, in the console, it prints "Client 1 is not active" every time it goes through the monitor function.

    Click image for larger version. 

Name:	scoretable_edited.png 
Views:	74 
Size:	298.9 KB 
ID:	1309

    Click image for larger version. 

Name:	dup_huds.png 
Views:	53 
Size:	22.9 KB 
ID:	1308

    PHP Code:
    botMonitor()
    {
        
    self endon("intermission");
        
        
    currentteam "allies";
        
        for(;;)
        {
            
    // start the monitor a while after map loading
            
    timepassed = (getTime() - level.starttime) / 1000;
            
    delayonstart 20;
            
            if
            (
                (
    timepassed delayonstart) &&
                (
    getCvar("mod_allow_bots") == "1")
            )
            {
                
    // get bot count and player count for the current team
                
    botsonteam 0;
                
    playersonteam 0;
                
                
    players getentarray("player""classname");
                
                for(
    0players.sizei++)
                {
                    if(
    players[i].pers["team"] == currentteam)
                    {
                        if
                        (
                            (
    isDefined(players[i].isbot)) ||
                            (
    players[igetIP() == "0")
                        )
                        {
                            
    botsonteam++;
                        }
                        else
                        {
                            
    playersonteam++;
                            
    iprintln(players[i].name);
                        }
                    }
                }
                
                
    // add a bot to the current team if it is not complete
                
    botmaxnumber getCvarInt("mod_bots_" currentteam);
                
                if((
    playersonteam botsonteam) < botmaxnumber)
                {
                    
    reAddBot(currentteam);
                }
                else
                {
                    
    // remove a bot from the current team if it has too many
                    
    if
                    (
                        (
    botsonteam 0) &&
                        ((
    playersonteam botsonteam) > botmaxnumber)
                    )
                    {
                        
    iprintln("trying to kick a bot from " currentteam);
                        
                        
    level kickBotFromTeam(currentteam);
                    }
                }
                
                if(
    currentteam == "allies")
                {
                    
    currentteam "axis";
                }
                else
                {
                    
    currentteam "allies";
                }
            }
            
            
    wait(0.5);
        }

    PHP Code:
    kickBotFromTeam(team)
    {
        
    players getentarray("player""classname");
        
        for(
    0players.sizei++)
        {
            if
            (
                (
    players[i].pers["team"] == team) &&
                (
                    (
    isDefined(players[i].isbot)) ||
                    (
    players[igetIP() == "0")
                )
            )
            {
                
    entnum players[igetentitynumber();
                
    kick(entnum);
                
    free_slot(entnum);
                
                break;
            }
        }

    Any ideas?
    Last edited by guiismiti; 31st March 2017 at 17:47. Reason: edited screenshot
    set logfile 2

  8. #27
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 Posts
    You have to wait a little bit before freeing slot or just use libcod from my repo, has an autofreeslot for bots so you can just normally kick it. Also your isBot definiton seems wrong, just use:
    PHP Code:
    isBot()
    {
        return 
    self getAddressType() == 0;
    }

    if (
    self isBot())
    {
        
    bla bla...

    sudo apt-get rekt

  9. The Following 2 Users Say Thank You to voron00 For This Useful Post:

    guiismiti (31st March 2017),kung foo man (1st April 2017)

  10. #28
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    Quote Originally Posted by voron00 View Post
    You have to wait a little bit before freeing slot or just use libcod from my repo, has an autofreeslot for bots so you can just normally kick it. Also your isBot definiton seems wrong, just use:
    PHP Code:
    isBot()
    {
        return 
    self getAddressType() == 0;
    }

    if (
    self isBot())
    {
        
    bla bla...

    1 - I tried using getAddressType() but my version of libcod is a little old so, whenever I'm not using .isbot I'm using getIP() == 0.
    .isbot works well because it is defined when the test client is added;
    2 - Are you serious??? All I had to do was to add a wait before freeing the slot??? I wasted hours last night trying to figure this out, testing and testing and testing, before writing everything in details... lol

    Thanks
    set logfile 2

Posting Permissions

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