PDA

View Full Version : TestClients



RobsoN
15th October 2013, 15:47
Hello everyone. Can you tell me where is a notify about "begin" (in Callback_PlayerConnect) ? My TestClients Bots can't pass it, but in older mod they could. What's wrong then?

Ni3ls
15th October 2013, 15:54
if you are testing on zombie mod, set autoassign 0

RobsoN
15th October 2013, 16:07
I don't think so autoassign have something to that. I deleted basic functions, and rewrited to my ones with deleting some useless stuff for me, so I could have missed something.

Tally
15th October 2013, 16:24
I don't think so autoassign have something to that. I deleted basic functions, and rewrited to my ones with deleting some useless stuff for me, so I could have missed something.

You know the golden rule - post your script. We can't see if there is a mistake without seeing the code itself.

RobsoN
15th October 2013, 17:15
What do you need ? Here is my Callback_PlayerConnect:
Callback_PlayerConnect()
{
waittillframeend;

if(isdefined(self))
{
level notify("connecting", self);
level thread [[level.functions["onEvent"]]]("onPlayerConnecting", self);
}

// Before Connect
self.statusicon = "hud_status_connecting";
self setClientCvar("download","Copyrights of extreme~Modding Team");
iprintln("Connecting "+self.name);
self waittill("begin");
self.statusicon = "";
iprintln("Connected "+self.name); //cant see this debug
// After Connect
level notify("connected", self);
level thread [[level.functions["onEvent"]]]("onPlayerConnect", self);
[...]


And testclient script:

addTestClients() //called on Callback_StartGameType
{
//level waittill("connected");

wait 1;

if(!level.debug)
return;

for(i = 0; i < level.debug_clients; i++)
{
ent[i] = addTestClient();

if(!isDefined(ent[i]))
continue;

ent[i] thread testClientInit();
}
}
testClientInit()
{
self.pers["team"] = "axis";
self.pers["primary_weapon"] = "knife_mp";
self.data["bot"] = true;
self.statusicon = "";
self thread maps\mp\gametypes\_zom::spawnPlayer();
}

Tally
15th October 2013, 17:48
Try this:


addTestClients() //called on Callback_StartGameType
{
//level waittill("connected");

wait 1;

if(!level.debug)
return;

for(i = 0; i < level.debug_clients; i++)
{
ent[i] = addTestClient();

if(!isDefined(ent[i]))
continue;

ent[i] thread testClientInit( "axis" );
}
}

testClientInit( team )
{
while( !isdefined( self.pers["team"] ) )
wait( 0.05 );

self notify( "menuresponse", game["menu_team"], team );
wait( 0.5 );
self notify( "menuresponse", game["menu_weapon_axis"], "knife_mp" );
}

serthy
15th October 2013, 17:49
What do you need ? Here is my Callback_PlayerConnect:
Callback_PlayerConnect()
{
waittillframeend;
...
}
wouldnt that explain it?
i wouldnt do anything before the begin-notify

Tally
15th October 2013, 17:52
wouldnt that explain it?
i wouldnt do anything before the begin-notify

No, I believe the problem is that the bots aren't given their notifications as they pass through the menus. They notify first for team, then for team weapons. If you don't do them, they wont spawn.

IzNoGoD
15th October 2013, 18:36
CoD2 is really sensitive with waittillframeend; when it comes to spawnplayer() function. Try adding waittillframeend; or just a plain wait .05 before doing anything with your bot (that includes setting the .pers["team"])

RobsoN
15th October 2013, 19:44
Thanks for the quick reply, I tried your ideas, but nothing has changed.

RobsoN
15th October 2013, 19:47
No, I believe the problem is that the bots aren't given their notifications as they pass through the menus. They notify first for team, then for team weapons. If you don't do them, they wont spawn. They are spawning (self thread maps\mp\gametypes\_zom::spawnPlayer(); ) but one weird thing is, they have still connecting status icon, even i changed it to "" ( self.statusicon = ""; ) Btw, scripts wont work correctly on bots, because script are still waiting for connected player... (stuck on self waittill("begin") )

serthy
15th October 2013, 20:00
(stuck on self waittill("begin") )

just use the default callback_playerconnected() procedure (or the slightly modified one below)


Callback_PlayerConnect()
{
self endon( "disconnect" );

self thread notifyConnecting();

self.statusicon = "hud_status_connecting";

self waittill( "begin" );

self.statusicon = "";

waittillframeend;
//...do your callback catching stuff here, AFTER everything went fine
}

notifyConnecting()
{
self endon( "disconnect" );
self endon( "begin" );

waittillframeend;

if( isDefined( self ) )
{
level notify( "connecting" , self );
}
}


add a shitload of debug-iprintln()'s in combination with getTime() to see where it stucks and why

RobsoN
15th October 2013, 20:08
Wow, really respect dude. It's working well now. Thank you so much! :)

guiismiti
16th October 2015, 00:37
What about on map change?

I tried adding test clients using addTestClient() (which, I think, is a stock function). The bot connects, gets to the spectators team, has a 999 ping, no problem there, since I have the rest of the functions to spawn it and make it play the game.
On map change, they just have the connecting status (with -1 ping). I can kick them, but they won't join, and I can't access them (they are not included in the list of players anymore). Can I do something here to access them? I'm thinking about kicking and re-adding them on every map start if there's no better solution.

serthy
16th October 2015, 10:57
Map change is done (in bot-mods without libcod) tis way:

- kick all player, but let them /reconnect automatically after a few seconds (execClientCommand()-hack)
- kill the server (removes the bots)
- retsart the server with your new map
- now the players start to reconnect

you can have a peek on cod2/cod4 bot mods for this
iirc here is likely a thread abut this already

Ni3ls
16th October 2015, 13:23
Or use the kickbot libcod function?

kung foo man
16th October 2015, 13:55
Appending to serthys answer, write logPrint("QUIT"); and let B3 register this and send "quit" via rcon, while the server.sh start script is in an infinite loop.

But I don't know if that is what you want, guiismiti, since two years ago we had same topic (even started by you :D).

http://killtube.org/showthread.php?1259-Tutorial-B3-Simple-and-Easy-Command-Adding!
http://killtube.org/showthread.php?1712-Changing-map-on-MeatBot-%28CoD-2%29

guiismiti
16th October 2015, 15:56
Yea, the kill method worked well.
Without libcod, I had to give a player rcon access to execute the kill.cfg (doesn't look exploitable).
Now I'm thinking about
- writing a file with the number of the name of the bots;
- changing the map without killing;
- kicking the spectator bots.
The advantage is, players won't need to reconnect.

IzNoGoD
16th October 2015, 17:17
Kick bots before you change map so you still know which players are the bots.

guiismiti
16th October 2015, 18:42
I don't know what I missed last time I dealed with bots....

I just used the kick command while they were connected, and they got kicked successfully... I remember having a lot of trouble last time (over a year ago).

kung foo man
17th October 2015, 02:22
You tried this? http://killtube.org/showthread.php?1940-Kicking-bots



entnum = players[i] getentitynumber();
kick(entnum);
free_slot(entnum);

BTW the vbulletin default search is totally useless, I just find this stuff with google ^^

guiismiti
17th October 2015, 02:29
No, and I just noticed that what I did didn't work, and I remembered why.

Yea I saw, but at the moment I am, once again, writing it libcod free. I'm gonna adjust it if at least one of the brazilian providers agree to use it.