AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bot in kz_dajrokan (https://forums.alliedmods.net/showthread.php?t=128853)

SlayeR 06-06-2010 08:02

Bot in kz_dajrokan
 
Hi. I have a problem with bot in dajrokan plugin... He should disconnect when players = 2 but he won't... Help!

There are a parts of code about bot:

PHP Code:

public client_putinserver(id) {

    
climber_time[id]    = 0
    climber_status
[id]    = STATUS_NONE
    climber_no_block
[id]    = kz_no_block true false
    climber_rgb
[id]        = GLOW_DEF
    climber_hud
[id]        = 1
    climber_teleports
[id]    = 0
    climber_checkpoints
[id]    = 0
    climber_stuck
[id]    = STUCK_COUNT
    climber_scout
[id]    = -1
    climber_meter
[id]    = origo
    climber_render
[id]    = true
    climber_lock
[id]    = true
    climber_action
[id]    = false
    climber_autotp
[id]    = true    

    
if (kz_bot) {
        new 
players[32], inum
        get_players
(playersinum)

        if (
inum == 1)
            
mi_bot_connect()
    }

        return 
PLUGIN_CONTINUE
}

public 
client_disconnect(id) {

    if (
kz_bot)
        if (
get_playersnum(1) == 2)
            
mi_bot_disconnect()

        return 
PLUGIN_CONTINUE



PHP Code:

public mi_bot_connect() {

    if (!
bot_id) {
        
bot_id engfunc(EngFunc_CreateFakeClientBOT_NAME)
        new 
ptr[128]
        
dllfunc(DLLFunc_ClientConnectbot_idBOT_NAME"127.0.0.1"ptr)
        
dllfunc(DLLFunc_ClientPutInServerbot_id)
        
cs_set_user_team(bot_idCS_TEAM_CTCS_CT_URBAN)
        
dllfunc(DLLFunc_Spawnbot_id)
        
set_pev(bot_idpev_effects, (pev(bot_idpev_effects) | 128))
        
set_pev(bot_idpev_solid0)
        
bot_userid get_user_userid(bot_id)
        
set_user_origin(bot_idorigo)
    }

    return 
PLUGIN_CONTINUE
}

public 
mi_bot_disconnect() {

    if (
bot_id) {
        
bot_id 0
        server_cmd
("kick #%d"bot_userid)
    }

    return 
PLUGIN_CONTINUE



GXLZPGX 06-06-2010 13:40

Re: Bot in kz_dajrokan
 
Edit: nevermind

ConnorMcLeod 06-06-2010 13:52

Re: Bot in kz_dajrokan
 
Replace :

PHP Code:

public client_disconnect(id) {

    if (
kz_bot)
        if (
get_playersnum(1) == 2)
            
mi_bot_disconnect()

        return 
PLUGIN_CONTINUE


With :
PHP Code:

public client_disconnect(id)
{
    if (
kz_bot)
    {
        new 
iPlayers[32], iNum
        get_players
(iPlayersiNum"ch")
        
iNum-- // disconnected player is still counted, so decrement iNum
        
if(iNum >= 2)
        {
            
mi_bot_disconnect()
        }
    }


Also, you should set kz_bot to false or 0 in mi_bot_disconnect

SlayeR 06-07-2010 07:33

Re: Bot in kz_dajrokan
 
Thanks.


All times are GMT -4. The time now is 05:24.

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