It helps to put a plugin karma to xaseco

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

Post Reply
josetey_77
pedestrian
pedestrian
Posts: 10
Joined: 11 Feb 2010 15:08
Owned TM-games: TMUF
Manialink(s): http://car-park.com
Location: spain-alicante
Contact:

It helps to put a plugin karma to xaseco

Post by josetey_77 » 27 Feb 2010 10:07

Hello someone can help me to translate this plugin of karma to xaseco v1.10 this one in version aseco and I not thank you

Code: Select all

<?php

class oliverde8_Hud_karma extends Plugin {
  
  private $_uptime;
  private $karma;
  private $show;
 
	function show($player) { 
				$this->show=True;
				if($this->show==False){
				return;
				}
				
				
		 if ($this->existsPlayerData($player, 'window')) {
			  $window = $this->getPlayerData($player, 'window');
			} else {
			  $window = $this->createWindowToPlayerFramework('Hud Karma', 0, 0, $player,true);
			 // $window->makeStatic();

			  $window->addCallback('Vote', 'Karma');
			  
			  $window->setTextsize(1);
			  $this->storePlayerData($player, 'window', $window);
			  
			}
		
		$xml='<quad sizen="4 4" posn="124 60 0.1" style="Icons64x64_1" substyle="YellowHigh" action="{name:Vote,param:1}"/>';
	  
		//old X pos=124
	  	$xml.='<quad sizen="4 4" posn="124 57 0.1" style="Icons64x64_1" substyle="YellowLow" action="{name:Vote,param:0}"/>';
		
		//oliverde8 logo/avatar
		$xml.='<quad sizen="8 6" posn="115 59.8 0.1" image="http://oliverde8.free.fr/TM/my_scripts/aseco/images/tool.logo.dds" />';
		
		$xml.='<quad posn="114.4 63.6 0" sizen="13.5 10.5" style="Bgs1InRace" substyle="NavButton" />';
		
		$xml.='<quad posn="115 61.78 0.2" sizen="12.6 1.8" style="Bgs1InRace" substyle="BgWindow3" />';
		
		$karma=$this->get_karma($this->Aseco->server->challenge);
			
		$width=((($karma["karma"])*11.6)/100);
		
		$xml.='<quad posn="115.5 61.55 0.4" sizen="'.$width.' 1.2" style="Bgs1InRace" substyle="ProgressBarSmall" />';
		
		$xml.='<label sizen="11 9" posn="116.5 63.20 4" textsize = "1.1" text="$F00TRACK KARMA"/>';
	
	//$xml.='<label sizen="14 3" posn="115.5 61.5 0.4" textsize = "1.3" text="$FFF0%"/>';
	//$xml.='<label sizen="14 3" posn="120 61.5 0.4" textsize = "1.3" text="$FFF50%"/>';
	//$xml.='<label sizen="14 3" posn="124.3 61.5 0.4" textsize = "1.3" text="$FFF100%"/>';
			
		
		if($karma["totkarma"]==""){
		$karma["totkarma"]=0;
		}
		$xml.='<label sizen="11 9" posn="118.5 61.5 0.4" textsize = "0.8" text="$00FN of votes:'.$karma["totkarma"].'"/>';
		
		//$xml.='<label sizen="14 3" posn="115.5 58.5 0.4" textsize = "1.3" text="$FFFKarma:'.$karma["karma"].'"/>';
		//$xml.='<label sizen="14 3" posn="115.5 57 0.4" textsize = "1.3" text="$FFFKarma Bad:'.$karma["bad"].'"/>';
		//$xml.='<label sizen="14 3" posn="115.5 55.5 0.4" textsize = "1.3" text="$FFFKarma good:'.$karma["good"].'"/>';
		//getting Karma info
		//$Tmaneger=$this->Aseco->getPlugin('Trackmaneger');
		//if($Tmaneger){	
		//$xml.=$this->Create_Karma_icon($karma,118,62,$Tid);  			
		//}
		
		$window->setContent($xml);
		
		$window->setPosX(1);
		
		$window->setPosY(-0.484);
	}
	
	function get_karma(&$challenge){
		
		//on start there is no challange data so we will stop it
		if(empty($challenge->data['DB_ID'])){
			return;
		}
		$query = 'Select goodkarma from challenges WHERE Id=' . $challenge->data['DB_ID'];
				$res = mysql_query($query);
			if ( mysql_num_rows($res) == 1 )
				{
				$row = mysql_fetch_row($res);
				$goodkarma = $row[0];
				}
			else
				{
				$goodkarma = 0;
				}

			if ( !isset($goodkarma) )
				{
				$goodkarma = 0;
				}
			mysql_free_result($res);
			
			$query = 'Select badkarma from challenges WHERE Id=' . $challenge->data['DB_ID'];
			$res = mysql_query($query);
			if ( mysql_num_rows($res) == 1 )
				{
				$row = mysql_fetch_row($res);
				$badkarma = -1*($row[0]);
				}
			else
				{
				$badkarma = 0;
				}

			if ( !isset($badkarma) )
				{
				$badkarma = 0;
				}
			mysql_free_result($res);

			$totkarma = $badkarma + $goodkarma;

			if ( $goodkarma > 0 )
				{
				$div1 = $totkarma / $goodkarma;
				if ( $div1 > 0 )
					{
					$div1 = (100 / $div1);
					}
				}
			else
				$div1 = 0.00;

			$div1 = number_format($div1, 2);
		
		$karma["karma"]= $div1;	
		$karma["totkarma"]= $totkarma;
		$karma["bad"]= $badkarma;
		$karma["good"]= $goodkarma;
		
		return $karma;
	}
	function Karma($param, $window, $player){
		$RaspKarma= $this->Aseco->getPlugin('RaspKarma');
		$command['author']=$player;
		if($param==0) $param=-1;
		if ($RaspKarma) {
			$RaspKarma->KarmaVote(&$command, $param);
		}
	}
	
	function remove($player) {
		$this->removePlayerData($player, 'window');
	}
	
	
	function refreshAllPlayers() {
	  $this->Aseco->server->players->resetPlayers();
	  while($player = $this->Aseco->server->players->nextPlayer()) {
	    $this->show($player);
	  }
	}
	
	//will use this function later on :D
	function Hide($player){
		if($this->show==True){
			$this->show=False;
			if ($this->existsPlayerData($player, 'window')) {
					$this->removePlayerData($player, 'window');
			}
		}else{
			$this->show=True;
			$this->show($player);
		}
			
	}
	
	//this function maybe use later on for my trackmaneger plugin
	function Create_Karma_icon($karma,$posx,$posy,$id){
	
		$Tmaneger=$this->Aseco->getPlugin('Trackmaneger');
		$Tsettings=$Tmaneger->random_set;
		
		$query2 = 'SELECT Random,NbPlayed FROM challenges WHERE Id=' .$id;
		$res2 = mysql_query($query2);
		
		if (!$res2){
			return;
		}
		$row = mysql_fetch_row($res2);
		$Cat=$row[0];	
		$NBplayed=$row[1];
		
		
		if($karma["totkarma"]<$Tsettings["TM"]["vote"]["min"]){
		$xml='<quad sizen="3 3" posn="'.$posx.' '.$posy.' 0.8" style="Icons64x64_1" substyle="Check"/>';
		
		}else if(($karma["karma"]<$Tsettings)){
		$xml='<quad sizen="3 3" posn="'.$posx.' '.$posy.' 0.8" style="Icons64x64_1" substyle="LvlRed"/>';		
		}else{
		
		
		}


		if($Cat=="AYES" 
		||$Cat=="YES" 
		|| $karma>$Tsettings["TM"]["points"]["min"] ){
			$xml='<quad sizen="5 5" posn="'.$posx.' '.$posy.' 0.8" style="Icons64x64_1" substyle="LvlGreen"/>';
		
		}else if(($Cat=="No" ||$Cat=="ANO") 
		&& ($karma>=$Tsettings["TM"]["points"]["max_delete"] 
		&&$NBplayed<$Tsettings["TM"]["played"]["max"] )){
			$xml='<quad sizen="5 5" posn="'.$posx.' '.$posy.' 0.8" style="Icons64x64_1" substyle="LvlYellow"/>';
		
		}else if($NBplayed>$Tsettings["TM"]["played"]["max"]){
			$xml='<quad sizen="5 5" posn="'.$posx.' '.$posy.' 0.8" style="Icons64x64_1" substyle="Check"/>';
		
		}else {
			$xml='<quad sizen="5 5" posn="'.$posx.' '.$posy.' 0.8" style="Icons64x64_1" substyle="LvlRed"/>';
		
		}
		return $xml;
	}
	
}
$_PLUGIN = new oliverde8_Hud_karma();
$_PLUGIN->setAuthor('Oliverde8');
$_PLUGIN->setVersion(1.2);
$_PLUGIN->setDescription('Hud with Karma information and voting karma');
$_PLUGIN->addEvent('onPlayerConnect', 'show');
$_PLUGIN->addEvent('onPlayerDisconnect', 'remove');

$_PLUGIN->addEvent('onNewChallenge', 'refreshAllPlayers');
$_PLUGIN->addEvent('onKarmaChange', 'refreshAllPlayers');

$_PLUGIN->addDependence('LocalDb', 1.0, null);
$_PLUGIN->addDependence('RaspKarma', 1.0, null);



centorus
tricycle manager
tricycle manager
Posts: 29
Joined: 28 Feb 2009 13:48
Owned TM-games: TMUF
Location: Nantes, France

Re: It helps to put a plugin karma to xaseco

Post by centorus » 27 Feb 2010 11:58

I think it's a aseco's plugin and not a xaseco's plugin
Image
Image

josetey_77
pedestrian
pedestrian
Posts: 10
Joined: 11 Feb 2010 15:08
Owned TM-games: TMUF
Manialink(s): http://car-park.com
Location: spain-alicante
Contact:

Re: It helps to put a plugin karma to xaseco

Post by josetey_77 » 28 Feb 2010 20:34

Already but need that somebody translate me this to the fufi_karmaWidget
since it comes with percentage and mas things

Post Reply