Your wishes

Moderators: Libero, cyrilw, matrix142, jensoo7, NADEO

Bladinium
Posts: 110
Joined: 07 Sep 2012, 14:35

Re: Your wishes

Post by Bladinium »

Hello and thank you for your quick response :)

Here is the file used for Smart must have callbacks in I think?

Yours

Code: Select all

<?php
	$this->register_plugin('STUNTSCORE', 'stuntscore', '1.1.1');
	$this->register_event('onInit','plugin_stuntscore_init');
	$this->register_event('ModeScriptCallback','plugin_stuntscore_callback');
	$this->register_event('PlayerConnect','plugin_stuntscore_connect');
	$this->register_event('PlayerConnectWithData','plugin_stuntscore_connect');
	$this->register_event('BeginMatch','plugin_stuntscore_init');
	//$this->register_event('EndMatch','plugin_stuntscore_hide');	
	//$this->register_event('EndRound','plugin_stuntscore_hide');	
	
	//samples of xmlrpc callbacks:
	/*
	When a Player Starts (or is on Startline first time)
	(playerStart, playerLogin:ubm;stuntScore:0;CP:0)
	Each Checkpoint	( CP. NR, not count ! )
	(playerCheckpoint, playerLogin:ubm;stuntScore:199;CP:1)
	And finish CP Count !
	(playerFinish, playerLogin:ubm;stuntScore:755;CPCount:3)
	*/
function plugin_stuntscore_init($smart, $data){
		//load config
		$smart->loadsettings('plugin.stuntscore.xml','plugin.stuntscore');
		if(strtolower($smart->settings['plugin.stuntscore']->enabled) != 'true') return;
		//create Table smart_records
		$sql="CREATE TABLE IF NOT EXISTS `smart_records` (`login` varchar(50) COLLATE utf8_unicode_ci NOT NULL,"
			."`uid` varchar(99) COLLATE utf8_unicode_ci NOT NULL, `score` int(11) NOT NULL,"
			."`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,KEY `login` (`login`,`uid`))"
			." ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
		$result = $smart->sql->ex($sql);
		$smart->settings['plugin.stuntscore']['Vars']['ranks']=array();;
		plugin_stuntscore_show	($smart, Null);
		plugin_stuntscore_show	($smart, "dummy");
		}
		
function plugin_stuntscore_connect($smart, $data)
{
plugin_stuntscore_show	($smart, Null);
$ranks=$smart->settings['plugin.stuntscore']['Vars']['ranks'];
plugin_stuntscore_show	($smart, $ranks);
}


function plugin_stuntscore_hide($smart, $data){
$smart->chat("..");
//$title='LiveRanks';
$smart->hideManiaLink("plugin.stuntscore.".$title);
$title='LocalRecords';
$smart->hideManiaLink("plugin.stuntscore.".$title);
$oscor=array();
}
function plugin_stuntscore_show	($smart, $data){
if (isset($data)){
		//Livescore
	//	$ypos=($smart->settings['plugin.stuntscore']->pos_y_live);
	//	$xpos=($smart->settings['plugin.stuntscore']->pos_x_live);
	//	$layer=$smart->settings['plugin.stuntscore']->layer_live;
	//	$maxrows=$smart->settings['plugin.liverankings']->max_rows;
	//	$repl=$data; 
	//	$title='LiveRanks';
		}
	//	else
			{
			//Localrecords
			$ypos=($smart->settings['plugin.stuntscore']->pos_y_local);
			$xpos=($smart->settings['plugin.stuntscore']->pos_x_local);
			$layer=$smart->settings['plugin.stuntscore']->layer_local;
			$maxrows=$smart->settings['plugin.liverankings']->max_rows;
			$title='LocalRecords';
			$sql='SELECT * FROM  `smart_records` where uid ="'.trim($smart->currentmap[UId]).'" ORDER BY  `smart_records`.`score` DESC LIMIT 0 , '.$maxrows;
		    $repl=$smart->sql->get_list_assoc($sql);
			}
			//display window
		$scbg=($maxrows)*1.5;
		$xml = '<manialink id="'.$smart->get_manialink_id('plugin.stuntscore.'.$title).'"><frame posn="'
				.$xpos.' '
				.$ypos.' '
				.$layer.'">';
			$xml .= '<frame posn="0 -0 1">';
			$xml .= '<label posn="0.2 0 0.5" halign="left" text="#" textsize="0.8" textcolor="333F" />';
			$xml .= '<label posn="1.2 0 0.5" sizen="6 1" halign="left" text="'.$title.'" textsize="0.8" textcolor="000F" />';
			$xml .= '<label posn="10.5 0 0.5" halign="left" text="Score" style="TextRaceStaticSmall" textsize="0.8" textcolor="FFFF" />';
			$xml .=	'<quad posn="0 0.5 0" sizen="15 2" halign="left" style="BgsPlayerCard" substyle="BgRacePlayerName"/>';
			$xml .=	'<quad posn="0 0.5 -1" sizen="15 60 '.$scbg.'" halign="left" style="BgsPlayerCard" substyle="ProgressBar"/>';
			$xml .= '</frame>';
		$y = 1.7;
		$rank = 0;
		foreach ($repl as $data1)		
		{
		$rank++;
		if ($title =="LocalRecords"){
		$login=$data1['login'];
		$score=$data1['score'];
		}
		//else if ($title=="LiveRanks"){
		//$login=$data1['playerLogin'];
		//$score="$FF0".$data1['stuntScore'];		
		//}
		$nn=$smart->sql->get_assoc('select nickname from smart_players where login ="'.$login.'"');
		$nickname=$nn['nickname'];
			$xml .= '<frame posn="0 '.($y*-1.8).' 1.9">';
			$xml .= '<label posn="1.7 1.1 0.5" halign="right" text="'.$rank.'." textsize="1.70" textcolor="FffF" />';
			$xml .= '<label posn="1.9 1.1 1.5" sizen="9.5 1" halign="left" text="'.$smart->chars($smart->remove_sizes($nickname)).'" textsize="1.70" textcolor="AAAF" />';
			$xml .= '<label posn="12.1 1.1 0.5" halign="left" text="'.$score.'" textsize="1.70" textcolor="FFFF"/>';
			$xml .= '</frame>';
			$y++;
			
		}
		$xml .= '</frame></manialink>';
		//$smart->console($xml);
		$smart->showManiaLink($xml, 0, false, false);
	}
function plugin_stuntscore_xmlrpctoarray($smart, $data){
		if (isset($data[1])) {
		$dat = explode(";",$data[1]);
		$dataset=array();
		foreach ($dat as $tmp){
		$da= explode(":",$tmp);
					$dataset[$da[0]]=$da[1];
					$dataset[$da[2]]=$da[3];
		}
		$callback1[0]=$data[0];
		$callback1[1]=$dataset;
		return $callback1;
		}
		}
function plugin_stuntscore_callback ($smart,$data){
//convert to array
$datastunt=plugin_stuntscore_xmlrpctoarray($smart,$data);
//check what kind of callback
$callback = trim($datastunt[0]);
$dat= $datastunt[1];
switch ($callback){
    case "playerCheckpoint":
	$login=$dat['playerLogin'];
		$smart->settings['plugin.stuntscore'][$login]['checkpoint'] = $dat['CP'];
		$smart->settings['plugin.stuntscore'][$login]['points'] = $dat['stuntScore'];
		break;
    case "playerFinish":
			$login=$dat['playerLogin'];
			if (intval($dat['stuntScore']>$oscore[$login]['score'])){
			$oscore[$login]['score']=$dat['stuntScore'];
			}
		$smart->settings['plugin.stuntscore'][$login]['checkpoint'] = $dat['CPCount'];
		$smart->settings['plugin.stuntscore'][$login]['points'] = $dat['stuntScore'];
		$sql='select * from smart_records where login="'.trim($login).'" and uid ="'.trim($smart->currentmap[UId]).'"';
		$repl=$smart->sql->get_assoc($sql);
		//if no record yet :
		if (!$repl)
		{
			$sql="INSERT INTO `smart_records` (`score`, `login`, `uid`, `date`) VALUES ('".$dat['stuntScore']."', '".trim($login)."', '".trim($smart->currentmap[UId])."', CURRENT_TIMESTAMP)";
			$repl=$smart->sql->get_assoc($sql);
			plugin_stuntscore_show	($smart, Null);
			}
			// if allready a record from player on this map , check if current score better, if yes, update.
			else{
			$sc=intval($repl['score']);
			if (intval($dat['stuntScore'])>$sc){
			$sql='update smart_records set score= "'.$dat['stuntScore'].'" where login="'.trim($login).'" and uid="'.trim($smart->currentmap[UId]).'"';
			$repl=$smart->sql->get_assoc($sql);
			plugin_stuntscore_show	($smart, Null);
			}
			}
		break;
		case "playerRanking":
						plugin_stuntscore_liveshow ($smart, $data);
		break;
    }
}


function plugin_stuntscore_liveshow($smart, $ranking){
$json_errors = array(
    JSON_ERROR_NONE => 'Es ist kein Fehler aufgetreten',
    JSON_ERROR_DEPTH => 'Die maximale Stacktiefe wurde erreicht',
    JSON_ERROR_CTRL_CHAR => 'Steuerzeichenfehler, möglicherweise fehlerhaft kodiert',
    JSON_ERROR_SYNTAX => 'Syntaxfehler',
);
$ranks=json_decode($ranking[1],true);
//$smart->console($json_errors[json_last_error()], PHP_EOL, PHP_EOL);
plugin_stuntscore_show ($smart,$ranks);
$smart->settings['plugin.stuntscore']['Vars']['ranks']=$ranks;
}

?>
Bladinium
Posts: 110
Joined: 07 Sep 2012, 14:35

Re: Your wishes

Post by Bladinium »

In fact, I really need a plugin that rewards the first player and the second player arrived stunt. for the local record. You think it is possible with fox?
User avatar
matrix142
Posts: 382
Joined: 18 Mar 2011, 18:12
Contact:

Re: Your wishes

Post by matrix142 »

Yes sure it's possible.
I'll work on it next weekend, because I have to go to work during the week.
Bladinium
Posts: 110
Joined: 07 Sep 2012, 14:35

Re: Your wishes

Post by Bladinium »

You can not quit your job for me? :roflol:

Verry thx for works! I'll wait :)
User avatar
matrix142
Posts: 382
Joined: 18 Mar 2011, 18:12
Contact:

Re: Your wishes

Post by matrix142 »

I startet to code some needed functions for the Stuntmode.
But I'll have to wait until Spaii releases the new version of the Stunt Script with integrated Callbacks.
Bladinium
Posts: 110
Joined: 07 Sep 2012, 14:35

Re: Your wishes

Post by Bladinium »

ok thx :=)
Bladinium
Posts: 110
Joined: 07 Sep 2012, 14:35

Re: Your wishes

Post by Bladinium »

I was wondering, it is possible to use two managers at the same time? I would like to use fox manager scores, music, and other plugins required, and to manage "smart" Is it possible?
User avatar
matrix142
Posts: 382
Joined: 18 Mar 2011, 18:12
Contact:

Re: Your wishes

Post by matrix142 »

Yes it is possible.
But you have to look that there are no plugins active with the same functions.
User avatar
spaii
Posts: 1100
Joined: 19 Jun 2010, 00:04
Location: Rémy - France
Contact:

Re: Your wishes

Post by spaii »

matrix142 wrote:I startet to code some needed functions for the Stuntmode.
But I'll have to wait until Spaii releases the new version of the Stunt Script with integrated Callbacks.
Matrix, i can send you a version of the title pack with some callbacks already integrated ;)

I think, public version will be ready after end of this week .
User avatar
spaii
Posts: 1100
Joined: 19 Jun 2010, 00:04
Location: Rémy - France
Contact:

Re: Your wishes

Post by spaii »

oups, another thing : Callbacks sending by title pack only working with ApiVersion 2012-06-19

I don't know if FoxControl work with this ApiVersion...
Post Reply

Return to “FoxControl”

Who is online

Users browsing this forum: No registered users and 1 guest