PDA

View Full Version : How to count users(except PODBOT)


senecas
05-02-2008, 06:02
I want to make AUTO BOT Control plugin.

Here is my plan.
if there is no one in my server, server execute "pb removebots"
but if there is more than one people, server execute "pb fillserver"
ex) set_task(1.0, "chueck_count_human", 0, _, _, "b")
because I can save my server resource dynamicaly (with Fakefull plugin).

get_user_num() just count all of users with bot.
How can I count users without bot ? any idea ?

Hunter-Digital
05-02-2008, 06:18
you can make a loop and check if a player is a bot or not with is_user_bot on the userid

new players = 0

for(new p; p <= get_user_num(); p++)
if(!is_user_bot(id))
players++

PS: non-testd code :roll:

Also you can add && is_user_conected(id) to the if() to check if the player is really goin' to connect to the server, so that the bots don't get out for nothing :lol:

Bdw, cool ideea :up:

senecas
05-02-2008, 06:50
#include <amxmodx>
public plugin_init()
{
set_task(1.0, "check_count_human", 0, _, _, "b")
}
public check_count_human()
{
new players = 0
for(new id; id <= get_playersnum(); id++)
if(!is_user_bot(id)) players++
if(players > 0) server_cmd("pb fillserver")
else server_cmd("pb removebots")
}


is this correct ?:|

shine771
05-02-2008, 06:56
why wont you use:
new players[32],num
get_players(players,num,"ch") //C - no bots, H - no hltvthen check:

if(num > 0) server_cmd("pb fillserver")
else server_cmd("pb removebots")

Hunter-Digital
05-02-2008, 07:03
I forgot about that function :lol: :mrgreen:

And one more thing, use the set_task at 10 seconds or something like that, 1 second is a big too quick :)

Exolent[jNr]
05-02-2008, 07:22
I'd rather do it this way:

#include <amxmodx>

new g_iPlayerCount;

public client_putinserver(id)
{
if(!is_user_bot(id) && ++g_iPlayerCount == 1)
{
server_cmd("pb fillserver");
}
}

public client_disconnect(id)
{
if(!is_user_bot(id) && --g_iPlayerCount == 0)
{
server_cmd("pb removebots");
}
}

senecas
05-06-2008, 02:06
Great way !!

Thanks guys. gave +karma to all :)