Raised This Month: $51 Target: $400
 12% 

[NonBug] Loop or is_ extensioned functions bug.


  
 
 
Thread Tools Display Modes
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-02-2006 , 22:07   [NonBug] Loop or is_ extensioned functions bug.
#1

I've reported this before, but have gotten a reply of "I'm afraid to touch the code" before.
This is sort of a serious bug and I would appreicate it, if it could be fixed properly.

The problem is, The command kick_all_bots is initiated, and on the first time of executing the command, it kicks

ID: 1
ID: 2.

On the second time or higher it tries to kick playerid's

ID: 1
ID: 2.

AGAIN!!!!! Even though the userid's are 3 and 4 and there are no player's with 1 and 2!

Now I don't know if it's my fault, but I've ran into this strange occurrance many times before and I would just like to bring it to your attention.

Code:
public kick_all_bots() {        new const plnum = get_maxplayers()     for(new i = 0; i <= plnum; i++)     {          kick_all_bots_now(i)     }     return PLUGIN_HANDLED } public kick_all_bots_now(i) {     if(is_user_bot(i) && is_user_connected(i))     {         new command[32]         format(command,sizeof(command),"kick #%i",i)         server_cmd(command)         server_print(command)     }     server_print("ID: %i",i)     return PLUGIN_HANDLED }
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
juKay
Member
Join Date: Mar 2004
Location: Sweden
Old 06-02-2006 , 22:30  
#2

Because you are using it the wrong way. You have to get the userid of the player, see get_user_userid(). i in your code is just a position in the loop nothing more:



Code:
 public kick_all_bots()
{    
    new const plnum = get_maxplayers()

    for(new i = 0; i <= plnum; i++) 
    {  
        if (is_user_bot(i) && is_user_connected(i))
        {
            new command[32]
            new userid = get_user_userid(i)
            format(command,sizeof(command),"kick #%d", userid)
            server_cmd(command)
            server_print(command)
        }
    }
    return PLUGIN_HANDLED
}
juKay is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-02-2006 , 22:35  
#3

Oh wow....
Now I feel stupid. Thank You.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
BAILOPAN
Join Date: Jan 2004
Old 06-02-2006 , 22:47  
#4

I have no idea what just happened here, but... locked!
__________________
egg
BAILOPAN is offline
 



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 09:57.


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