Here's my little plugin (in the part of big plugin) which should control disables on high ping.
My question is -
is it the correct defination of variable which could only be true or false? "
static is_ping_ok=true" - maybe i should use another way? Can someone give me an example?
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
static is_ping_ok=true
public plugin_init() set_task(60.0, "disables_on_high_ping", 142600, _, _, "b")
public disables_on_high_ping()
{
if (GetAveragePing() > 150)
{
is_ping_ok=false;
server_cmd("amxx pause something.amxx");
}
else
{
is_ping_ok=true;
server_cmd("amxx unpause something.amxx");
}
return PLUGIN_HANDLED
}
GetAveragePing()
{
new players[32], n;
get_players(players, n, "ch");
if (!n)
return 0;
new sum;
for (new i, ping, loss; i < n; i++)
{
get_user_ping(players[i], ping, loss);
sum += ping;
}
return sum / n;
}
public client_putinserver()
{
if(is_ping_ok) server_print("ping is OK")
else server_print("ping is BAD")
}