Raised This Month: $ Target: $400
 0% 

Spawning fakeclient crashes server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 04-25-2007 , 21:34   Spawning fakeclient crashes server
Reply With Quote #1

Hi, I am terrible with fakemeta, and have never done anything using fakeclients before. I got this code from another post in the forum and modified it some. I am trying to spawn a fakeclient that will take up a player spot. That model is precached btw

Code:
public createBot(id) {     new Float:origin[3], Float:mina[3], Float:maxa[3];     new ent;         pev(id, pev_origin, origin);     ent = engfunc(EngFunc_CreateFakeClient, engfunc(EngFunc_AllocString, "info_target"));     engfunc(EngFunc_SetOrigin, ent, origin);         origin[2] += 80.0;     engfunc(EngFunc_SetOrigin, id, origin);         set_pev(ent, pev_takedamage, 0.0);     set_pev(ent, pev_classname, "player");         engfunc(EngFunc_SetModel, ent, "models/player/civilian/civilian.mdl");         set_pev(ent, pev_movetype, 4);     set_pev(ent, pev_solid, 2);         mina[0] = -16.0;     mina[1] = -16.0;     mina[2] = -36.0;     maxa[0] = 16.0;     maxa[1] = 16.0;     maxa[2] = 36.0;     engfunc(EngFunc_SetSize, ent, mina, maxa);         set_pev(ent, pev_animtime, 2.0);     set_pev(ent, pev_framerate, 1.0);     set_pev(ent, pev_sequence, 0);         engfunc(EngFunc_DropToFloor, ent);         client_print(0, print_chat, "Bot created.");         return 1; }
hlstriker is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-25-2007 , 21:48   Re: Spawning fakeclient crashes server
Reply With Quote #2

Code:
    engfunc(EngFunc_CreateFakeClient, "BotName");
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 04-25-2007 , 21:50   Re: Spawning fakeclient crashes server
Reply With Quote #3

It still crashes with that, although I found out it doesn't crash if I am not near it (or when I walk through it... which I don't know why I can wak through it).

Seems to crash when I walk through it I guess.

Last edited by hlstriker; 04-25-2007 at 21:56.
hlstriker is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-25-2007 , 21:54   Re: Spawning fakeclient crashes server
Reply With Quote #4

http://svn.alliedmods.net/viewvc.cgi...06&view=markup

You can look at OneEyed Round End Blocker too for reference.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 04-25-2007 , 22:38   Re: Spawning fakeclient crashes server
Reply With Quote #5

I'm using the mod Team Fortress Classic, and I can get the bot to join the game with that method, but I cannot get them to join a team.

I tried using...
client_cmd(botid, "jointeam 1");

jointeam 1 is the command to join the blue team, but this did not work.
hlstriker is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-26-2007 , 00:01   Re: Spawning fakeclient crashes server
Reply With Quote #6

Your going to have to use engclient_cmd(...); From looking at FoxBot source code. It get little complex cause it wait for the bot to think and do other stuff including the joining team and class.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 04-26-2007 , 15:04   Re: Spawning fakeclient crashes server
Reply With Quote #7

Thanks for the help teame
hlstriker is offline
pRED*
Join Date: Dec 2006
Old 04-26-2007 , 19:07   Re: Spawning fakeclient crashes server
Reply With Quote #8

Bit of a thread hijack but..

How do you remove bots created with CreateFakeClient?
RemoveEntity? or server command kick the id from get_user_userid?

My plugin keeps crashing randomly and I think that may be the problem (I'm kicking using the server command)
pRED* is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-27-2007 , 09:05   Re: Spawning fakeclient crashes server
Reply With Quote #9

From Dajrokan's kz_dajrokan.sma:

Code:
public mi_bot_connect() {

    if (!bot_id) {
        bot_id = engfunc(EngFunc_CreateFakeClient, BOT_NAME)
        new ptr[128]
        dllfunc(DLLFunc_ClientConnect, bot_id, BOT_NAME, "127.0.0.1", ptr)
        dllfunc(DLLFunc_ClientPutInServer, bot_id)
        cs_set_user_team(bot_id, CS_TEAM_CT, CS_CT_URBAN)
        dllfunc(DLLFunc_Spawn, bot_id)
        set_pev(bot_id, pev_effects, (pev(bot_id, pev_effects) | 128))
        set_pev(bot_id, pev_solid, 0)
        bot_userid = get_user_userid(bot_id)
        set_user_origin(bot_id, origo)
    }

    return PLUGIN_CONTINUE
}

public mi_bot_disconnect() {

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

    return PLUGIN_CONTINUE
}
Hope that helps!?

greetz regalis
__________________

Last edited by regalis; 04-27-2007 at 20:20. Reason: edited my edits *gg*
regalis is offline
pRED*
Join Date: Dec 2006
Old 04-27-2007 , 18:01   Re: Spawning fakeclient crashes server
Reply With Quote #10

And that works fine? Guess that's not the cause of the crash problem then.
Thanks
pRED* 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 06:33.


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