AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spawning fakeclient crashes server (https://forums.alliedmods.net/showthread.php?t=54444)

hlstriker 04-25-2007 21:34

Spawning fakeclient crashes server
 
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 :P

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; }

teame06 04-25-2007 21:48

Re: Spawning fakeclient crashes server
 
Code:
    engfunc(EngFunc_CreateFakeClient, "BotName");

hlstriker 04-25-2007 21:50

Re: Spawning fakeclient crashes server
 
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.

teame06 04-25-2007 21:54

Re: Spawning fakeclient crashes server
 
http://svn.alliedmods.net/viewvc.cgi...06&view=markup

You can look at OneEyed Round End Blocker too for reference.

hlstriker 04-25-2007 22:38

Re: Spawning fakeclient crashes server
 
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.

teame06 04-26-2007 00:01

Re: Spawning fakeclient crashes server
 
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.

hlstriker 04-26-2007 15:04

Re: Spawning fakeclient crashes server
 
Thanks for the help teame :D

pRED* 04-26-2007 19:07

Re: Spawning fakeclient crashes server
 
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)

regalis 04-27-2007 09:05

Re: Spawning fakeclient crashes server
 
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

pRED* 04-27-2007 18:01

Re: Spawning fakeclient crashes server
 
And that works fine? Guess that's not the cause of the crash problem then.
Thanks


All times are GMT -4. The time now is 06:33.

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