Raised This Month: $ Target: $400
 0% 

Kick a random bot.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
althor
New Member
Join Date: Oct 2012
Old 01-18-2013 , 20:32   Kick a random bot.
Reply With Quote #1

Hello everyone. I am trying to kick a bot The first one it finds is fine. It does work how ever. It kicks the bot and If a player try's to connect to the server it wants to kick them no matter how many times they try to connect. Any help would be appreciated.

Here is the code I am using
Code:
public kickrandombot(id)
{
    //bots
    new Players[32]
    new playerCount, userid
    get_players(Players, playerCount, "d")
    
    for (new i=0; i<playerCount; i++)
    {    
        userid = get_user_userid(Players[i])
        
        server_cmd("kick #%d", userid)
        break;
    }
}

Last edited by althor; 01-18-2013 at 21:28.
althor is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-19-2013 , 01:49   Re: Kick a random bot.
Reply With Quote #2

I'm not exactly sure about what you are saying but everything looks fine to me. Though, your for loop doesn't really do anything. It's just acting as an if statement:

PHP Code:
if( playerCount )
{
    
server_cmd("kick #%d"get_user_userid(players[0]))

__________________

Last edited by fysiks; 01-19-2013 at 01:49.
fysiks is offline
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-19-2013 , 09:59   Re: Kick a random bot.
Reply With Quote #3

PHP Code:
if( playerCount )
{
    
server_cmd("kick #%d"get_user_userid(players[random_num(0,playerCount)]))

__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT

Last edited by AngeIII; 01-19-2013 at 09:59.
AngeIII is offline
Send a message via Skype™ to AngeIII
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-19-2013 , 11:20   Re: Kick a random bot.
Reply With Quote #4

Quote:
Originally Posted by AngeIII View Post
PHP Code:
if( playerCount )
{
    
server_cmd("kick #%d"get_user_userid(players[random_num(0,playerCount)]))

That is not correct. You are allowing for the possibility of players[playerCount] which is not a valid player returned by get_players(). You should use random(playerCount) which is better than random_num(0, playerCount-1).
__________________
fysiks is offline
althor
New Member
Join Date: Oct 2012
Old 01-20-2013 , 10:33   Re: Kick a random bot.
Reply With Quote #5

Thanks guys for the comments.
I have tried almost everything I could think of.
It always done the same thing.
It "works" but when a player tried to connect. Right after kicking the first bot.
It would kick the "first" connecting player. Some players could get in. Some couldn't.

I was going by the wiki here.
http://www.amxmodx.org/doc/index.htm...et_players.htm

As fysiks pointed out. It should of worked and "did".
I even added a side by side loop to make sure it wasn't a actual player being kicked.
Added is_user_connecting and is_user_connected.

From the loop. Like it was counting the player connecting for a bot. Extremely weird.
Finally I had enough, So I made this in foxbot's source.

PHP Code:
kickrandombot()
{
    
server_cmd("bot kickrandombot")

Here is an alternative I tried.
PHP Code:
public kickrandombot(id)
{
    new 
Players[32]
    new 
playerCountiplayer
    get_players
(PlayersplayerCount"d")
    
    for (
i=0i<playerCounti++)
    {
        
player Players[i]
        if(
is_user_bot(player) && !is_user_connecting(player) && is_user_connected(player)) 
        {
            
server_cmd("kick #%d"player)
            break;
        }
    }

And another,
PHP Code:
public kickrandombot(id)
{
    new 
Players[32]
    new 
playerCount
    get_players
(PlayersplayerCount"d")

    if(
playerCount 0)
        
server_cmd("kick #%d"get_user_userid(players[random_num(1,playerCount)]))

Thank you everyone for your suggestions.
Althor

Last edited by althor; 01-20-2013 at 10:35. Reason: Tag Mistake
althor is offline
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-20-2013 , 10:52   Re: Kick a random bot.
Reply With Quote #6

get_user_userid(players[random_num(1,playerCount)]))
use fysiks method
get_user_userid(players[random(playerCount)]))
__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT

Last edited by AngeIII; 01-20-2013 at 10:52.
AngeIII is offline
Send a message via Skype™ to AngeIII
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-20-2013 , 13:41   Re: Kick a random bot.
Reply With Quote #7

Attach the full plugin because what you are describing cannot be happening based on the code that you have shown.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode