Raised This Month: $ Target: $400
 0% 

Variable which can only be true || false


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 07-12-2013 , 10:46   Variable which can only be true || false
Reply With Quote #1

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(playersn"ch");
    
    if (!
n)
        return 
0;
    
    new 
sum;
    
    for (new 
ipinglossni++)
    {
        
get_user_ping(players[i], pingloss);
        
sum += ping;
    }
    
    return 
sum n;
}

public 
client_putinserver()
{
    if(
is_ping_okserver_print("ping is OK")
    else 
server_print("ping is BAD")


Last edited by Mofforg; 07-12-2013 at 10:46.
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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