Raised This Month: $ Target: $400
 0% 

Bot disappears some time after creation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AzcariaX
Junior Member
Join Date: Jun 2009
Location: Sweden
Old 05-30-2010 , 14:05   Bot disappears some time after creation
Reply With Quote #1

Hello.

I'm trying to make a bot which spawns when you say /bot. The bot spawns without any problem. Then it starts to follow you as expected. After approximately 7 seconds it suddenly teleports to another location. It teleports between about 5 different locations and its not meant to teleport at all!
I have no idea what i've done wrong, here my code:

Most of this code comes from this plugin: http://forums.alliedmods.net/showthread.php?p=552563

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>

#define PLUGIN "The bot"
#define VERSION "1.0"
#define AUTHOR "El Maco"

new is_bot[33]
new 
owner[33]
new 
MaxPlayers

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /bot""bot_create")
    
    
register_forward(FM_StartFrame"forward_startFrame"1)
    
    
MaxPlayers=get_maxplayers()
}

public 
bot_create(id)
{
    new 
bot engfunc(EngFunc_CreateFakeClient"BOT")
    if (!
bot)
    {
        
server_print("Couldn't create a bot, server full?")
        return 
PLUGIN_HANDLED
    
}

    
engfunc(EngFunc_FreeEntPrivateDatabot)

    
set_user_info(bot"model""gordon")
    
set_user_info(bot"rate""3500")
    
set_user_info(bot"cl_updaterate""30")
    
set_user_info(bot"cl_lw""0")
    
set_user_info(bot"cl_lc""0")
    
set_user_info(bot"tracker""0")
    
set_user_info(bot"cl_dlmax""128")
    
set_user_info(bot"lefthand""1")
    
set_user_info(bot"friends""0")
    
set_user_info(bot"dm""0")
    
set_user_info(bot"ah""1")
    
set_user_info(bot"*bot""1")
    
set_user_info(bot"_cl_autowepswitch""1")
    
set_user_info(bot"_vgui_menu""0")
    
set_user_info(bot"_vgui_menus""0")

    new 
szRejectReason[128]
    
dllfunc(DLLFunc_ClientConnectbot"BOT""127.0.0.1"szRejectReason)
    if (!
is_user_connected(bot))
    {
        
server_print("Connection rejected: %s"szRejectReason)
        return 
PLUGIN_HANDLED
    
}

    
dllfunc(DLLFunc_ClientPutInServerbot);
    
set_pev(botpev_spawnflagspev(botpev_spawnflags) | FL_FAKECLIENT)
    
set_pev(botpev_flagspev(botpev_flags) | FL_FAKECLIENT)
    
set_user_flags(botADMIN_IMMUNITY ADMIN_USER)
    
set_cvar_num("mp_autokick"0)
    
cs_set_user_team(botCS_TEAM_CT)
    
server_print("Bot successfully created! Id: %d, name: BOT"bot)

    
dllfunc(DLLFunc_Spawnbot)

    
is_bot[bot]=1
    owner
[bot]=id

    
return PLUGIN_HANDLED
}

public 
forward_startFrame()
{
    static 
Float:msecvalmsecidFloat:angles[3], buttonsFloat:target_origin[3], Float:bot_origin[3], Float:bot_velocity[3]
    
global_get(glb_frametimemsecval), msec floatround(msecval 1000.0);

    for (
id 1id <= MaxPlayersid++)
    {
        if (
is_bot[id])
        {
            if (
is_user_alive(id))
            {
                
pev(owner[id], pev_origintarget_origin)
                
pev(idpev_originbot_origin)
                
pev(idpev_velocitybot_velocity)
                
                
target_origin[0]-=bot_origin[0]
                
target_origin[1]-=bot_origin[1]
                
target_origin[2]-=bot_origin[2]
                
                
vector_to_angle(target_originangles)
                
                
buttons=0
                
                target_origin
[0]*-1
                target_origin
[1]*-1
                target_origin
[2]=bot_velocity[2]
            
                
set_pev(idpev_velocitytarget_origin)
                
set_pev(idpev_v_angleangles)
                
angles[0] /= -3.0;
                
set_pev(idpev_anglesangles)
                
                
engfunc(EngFunc_RunPlayerMoveidanglesvector_length(bot_velocity), 0.00.0buttons0msec)
            }
        }
    }
    
    return 
FMRES_IGNORED

Please help me.
AzcariaX is offline
infek
Senior Member
Join Date: May 2009
Location: Behind you
Old 05-30-2010 , 14:23   Re: Bot disappears some time after creation
Reply With Quote #2

Set a team for the bot its just like when you revive your self and your not in anyteam you teleport to many places
__________________
"Domo Arigato, Mr. Roboto!"
PM me if you want to know a secret
infek is offline
AzcariaX
Junior Member
Join Date: Jun 2009
Location: Sweden
Old 05-30-2010 , 14:30   Re: Bot disappears some time after creation
Reply With Quote #3

Quote:
Originally Posted by infek View Post
Set a team for the bot its just like when you revive your self and your not in anyteam you teleport to many places
I've no idea what you are talking about. I have set a team for the bot.

EDIT (some hours later...): Ohh, now i understand... But i've already put the bot in a team. Have i done it wrong?

Last edited by AzcariaX; 05-30-2010 at 17:07.
AzcariaX is offline
AzcariaX
Junior Member
Join Date: Jun 2009
Location: Sweden
Old 06-18-2010 , 05:56   Re: Bot disappears some time after creation
Reply With Quote #4

Bump!
AzcariaX 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 05:25.


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