Warning: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in ..../includes/class_bbcode.php on line 2958
Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]
V
Home Rules Plug-Ins Forums Donate


 
Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Member
    Join Date
    Jul 2012
    Posts
    5

    Lightbulb Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    Stats.

    This lets you do a bunch of crap, kind of a framework to start building onto it.

    First of all, everything you code should remain open source, give shit back and quit being haters.
    If you do give back -- feel free to use it for corporate means, or donate to TKU.

    Otherwise, prohibit your self from using this.


    ----
    Current Version: 1.0
    Package download: Here shortly.

    Configuration:
    Edit config.php

    Requirements:
    Php 5.3 w/ pdo

    ---
    Code:
    Features:
    Easily write hooks for Tf2's log, this is how our !best, !stats, etc commands have became a reality.
    Create custom commands, such as !loadhacks, or, !bind sweet "i love your sweet ass."  [ more on this shortly. ]
    
    !eventspam - Spams the shit out of chat with alt colors, which you can change easily (editing libs/players.class.php)
    
    !loadhacks - Purely bad, but an example... GIves a random sm_overlay to @player for 30 seconds, or slaps the piss out of them.
    
    !best - Shows whoms bested the map, btw its a good ideal to clone the database and run your events on another one. Just be sure to give your self access.
    
    !stats - Shows your stats, or you can specify a user by doing !stats "<players name>" "<map>"
      
    HappyBdayBanBro *LCG*xxCookiesxx : <neutral_b4> [14/14 deflects] speed of [168.04 MPH] set 8 secs ago.
    <hlx_message_prefix> <user> : <map> [session/all deflects] speed of [best speed] set [time of best deflect]
    !roll [min] [high] OR !roll [high]
    
    !bind <command> <response> [access] [playerActionFunction] 
    
    !session [player] [map] - This will show your stats for that session
    

    Also, it keeps track of ips and players that join. So you can kind of see when events are hooked and used to manipulate or create something, etc.

    Secondly, we have a anti-cheat incorporated within, but the source code for the hooks will NOT be available unless asked for privately. Also, I'm still debating if I want you guys to know how I am catching all of the cheaters... kind of want you to learn on your own.

    Ill post more soon..

    @@@@ Hooks @@@@@
    12:03 PM - bantic - Ӄ: http://pb.websilver.co/79 -- phpar.config.php -- default, you'll need to create a config.php with these defines.
    12:05 PM - bantic - Ӄ: http://pb.websilver.co/80 hooks/playercommands.php - version 1.0
    Code:
    Uses these hooks:
                    $this->ListenForEvent('connected', "PlayerConnected");  // justi ncase 
                    $this->ListenForEvent('connected,', "PlayerConnected"); // sorry, not sure if i removed the comma
                    $this->ListenForEvent('entered', "PlayerEnteredGame"); // when ppl Enter
                    $this->ListenForEvent('disconnected', "PlayerDisconnected"); // when ppl Leave
                    $this->ListenForEvent('joined', "JoinedTeam"); // when Ppl join a Team
    12:07 PM - bantic - Ӄ: http://pb.websilver.co/81 -- hook: player deflects
    12:07 PM - bantic - Ӄ: sry notepad broke
    12:10 PM - bantic - Ӄ: http://pb.websilver.co/82 - last one
    12:10 PM - bantic - Ӄ: ty

    Kind of spammed Voogru, sorry man LOL.
    So these files above will be stock, the following commands are available from saycommands.php

    @@@@ DOWNLOADS @@@@
    Package is being uploaded. here shortly.

    @@@@ Hooks @@@@
    Place these files in hooks/
    Version: 1.0
    Hooks.zip


    Also -- I spoke with Matt, he may be posting his logger for us (which he provided to TKU) -- we'll see where that goes and then the stats will work.


    --- will continue on this in a bit, happy 4th of July dodgers!!!!

  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    5

    Re: Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    -- pause --

  3. #3
    Community Regular
    Join Date
    Aug 2009
    Posts
    175

    Re: Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    I may be not smart enough to understand all of the above, but I am against seeing stuff like that being implemented on Voogru since in my opinion all it does is spam the text chat non stop, makes people wave their e-peen even more than they do already, and adds lag issues.

    The few times I have tried to play either on Voided's DB Hell or on your TKU server recently all I get are rockets and nukes that skip. Issues that I did not have before either of those things were on those servers.

    Just my two cents.

  4. #4
    Member
    Join Date
    Jul 2012
    Posts
    5

    Talking Re: Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    Don't think it's anything lesser then The most recent update and probably your pc.

    Man, this doesnt run on the server. If your familiar with HLStats... We do te same ,?I made it have plugins aka hooks.
    And it's using Php. Off sight.

    Just saying. :$

    Also, it's extremely customizable.
    Only other haters besides laggers has been hackers. What's your pc specs?

  5. #5
    Server Admin
    Join Date
    Dec 2003
    Location
    Cargo Bay
    Posts
    2,889

    Re: Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    Don't spam that server chat with an automated script and it should be fine, otherwise you'll find yourself with a gag. HLStats is a log parser, so if this is just a client-side log parser for your personal benefit, then I'm sure you'll find others appreciating it.

  6. #6
    Community Regular
    Join Date
    Aug 2010
    Location
    Tampa, Florida
    Posts
    854

    Re: Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    welcome to the voogru forums!

  7. #7
    Community Regular
    Join Date
    Aug 2008
    Location
    Ithaca, NY
    Posts
    566

    Re: Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    Wow you just joined today... Congrats??? now.. Clean up that code and read the rules.. Speaking as a lurker only.. Not affiliated with the voogru servers other then occasional drunk play..

  8. #8
    Member
    Join Date
    Jul 2012
    Posts
    5

    Re: Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    07-04-2012, 05:59 PM
    Krytical -V-


    Thanks LOL.



    07-04-2012, 08:57 PM
    travelingthumbs

    Rules????


    HoundDawg

    It's all interchangeable.

    Code:
    <?php
    /**
     * This code is free software; you can redistribute it and/or modify it under
     * the terms of the new BSD License.
     *
     * Copyright (c) 2011-2012, Bryan "Bantic" Breatoz
     *
     * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
     *
     **/
    
    /**
     * This class represents an IP socket
     *
     * It can connect to a remote host, send and receive packets
     *
     * @author  Bryan "Bantic"
     * @package my-lifes-story
     */
    abstract class MESSAGE_COLOR {
    	public $string = "--11";
    	function __construct($string){
    		if(is_array($string)){}
    		$this->string = $string;
    	}
    
    	function __toString(){
    		return (string) $this->string;
    	}
    };
    class MESSAGE_COLOR_STANDARD extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_CMD extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_CVAR_ON extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_CVAR_OFF extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_PLAYER_RED extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_PLAYER_BLUE extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_OBJ_USER extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_STRING extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_INTERGER extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_OBJ extends MESSAGE_COLOR{};
    class MESSAGE_COLOR_RANDOM extends MESSAGE_COLOR{};
    function printr2($obj)
    {
    	if (gettype($obj) == 'object' && get_class($obj) != 'Player')
    	{
    		echo "Skipping OBJECT: ".get_class($obj)."\n";
    	}
    	elseif (gettype($obj) == 'object')
    	{
    		$vars = get_object_vars($obj);
    		foreach ($vars as $var)
    		{
    			printr2($var);
    		}
    	}
    	elseif (gettype($obj) == 'array') {
    
    		foreach ($obj as $x)
    		{
    			printr2($x);
    		}
    	}
    	else
    	{
    		echo gettype($obj) . " : ".$obj."\n";
    	}
    }
    
    class PlayerActions
    {
    	const PM_MESSAGE_RCON = 'rcon say "%s"';
    	const PM_MESSAGE_CSAY = 'hlx_sm_csay "%s"'; // Usage: hlx_sm_csay <message> - display center message
    	const PM_MESSAGE_MSAY = 'hlx_sm_msay "%time" "%uid" "%s"'; // Usage: hlx_sm_msay <time><userid><message> - sends hud message
    	const PM_MESSAGE_TSAY = 'hlx_sm_tsay "%time" "%uid" "%s"'; // Usage: hlx_sm_tsay <time><userid><message> - sends hud message
    	const PM_MESSAGE_PSAY = 'hlx_sm_psay "%uid" "%color" "%s"'; // Usage: hlx_sm_psay <userid><colored><message> - sends private message
    	const PM_MESSAGE_PSAY2 = 'hlx_sm_psay2 "%uid" "%color" "%s"';// Usage: hlx_sm_psay2 <userid><colored><message> - sends green colored private message
    	const PM_MESSAGE_BULKPSAY = 'hlx_sm_bulkpsay "%color" "%s"';
    	const PM_MESSAGE_HINT = 'hlx_sm_hint "%uid" "%s"'; // Usage: hlx_sm_hint <userid><message> - send hint message
    
    	const MESSAGE_COLOR_STANDARD_DARK = "\x071e1f1f"; // dark
    	const MESSAGE_COLOR_STANDARD = "\x01"; // light
    
    	const MESSAGE_COLOR_CMD = "\x071BE0CC";
    	const MESSAGE_COLOR_CVAR_ON = "\x0709a124";
    	const MESSAGE_COLOR_CVAR_OFF = "\x07c71f27";
    	//red			//blue
    	const MESSAGE_COLOR_PLAYER_RED = "\x07e8262c";
    	const MESSAGE_COLOR_PLAYER_BLUE = "\x079acdff";
    	const MESSAGE_COLOR_OBJ_USER = "\x07B7FF00";
    
    	//other vars
    	const MESSAGE_COLOR_STRING = "\x07EB0056";
    //	const MESSAGE_COLOR_STRING = "\x0763dbfe";
    	const MESSAGE_COLOR_INTERGER = "\x07FFBF00";
    	const MESSAGE_COLOR_OBJ = "\x07B7FF00";
    	const MESSAGE_COLOR_RANDOM = "\x07B7FF00";
    
    	static $instance = array();
    
    	public $targets = array();
    	public $msg = '';
    	public $type = '';
    	public $time = 5;
    	public $color = '0';
    	public $playersdb;
    	public $players;
    	public $player;
    	public $server;
    
    	public function getPlayerActionObject(Player $player, SourceMonitor $server)
    	{
    		if (!isset($player->uid) || !$player->uid)
    		{
    			print "Player doesn't have uid: ".$player->uid." \n";
    			return false;
    		}
    
    		if (isset(self::$instance[$player->uid]))
    		return self::$instance[$player->uid];
    
    		self::$instance[$player->uid] = new PlayerActions();
    		self::$instance[$player->uid]->player = $player;
    		self::$instance[$player->uid]->playersdb = PlayersDB::getInstance();
    		self::$instance[$player->uid]->server = $server;
    
    		return self::$instance[$player->uid];
    	}
    
    	public function clear()
    	{
    		$this->targets = array();
    	}
    	public function to(Player $player, $clearold = false)
    	{
    		$target_ids = array();
    		if ($clearold) $this->targets = array();
    		if (is_object($player) && $player->uid) $target_ids[] = $player->uid;
    		elseif (is_object($player) && $player->unique_id) $target_ids[] = $player->unique_id;
    		elseif (is_array($player) && isset($player['unique_id'])) $target_ids[] = $player['unique_id'];
    		elseif (is_array($player) && isset($player['uid'])) $target_ids[] = $player['uid'];
    		elseif (is_int($player)) $target_ids[] = $player;
    
    		if (count($target_ids))
    		{
    			$this->targets = $target_ids;
    			return $target_ids;
    		}
    
    		if (is_array($player) && isset($player['uid']))
    		{
    			$this->targets[] = PlayersDB::uidToPlayer($player['uid']);
    		}
    		elseif (!is_object($player))
    		$this->targets[] = PlayersDB::uidToPlayer($player);
    
    		else
    		$this->targets[] = $player;
    
    		if ($clearold == true) $this->targets = array();
    
    	}
    	public function PM()
    	{
    		return call_user_method_array('Send', $this, func_get_args());
    	}
    	public function Send($message, $msg_type, $time, $color, $players = null)
    	{
    		//		list($target, $msg_type, $time, $color) = func_get_args();
    
    		$this->msg = $message;
    		$this->type = $msg_type;
    		$this->time = $time;
    		$this->color = $color;
    		if (isset($players) && is_object($players))
    		{
    			if (is_a($players, 'Player'))
    			$this->to($players,true);
    		}
    		elseif (isset($players) && is_array($players))
    		{
    			$this->clear();
    			foreach ($players as $p)
    			$this->to($p);
    		}
    		elseif (is_a($this->player,"Player") && !count($this->targets))
    		{
    			echo "Target count: ".count($this->targets)." Player: ".$this->player->name;
    
    			$this->targets = array($this->player->uid);
    		}
    
    		$target_ids = array();
    		if (!count($this->targets))
    		{
    			echo "there are no targets";
    			return false;
    		}
    		foreach ($this->targets as $target)
    		{
    			if (is_object($target) && $target->uid) $target_ids[] = $target->uid;
    			elseif (is_object($target) && $target->unique_id) $target_ids[] = $target->unique_id;
    			elseif (is_array($target) && isset($target['unique_id'])) $target_ids[] = $target['unique_id'];
    			elseif (is_array($target) && isset($target['uid'])) $target_ids[] = $target['uid'];
    			elseif (ctype_digit($target)) $target_ids[] = $target;
    			//			else { echo "unknown target type ".var_export($target,true).""; continue; }
    		}
    		if (!count($target_ids) && strstr('%uid', $this->type))
    		echo "Msg: No targets to deliever to. ".$target->uid." ".get_class($target)." printr:".printr2($target_ids,true);
    
    		$message = str_ireplace(array('%time','%uid','%color'), array($this->time, join(',', $target_ids), $this->color), $this->type);
    		$msg = sprintf($message, $this->msg);
    
    		echo "Sending: $message - $this->msg\n";
    
    		$this->player->server->rcon($message, false, $this->msg);
    	}
    
    	/// stop
    
    
    	function init($caller)
    	{
    		$this->server = $caller->server;
    	}
    	function sprintfm_color()
    	{
    		$args = func_get_args();
    		$colors = array('standard' => self::MESSAGE_COLOR_STANDARD, 'userobj', self::MESSAGE_COLOR_OBJ_USER, 'unknown'=> self::MESSAGE_COLOR_RANDOM, 'red' => self::MESSAGE_COLOR_PLAYER_RED, 'blue' => self::MESSAGE_COLOR_PLAYER_BLUE, 'string' => self::MESSAGE_COLOR_STRING, 'interger' => self::MESSAGE_COLOR_INTERGER);
    		error_reporting(E_ALL);
    		$new_args = array();
    
    		foreach ($args as $i => $arg)
    		{
    			if ($i === 0) $new_args[$i] = $colors['standard'] . $arg;
    			else
    			{
    
    				if (is_object($arg) && is_a($arg, 'player'))
    				{
    					$new_args[$i] = (strtolower($arg->team) == 'red' ? self::MESSAGE_COLOR_PLAYER_RED : (strtolower($arg->team) == 'blue' ? self::MESSAGE_COLOR_PLAYER_BLUE : self::MESSAGE_COLOR_OBJ_USER)) . trim($arg->name) . $colors['standard'];
    				}
    				elseif (is_object($arg) && is_a($arg, 'User'))
    				{
    					//Try to get there player object by user object and switch this to a player instead.
    					if ($arg->uid && ($ptmp=$this->playersdb->uidToPlayer($arg->uid)))
    					{
    						if ($ptmp->steamid64 != $arg->steamid64) // player found
    						{
    							$new_args[$i] = self::MESSAGE_COLOR_OBJ_USER . isset($arg->playername)?$arg->playername:trim($arg->display_name,' ') .$colors['standard'];
    							continue;
    						}
    						elseif (is_object($ptmp) && is_a($ptmp, 'player'))
    						{
    							$new_args[$i] = (strtolower($ptmp->team) == 'red' ? self::MESSAGE_COLOR_PLAYER_RED : (strtolower($ptmp->team) == 'blue' ? self::MESSAGE_COLOR_PLAYER_BLUE : self::MESSAGE_COLOR_OBJ_USER)) . trim($ptmp->name) . $colors['standard'];
    							continue;
    						}
    					}
    					$new_args[$i] = self::MESSAGE_COLOR_OBJ_USER . isset($arg->playername)?$arg->playername:trim($arg->display_name,' ') .$colors['standard'];
    				}
    				elseif (is_object($arg) && is_a($arg, 'usermap')) $new_args[$i] = self::MESSAGE_COLOR_RANDOM . trim($arg->display_name,' ') . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_STANDARD')) $new_args[$i] = self::MESSAGE_COLOR_STANDARD . ((string) $arg) . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_CMD')) $new_args[$i] = self::MESSAGE_COLOR_CMD . ((string) $arg) . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_CVAR_ON')) $new_args[$i] = self::MESSAGE_COLOR_CVAR_ON . ((string) $arg)  . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_CVAR_OFF')) $new_args[$i] = self::MESSAGE_COLOR_CVAR_OFF . ((string) $arg)  . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_OBJ_USER')) $new_args[$i] = self::MESSAGE_COLOR_OBJ_USER . ((string) $arg)  . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_RANDOM')) $new_args[$i] = self::MESSAGE_COLOR_RANDOM . ((string) $arg)  . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_PLAYER_RED')) $new_args[$i] = self::MESSAGE_COLOR_PLAYER_RED . ((string) $arg)  . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_PLAYER_BLUE')) $new_args[$i] = self::MESSAGE_COLOR_PLAYER_BLUE . ((string) $arg) . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_STRING')) $new_args[$i] = self::MESSAGE_COLOR_STRING . ((string) $arg) . $colors['standard'];
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_INTERGER')) $new_args[$i] = self::MESSAGE_COLOR_INTERGER . ((string) $arg) . $colors['standard'];
    				elseif (is_object($arg) && isset($new_args->display_name)) $new_args[$i] = self::MESSAGE_COLOR_OBJ . $arg->display_name . $colors['standard'];
    				elseif (is_integer($arg) || ctype_digit($arg)) $new_args[$i] = self::MESSAGE_COLOR_INTERGER . $arg . $colors['standard'];
    				elseif (is_string($arg) || ctype_alnum($arg)) $new_args[$i] = self::MESSAGE_COLOR_STRING . $arg . $colors['standard'];
    				else $new_args[$i] = self::MESSAGE_COLOR_RANDOM . $arg . $colors['standard'];
    			}
    		}
    
    		$msg=call_user_func_array('sprintf', $new_args);
    		return $msg;
    	}
    	
    	function sayparser()
    	{
    		$args = func_get_args();
    //		print_r($args);
    		$this->msay_all('%s', $args);
    	}
    	//!bind brett "STEAM_0:0:8772506" 0 msay_all_statsBySteamIDB
    	function msay_all_statsBySteamIDB($steamid)
    	{
    		$args = func_get_args();
    		//		$colors = array('standard' => self::MESSAGE_COLOR_STANDARD, 'userobj', self::MESSAGE_COLOR_OBJ_USER, 'unknown'=> self::MESSAGE_COLOR_RANDOM, 'red' => self::MESSAGE_COLOR_PLAYER_RED, 'blue' => self::MESSAGE_COLOR_PLAYER_BLUE, 'string' => self::MESSAGE_COLOR_STRING, 'interger' => self::MESSAGE_COLOR_INTERGER);
    		$new_args = array();
    		
    		$message = array('get top three maps.',);	
    		$msg = call_user_func_array(array($this,'sprintfm_color'), func_get_args());
    		$this->to($this->player, true);
    		$this->Send($msg, PlayerActions::PM_MESSAGE_PSAY, 15, "1");
    		$this->clear();
    		
    	}
    	function sprintfm2()
    	{
    		$args = func_get_args();
    		//		$colors = array('standard' => self::MESSAGE_COLOR_STANDARD, 'userobj', self::MESSAGE_COLOR_OBJ_USER, 'unknown'=> self::MESSAGE_COLOR_RANDOM, 'red' => self::MESSAGE_COLOR_PLAYER_RED, 'blue' => self::MESSAGE_COLOR_PLAYER_BLUE, 'string' => self::MESSAGE_COLOR_STRING, 'interger' => self::MESSAGE_COLOR_INTERGER);
    		$new_args = array();
    
    		foreach ($args as $i => $arg)
    		{
    			if ($i === 0) $new_args[$i] = $arg;
    			else
    			{
    				if (is_object($arg) && is_a($arg, 'player')) $new_args[$i] = trim($arg->name);
    				elseif (is_object($arg) && is_a($arg, 'User')) $new_args[$i] = isset($arg->playername)?$arg->playername:trim($arg->display_name,' ');
    				elseif (is_object($arg) && is_a($arg, 'usermap')) $new_args[$i] = trim($arg->display_name,' ');
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_STANDARD')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_CMD')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_CVAR_ON')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_CVAR_OFF')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_OBJ_USER')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_RANDOM')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_PLAYER_RED')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_PLAYER_BLUE')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_STRING')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && is_a($arg, 'MESSAGE_COLOR_INTERGER')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && method_exists($new_args,'__toString')) $new_args[$i] = ((string) $arg);
    				elseif (is_object($arg) && isset($new_args->display_name)) $new_args[$i] = $arg->display_name;
    				elseif (is_object($arg) && isset($new_args->name)) $new_args[$i] = $arg->name;
    				elseif (is_integer($arg) || ctype_digit($arg)) $new_args[$i] = $arg;
    				elseif (is_string($arg) || ctype_alnum($arg)) $new_args[$i] = $arg;
    				else $new_args[$i] = $arg;
    			}
    		}
    
    		$msg=call_user_func_array('sprintf', $new_args);
    		return $msg;
    	}
    	function sprintfm()
    	{
    		$msg=call_user_func_array('sprintf', func_get_args());
    		return $msg;
    	}
    	function color_privmsg($msg, $args)
    	{
    		$msg = call_user_func_array(array($this,'sprintfm_color'), func_get_args());
    		$this->to($this->player, true);
    		$this->Send($msg, PlayerActions::PM_MESSAGE_PSAY, 15, "1");
    		$this->clear();
    	}
    	function privmsg($msg, $args)
    	{
    
    		//sprintf message and args.
    		$msg = call_user_func_array(array($this,'sprintfm_color'), func_get_args());
    		$this->to($this->player, true);
    		$this->Send($msg, PlayerActions::PM_MESSAGE_PSAY, 15, '1');
    		$this->clear();
    	}
    	function psay($msg,$args)
    	{
    		//sprintf message and args.
    		$msg = call_user_func_array(array($this,'sprintfm_color'), func_get_args());
    		$this->to($this->player, true);
    
    		$this->Send($msg,PlayerActions::PM_MESSAGE_PSAY, 15, '1');
    		$this->clear();
    	}
    	function psay_all($msg)
    	{
    		//sprintf message and args.
    		$msg = call_user_func_array(array($this,'sprintfm_color'), func_get_args());
    		$this->targets = $this->players->players;
    
    		$this->Send($msg,PlayerActions::PM_MESSAGE_PSAY, 15, '1');
    		$this->clear();
    
    	}
    
    	function hint($msg, $args = null)
    	{
    		if (func_num_args() >= 2)
    		$msg = call_user_func_array(array($this,'sprintfm2'), func_get_args());
    
    		if (!is_object($this->player))
    		{
    			trigger_error("player is not an object. quitting.", E_NOTICE);
    			return false;
    		}
    
    		$this->to($this->player, true);
    		$this->Send($msg, PlayerActions::PM_MESSAGE_HINT,  5, "1");
    		$this->clear();
    	}
    	function msay($msg, $args = null)
    	{
    		//sprintf message and args.
    		if (isset($args) && $args!=null)
    		$msg = call_user_func_array(array($this,'sprintfm2'), func_get_args());
    
    		$this->targets = array($this->player);
    
    		$this->Send($msg, PlayerActions::PM_MESSAGE_MSAY, 25, "1");
    		$this->clear();
    	}
    	function msay_all($msg, $args = false)
    	{
    		if ($args)
    		$msg = call_user_func_array(array($this,'sprintfm2'), func_get_args());
    
    		$this->targets = $this->players->players;
    
    		$this->Send($msg, PlayerActions::PM_MESSAGE_MSAY, 20, "1");
    		$this->clear();
    	}
    	
    	function csay($msg, $args = false)
    	{
    		if ($args)
    		$msg = call_user_func_array(array($this,'sprintfm2'), func_get_args());
    
    		$this->targets = $this->players->players;
    
    		$this->Send($msg, PlayerActions::PM_MESSAGE_CSAY, 20, "1");
    		$this->clear();
    	}
    }
    
    
    class PlayersDB {
    	static $instance;
    	public $data = array();
    	public $players = array();
    	public $steamids = array();
    
    	public $server = false;
    	public $console = false;
    
    	protected function __construct() {}
    
    	public static function getInstance()
    	{
    		if(!self::$instance) {
    			self::$instance = new self();
    		}
    		////		self::$instance->server
    		//		self::$instance->players = PlayersDB::getInstance();
    		//
    		return self::$instance;
    	}
    
    	function Steam64toPlayer($steamid64)
    	{
    		//create the player
    		if (strtolower(substr($steamid64,0,6)) == 'steam_') $steamid64 = PlayersDB::steamID64($steamid64);
    
    
    		if (isset($this->steamids[$steamid64]) && isset($this->players[$this->steamids[$steamid64]]) && is_a($this->players[$this->steamids[$steamid64]], 'Player'))
    		{
    			$player = $this->players[$this->steamids[$steamid64]];
    			if ($player->steamid64 === $steamid64) return $player;
    			unset($this->steamids[$steamid64]);
    		}
    		return false;
    	}
    	function Steam64toUser($steamid64)
    	{
    		//create the player
    		if (strtolower(substr($steamid64,0,6)) == 'steam_') $steamid64 = PlayersDB::steamID64($steamid64);
    
    
    		$player = $this->Steam64toPlayer($steamid64);
    		if ($player)
    		return $this->players[$this->steamids[$steamid64]]->user;
    
    		$user = user::find_by_steamid64($steamid64);
    		if ($user) return $user;
    
    		return false;
    	}
    
    	function getUserObject($name, $steamid, $uid)
    	{
    		//create the player
    		if (strtolower(substr($steamid,0,6)) == 'steam_') $steamid64 = self::steamID64($steamid);
    		else $steamid64 = $steamid;
    
    		$user = $this->Steam64toUser($steamid64);
    		if (!$user)
    		{
    			echo "Creating User: $name - steam: $steamid UID: $uid\n\t";
    			$user = new user(array('display_name' => $name,'playername' => $name, 'steamid64' => $steamid64, 'uid' => $uid));
    			$user->save();
    		}
    		else
    		{
    			if ($user->uid != $uid)
    			{
    				$user->uid = $uid;$yes=1;
    			}
    			if ($user->playername != $name)
    			{
    				$user->playername = $name;$yes=1;
    			}
    			if (isset($yes)) $user->save();
    		}
    		return $user;
    	}
    
    	public function create_player($name, $steamid, $uid, $additional_data = array())
    	{
    		//		if (!$uid) exit ('no uid specified');
    		//		if (!$uid && isset($additional_data['user_id'])) $uid = $additional_data['user_id'];
    		$additional_data['uid'] = $uid;
    
    		if (!isset($this) || !is_object($this))
    		{
    			$obj = self::getInstance();
    			return  call_user_method_array(__FUNCTION__, $obj, func_get_args());
    		}
    		if (isset($this->players[$uid]))
    		return $this->players[$uid];
    
    		echo "Creating Player: $name - steam: $steamid UID: $uid\n\t";
    		if (strtolower(substr($steamid,0,6)) == 'steam_') $steamid64 = self::steamID64($steamid);
    		else $steamid64 = $steamid;
    
    
    		//		$user = $this->GetUserObject($name, $steamid64, $uid);
    		//		$user_id = $user->id;
    		if (!isset($this->players[$uid]) || !is_object($this->players[$uid]))
    		{
    			if ($player = $this->Steam64toPlayer($steamid))
    			{
    				//player was once here, but he died? idk.. we still have his records though.
    				echo "Found user by steamid during PlayersDB::create_player";
    				return $player;
    			}
    			$player = Player::create_player($name, $steamid, $uid, $this, $this->server, $this->getUserObject($name,$steamid64,$uid), $additional_data);
    
    			$this->players[$uid] = $player;
    			$this->steamids[$steamid64] = $uid;
    		}
    		else
    		{
    			$player = $this->players[$uid];
    			$this->players[$player->uid] = $player;
    		}
    
    		return $this->players[$player->uid];
    	}
    
    	function GetArrayToPlayer($array)
    	{
    		$uid = intval($array['uid']);
    
    		//		return $this->getBySteamID($array['name'], $array['steamid'], $uid);
    
    		return call_user_func_array(array(PlayersDB::getInstance(),'create_player'), array($array['name'], $array['steamid'], $array['uid'], $array) );
    	}
    
    
    	public function uidToPlayer($uid)
    	{
    		if (!isset($this) || !is_object($this))
    		{
    			$obj = self::getInstance();
    			return  call_user_method_array(__FUNCTION__, $obj, func_get_args());
    		}
    		if (is_object($uid) && is_a($uid, 'Player')) return $uid;
    		if (isset($this->players[$uid]) && is_a($this->players[$uid], 'Player')) return $this->players[$uid];
    
    		if (ctype_digit($uid) && strlen($uid) > 10) //steamid64
    		return $this->Steam64toPlayer($uid);
    		elseif (ctype_digit($uid) && isset($this->players[$uid]) && is_a($this->players[$uid], 'Player')) return $this->players[$uid];
    		else
    
    		return false;
    	}
    
    	function LogStrToPlayer($playerStr)
    	{
    		if (is_string($playerStr)) $playerStr = $this->extractPlayerInfo($playerStr);
    
    		if (is_array($playerStr))
    		{
    			if (isset($playerStr['uid']))
    			$player = $this->uidToPlayer($playerStr['uid']);
    			elseif (isset($playersStr['steamid']))
    			$player = $this->Steam64toPlayer($playersStr['steamid']);
    
    			if (is_object($player)) return $player;
    
    			return $this->GetArrayToPlayer($playerStr);
    		}
    
    	}
    
    	function GetStrToPlayer($playerStr)
    	{
    		if (!isset($this) || !is_object($this))
    		{
    			$obj = self::getInstance();
    			return  call_user_method_array(__FUNCTION__, $obj, func_get_args());
    		}
    		if (is_array($playerStr)) return $this->GetArrayToPlayer($playerStr);
    
    		$pregmatch = '/^\#\s*(\d+)\s+(?:\d+\s+|)"(.+)"\s+(.+)\s+([\d:]+)\s+(\d+)\s+(\d+)\s+([A-Za-z]+)\s+(?:\d+\s+|)([^:]+):(\S+)/x';
    		preg_match($pregmatch, $playerStr, $matched);
    
    		if (count($matched) == 10)
    		{
    			list(,$uid, $name, $steamid, $time, $ping, $loss, $state, $addr, $port) = $matched;
    			$extract = array('name' => $name, 'uid' => $uid, 'steamid' => $steamid, 'time' => $time, 'ping' => $ping, 'state' => $state, 'addr' => $addr, 'port' => $port);
    			return $this->create_player($name, $steamid, $uid, $extract);
    
    			return $this->GetArrayToPlayer($extract, true);
    		}
    		else
    		{
    			$extract = $this->extractPlayerInfo($playerStr);
    			if (is_array($extract))
    			return $this->create_player($extract['name'], $extract['steamid'], $extract['uid'], $extract);
    		}
    
    		return null;
    	}
    
    	function StrToArray($playerStr)
    	{
    		if (!isset($this) || !is_object($this))
    		{
    			$obj = self::getInstance();
    			return  call_user_method_array(__FUNCTION__, $obj, func_get_args());
    		}
    
    		$pregmatch = '/^\#\s*(\d+)\s+(?:\d+\s+|)"(.+)"\s+(.+)\s+([\d:]+)\s+(\d+)\s+(\d+)\s+([A-Za-z]+)\s+(?:\d+\s+|)([^:]+):(\S+)/x';
    		preg_match($pregmatch, $playerStr, $matched);
    		if (count($matched) == 10)
    		{
    			list(,$uid, $name, $steamid, $time, $ping, $loss, $state, $addr, $port) = $matched;
    			$extract = array('name' => $name, 'unique_id' => $uid, 'uid' => $uid, 'steamid' => $steamid, 'time' => $time, 'ping' => $ping, 'state' => $state, 'addr' => $addr, 'port' => $port);
    			return $extract;
    
    			return $this->GetArrayToPlayer($extract, true);
    		}
    		else
    		{
    			$extract = $this->extractPlayerInfo($playerStr);
    			if (is_array($extract))
    			return $extract;
    			//return $this->create_player($extract['name'], $extract['steamid'], $extract['unique_id'], $extract);
    		}
    
    		return null;
    	}
    
    	function get_str_wstop($str, $start_pos, $stop_chr, $reverse = false)
    	{
    		if ($reverse == true) $str = strrev($str);
    
    		$str_len = strlen($str);
    		$str_hold = "";
    
    		for ($i=$start_pos;$i<=$str_len;$i++)
    		{
    			$curr_char = trim(substr($str,$i,1));
    
    			if (ord($curr_char) == $stop_chr)
    			break;
    			$str_hold .= $curr_char;
    		}
    
    		if ($reverse == true) $str_hold = strrev($str_hold);
    		return array($str_hold, $i);
    	}
    
    	function extractPlayerInfo($log)
    	{
    		list($team, $position) = self::get_str_wstop($log, 1, ord('<'), 1);
    		list($steamid, $position) = self::get_str_wstop($log, $position+2, ord('<'), 1);
    		list($userid, $position) = self::get_str_wstop($log, $position+2, ord('<'), 1);
    		$playername = strrev(substr(strrev($log), $position+1));
    
    		return array('name' => $playername, 'unique_id' => $userid, 'uid' => $userid, 'steamid' => $steamid, 'team' => $team);
    	}
    
    	/**
    	 * Removes all associated data anywhere about this player.
    	 *
    	 * @param Player $player
    	 * @todo Update the user postmatically ( e.g re-create the userobject before making any changes.)
    	 */
    	function PlayerQuit(Player $player)
    	{
    		if (!isset($this) || !is_object($this))
    		{
    			$obj = self::getInstance();
    			return  call_user_method_array(__FUNCTION__, $obj, func_get_args());
    		}
    
    		if (is_object($player))
    		{
    			$steamid64 = $player->steamid64;
    			$uid = $player->uid;
    			$name = $player->name;
    			$user_id = $player->user->id;
    
    			$player->user->uid = 0;$player->user->save();
    
    			unset($this->server->players[$player->uid], $this->players[$uid], $this->server->console->players[$player->uid]);
    		}
    
    		//$player->quit();
    
    	}
    
    	public function steamID64($steamId)
    	{
    
    		//Example SteamID: "STEAM_X:Y:ZZZZZZZZ"
    		$gameType = 0; //This is X.  It's either 0 or 1 depending on which game you are playing (CSS, L4D, TF2, etc)
    		$authServer = 0; //This is Y.  Some people have a 0, some people have a 1
    		$clientId = ''; //This is ZZZZZZZZ.
    
    		//Remove the "STEAM_"
    		$steamId = str_ireplace('STEAM_', '' ,$steamId);
    
    		//Split steamId into parts
    		$parts = explode(':', $steamId);
    		$gameType = $parts[0];
    		$authServer = $parts[1];
    		$clientId = $parts[2];
    
    		//Calculate friendId
    		$result = bcadd((bcadd('76561197960265728', $authServer)), (bcmul($clientId, '2')));
    
    		return $result;
    	}
    
    }
    class Player {
    	public $storage = array();
    	public $vars = array();
    
    	public $server = false;
    	public $playersdb; // Object of the PlayersDB
    	public $console = false;
    
    	public $pData = array();
    	//
    	//	public $name;
    	public $steamid;
    	public $steamid64;
    	public $uid;
    	public $user_id;
    	//	public $userid; // uniqueid
    	//	public $ipaddr; //
    	public $user = false; // there User object
    	public $level = 0; // this returns alias of $this->user->level.
    	public $Actions = false;
    
    	function create_player($name,$steamid,$uid, PlayersDB $playerdb, SourceMonitor $server, User $user, $settings = array())
    	{
    		//		echo "CREATE_PLAYER: Name: ", $name, "SteamID: ",$steamid," UID:", $uid, "User->id: ", $user->id, "User->display_name", $user->display_name."\n";
    		$player = new Player();
    
    		$steamid64 = PlayersDB::steamID64($steamid);
    		$player->name = $name;
    		$player->user_id = $user->id;
    		$player->playersdb = $playerdb;
    		$player->server = $server;
    		$player->user = $user;
    		$player->level =& $user->level;
    
    		
    //		if (!$player->user->id) die("No user id specified: ".print_r($user->to_array(),1));
    		$player->name = $name;
    		$player->steamid =$steamid;
    		$player->steamid64 =$steamid64;
    		$player->uid = $uid;
    		$player->user_id = $player->user->id;
    		if (isset($settings['team']))
    		$player->team = $settings['team'];
    
    		$player->vars = $settings;
    		$player->Actions = PlayerActions::getPlayerActionObject($player, $server);
    		$player->Actions->player = $player;
    		$player->Actions->players = $playerdb;
    
    		$player->playersdb->players[$player->uid] = $player;
    		$player->playersdb->steamids[$player->steamid64] = $player->steamid64;
    		$player->playersdb->server->players[$player->uid] = $player;
    
    		return $player;
    		//$this->Players->add_player($this);
    	}
    	function createplayer2($name,$steamid,$uid, SourceMonitor $server, $settings = array())
    	{
    		if (isset($this->server->playerlist[$uid])) return $this->server->playerlist[$uid];
    		$steamid64 = PlayersDB::steamID64($steamid);
    	}
    	function GetPlayers()
    	{
    		if (is_object($this->playersdb))
    		return $this->playersdb;
    		$this->playersdb = PlayersDB::getInstance();
    
    		return $this->playersdb;
    	}
    	function GetUser(){
    		if (!$this->user || !is_object($this->user))
    		$this->user = $this->GetPlayers()->getUserByPlayer($this);
    
    	}
    	function setplayerinfo($vars)
    	{
    		foreach ($vars as $var => $val)
    		{
    			$this->$var = $val;
    		}
    	}
    
    	/**
    	 * Returns the players name when the object is referenced as a string
    	 *
    	 * @return string Player_Name
    //	 */
    	function __toString(){
    		//		if ($this->player->vars['team'] == 'red') $return = PlayerActions::MESSAGE_COLOR_PLAYER_RED;
    		//		elseif ($this->player->vars['team'] == 'blue') $return = PlayerActions::MESSAGE_COLOR_PLAYER_BLUE;
    		//		else
    		return (string) $this->name;
    	}
    
    	/**
    	 * Marks a player has quit the game
    	 *
    	 */
    	public function PlayerQuit()
    	{
    		$this->playersdb->PlayerQuit($this);
    		return false;
    	}
    	/**
    	 * Get the connect message
    	 *
    	 */
    	public function getConnectMessage()
    	{
    		$connectMsg = $this->user_setting('join_message');
    
    	}
    
    	public function user_setting($setting, $value = null)
    	{
    		return false;
    	}
    }

  9. #9
    Server Admin
    Join Date
    Dec 2003
    Location
    Cargo Bay
    Posts
    2,889

    Re: Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    I'm just warning anyone looking to use this, that spamming the server chat will earn you a gag. So, you'd be best to disable the chat features while on the voogru servers (and I imagine many other servers wouldn't care to see this either).

  10. #10
    Member
    Join Date
    Apr 2010
    Location
    The Netherlands
    Posts
    327

    Re: Stats for Voogru's dodgeball -- [php/pdo/namespaces/phpar]

    and what is exactly wrong with having hlx:ce ? (http://www.hlxce.com/) ??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 

Copyright 2001-2011 voogru.com. All Rights Reserved.
Voogru, the Voogru logo, are all trademarks or registered trademarks of voogru.com.
All content on this site is the property of Voogru, and unless otherwise specified, may not be reproduced without prior written consent.