Add bots after player joins

12 replies [Last post]
[FRAGENSTEIN]
Fragenstein's picture
Offline
Joined: Apr 2011
Posts:

I have "set bot_minplayers "4" in server.cfg. The bots play all the time even when there's no one on the server. Is there a way to have bots join game after a player connects?

easy
Developer
easy's picture
Offline
Joined: Sep 2003
Posts:
Re: Add bots after player joins

You can use the crontab to simulate this.

crontab.txt:

if ( activeClients() ) {
    $bot_minplayers = 4;
}
else {
    $bot_minplayers = 0;
    exec("kick allbots");
}

Note: The crontab gets executed once per minute.

cml
Forum moderator Rank moderator LIVING LEGEND
camel-xp's picture
Offline
Joined: Mar 2006
Posts:
Re: Add bots after player joins
easy wrote:

You can use the crontab to simulate this.

crontab.txt:

if ( activeClients() ) {
    $bot_minplayers = 4;
}
else {
    $bot_minplayers = 0;
    exec("kick allbots");
}

Note: The crontab gets executed once per minute.

is it possible to set own execution time for cron, like some cmd: xp_cronTime "10"
Where the value is interpreted by the seconds, this could let execute it much faster Happy

[FRAGENSTEIN]
Fragenstein's picture
Offline
Joined: Apr 2011
Posts:
Re: Add bots after player joins
easy wrote:

You can use the crontab to simulate this.

crontab.txt:

if ( activeClients() ) {
    $bot_minplayers = 4;
}
else {
    $bot_minplayers = 0;
    exec("kick allbots");
}

Note: The crontab gets executed once per minute.

Thank you. I'll give it a try. Do I change the setting in server.cfg?

[FRAGENSTEIN]
Fragenstein's picture
Offline
Joined: Apr 2011
Posts:
Re: Add bots after player joins

I know this is an old post, but I'm trying to get this to execute every 10 seconds. Here's what I have in crontab...

if ( activeClients() ) {
*/10 * * * * * $bot_minplayers = 4
;}
else { $bot_minplayers = 0;
exec("kick allbots")
;}

It's not working. Any help appreciated.

JIVA
Jiva's picture
Offline
Joined: Jun 2006
Posts:
CZ Czech Republic
Re: Add bots after player joins

command bot_minplayers works with one minute dalay to add next bots i mean

[FRAGENSTEIN]
Fragenstein's picture
Offline
Joined: Apr 2011
Posts:
Re: Add bots after player joins
JIVA wrote:

command bot_minplayers works with one minute dalay to add next bots i mean

That has nothing to do with what I'm asking.

superbad!
Divx's picture
Offline
Joined: Aug 2008
Posts:
GB United Kingdom
Re: Add bots after player joins

sorry for my naive reply here but does it not function at all when the crontab runs? - is that the issue

you're limited by the intervals at which the crontab can run, but when it does run every minute, its not adding bots or its not running that check every 10 seconds.

it looks as if you're trying to find a workaround for seconds rather than minutes- if what cml suggested was an option, then you could do this by specifying the crontab interval rather than utilising crontab to set the interval at which to run the check

i see crontab can be used to run things every few miuntes, but i dont see an option for seconds or at least i cannot decipher this from the documentation:
# Format: Minute Hour Day Month DayOfWeek Expression
#
# values can be
# - an asterisk: *
# - a list: 1,2,3,4
# - a range: 1-4
# - a step: */2
#
# and all sorts of combinations, which internally will be reduced
# from 0,1,2-4,5,6,7/3
# to 0,1,2,3,4,5,6,7/3
# and finally 0,3,6
#
# Month and DayOfWeek can also be abbreviations of their name
# e.g. Jan, Feb, Mar ... or Mon, Tue, Wed ...

and also:
// multi-line comments are not available to prevent unexpected
// behavior with asterisk steps e.g. */2

so if you're setting the script to run on a time interval, whether or not seconds is an option, even if u tried with minutes, surely it would need to be a single line?
and i would have thought the timing would be set at the beggining rather than after the check for active clients

*/10 * * * * * if ( activeClients() ) { $bot_minplayers = 4;} else { $bot_minplayers = 0; exec("kick allbots") ;}
this would need to function from a single line would it not?

Deathadder | Goliathus Speed | Filco Majestouch | i7 3770 | 16GB | GTX 1080 | Xonar Essence ST | Sennheiser HD598

[FRAGENSTEIN]
Fragenstein's picture
Offline
Joined: Apr 2011
Posts:
Re: Add bots after player joins

It works fine running every minute, but does not work
at all tring to use any variation of seconds.
I'm not sure how to implement
by specifying the crontab interval rather than utilising
crontab to set the interval at which to run the check

JIVA
Jiva's picture
Offline
Joined: Jun 2006
Posts:
CZ Czech Republic
Re: Add bots after player joins

congratulations , this what i say about minute interval , i know it

for others

when bot_minplayers command are executed , a one minute delay must wait to add first one bot

if command are executed every less time for example in 10 seconds interval

every new started command bot_minplayers restart delay 1 minute must wait to 0 seconds

start from begin and bot not come to game

my result how to do bot_minplayers to be executable in sooner intervals and realy add bots

is touch code of bot_minplayers command what is C code in quake 3 arena inside

copy that C function extract from source codes vivat radiant and sources

then make different one with choosable delay

this will be add to game as dll or so library similar to programming other things

delay 1 minute is old protect against spam with add bot manipulators

shaprc
Online
Joined: Sep 2010
Posts:
UA Ukraine
Re: Add bots after player joins
[FRAGENSTEIN] wrote:

It works fine running every minute, but does not work
at all tring to use any variation of seconds.
I'm not sure how to implement
by specifying the crontab interval rather than utilising
crontab to set the interval at which to run the check

*/10 means once per 10 minutes.
* means every minute
there's no way to set schedule to anything more frequent than once per minute.