Pay in manialink

If you have anything to say - or advice to give - on the creation or publishing of ManiaLinks, here is the place to do it!

Moderator: TM-Patrol

Post Reply
jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Pay in manialink

Post by jouko100 » 18 Sep 2009 04:45

is it possible to pay coppers for player in manialink
Last edited by jouko100 on 04 Oct 2009 13:57, edited 2 times in total.

User avatar
SaTaNaSDiaBoLo
Pit Crew
Pit Crew
Posts: 346
Joined: 16 Aug 2005 14:53
Owned TM-games: TMO TMS TMN TMU TMUF
Manialink(s): maniahome
Location: In my Home on ManiaHome Manialink

Re: Pay in manialink

Post by SaTaNaSDiaBoLo » 18 Sep 2009 08:44

It's possible if you register a maniacode, and put the player's login as beneficiary of the price.
I hope it's the answer your waiting for, maybe I've not understood correctly so let me know, and I'll try to help you.
Imagecolor>

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Re: Pay in manialink

Post by jouko100 » 18 Sep 2009 12:54

i have game and i like to pay wins in manialink

User avatar
apovtx
happy cruiser
happy cruiser
Posts: 154
Joined: 04 Dec 2008 16:06
Owned TM-games: TMUF,TMNF,TMN
Manialink(s): funteam
Location: Xanthi,Greece
Contact:

Re: Pay in manialink

Post by apovtx » 18 Sep 2009 16:11

If i understood, you want to pay the winner through manialink? For example if a player wins, the manialink will pay the coppers to the player? I don't think this is possible.

:thumbsup: :lovetm Apovtx
Do you wanna be a journalist?
Contact me with PM!
Image

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Re: Pay in manialink

Post by jouko100 » 19 Sep 2009 09:30

maybe if server is running and mainlink sends data to server and server pays
Last edited by jouko100 on 25 Sep 2009 19:13, edited 1 time in total.

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Re: Pay in manialink

Post by jouko100 » 25 Sep 2009 13:06

Now i have working plugin for pay in manialiks thru xaseco server.This code is in manialink it writes winner and win in file.Make empty voittaja.txt and voittaja2.txt files in manailink folder.Wins are waiting in queue when xaseco server is running they are paid.
Next reply is needed xaseco plugin.



voittaja2.txt file is in this format:login|win|time|

jouko100|150|[09/24,08:07:22] |jouko100|150|[09/24,08:14:06] |jouko100|150|[09/24,08:29:08] |jouko100|150|[09/24,09:18:53] |

edited 7.11 09 added remove too old lines


Code: Select all

//***************winner************************

// made  by jou**********************************************
//remove too old lines********************************************'***** 
// remove CR ************************************
$myFile = "voittaja.txt";
$fh = fopen($myFile, 'r');
$data = fread($fh, filesize($myFile));
fclose($fh);
$data = str_replace("
", "", $data);
$myFile = "voittaja.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $data;
fwrite($fh, $stringData);
fclose($fh);

//destroy  fist line*********************************************************
$myFile = "voittaja.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $data;
fwrite($fh, $stringData);
fclose($fh);
//make array****************************************
$data = file("voittaja.txt");
$a = 0;
while($a < count($data))
   {
   $arr = explode("|", $data[$a]);

   
   $a++;
   }

$laskuri= count($arr);
print $laskuri;
print $arr[0];
  if ($laskuri>27)//removes line if there is more then 10 lines.U can edit it(3*line)**********
{
unset($arr[0]);
unset($arr[1]);
unset($arr[2]);

// back array to  file*****************************************************************
$fp=fopen("voittaja.txt","w+");
foreach($arr as $key => $value){
fwrite($fp,$value."|");
}
// remove last char file************************************
$myFile = "voittaja.txt";
$fh = fopen($myFile, 'r');
$data = fread($fh, filesize($myFile));
fclose($fh);

$data2 = substr_replace($data,"",-1);//poista viim merkki

$myFile = "voittaja.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $data2;
fwrite($fh, $stringData);
fclose($fh);
}
//end remove too old lines*************************************************
$hourdiff = "1";
$timeadjust = ($hourdiff * 3600); 
$time = '[' . date('m/d,H:i:s',time() + $timeadjust) . '] ';
$login2 =($_GET['playerlogin']);
$login2.="|".$coppers."|".$time ."|";
$players_LOG = 'voittaja.txt';

if ($file = fopen($players_LOG, 'a+')) {
				fwrite($file, $login2);
				fclose($file);
			}
//************************************
// clean  beginning********************************

$myFile = "voittaja.txt";
$fh = fopen($myFile, 'r');
$text3 = fread($fh, filesize($myFile));
fclose($fh);

$clean = trim($text3, "\xEF\xBB\xBF");

$myFile = "voittaja2.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $clean;
fwrite($fh, $stringData);
fclose($fh);  


Last edited by jouko100 on 08 Nov 2009 06:02, edited 14 times in total.

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Re: Pay in manialink

Post by jouko100 » 25 Sep 2009 18:02

edited 8.11.09 added remove too old lines********
edited 9,10,2009*********************


And next xaseco plugin.Server must have TMU rights.It transfers file from manailink server and pays wins.Name it copy.php.add it to xaseco plugins directory.Edit manialink server address.Add line
<plugin>copy.php</plugin> in plugins.xml.
Make emty files winner.txt, allpayed.txt in xaseco folder


Code: Select all

<?php
// made  by Jou**************************************************

Aseco::registerEvent('onEndRace', 'load_copy');

function load_copy($aseco) {
// copy file******************************************
$uri = "http://www. yours manialink server address/voittaja2.txt";// edit  this ******************
$inhalt = file_get_contents($uri);
if ($inhalt !== false) {

$myFile = "winner.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $inhalt;
fwrite($fh, $stringData);
fclose($fh);

//make array*************************************
$datei = file("winner.txt");
$a = 0;
while($a < count($datei))
   {
   $data = explode("|", $datei[$a]);   
   $a++;
   }
//end make*************************************************
$units=sizeof($data)-1;
//make  $contents********************************************
$i = 0;
while($i < $units)
  {
$contents=$data[$i]."|".$data[$i+1]."|".$data[$i+2]."|";
//end make $contents*************************************************
// check if aldredy payed***************************************
$log = 'allpayed.txt';
$pay = true;
$hits=0;
if (!file_exists ($log)) {
	echo "Error: $log does not exist.";
	exit;
}
$h = fopen ($log, 'r');
while (!feof ($h)) {
	$line = fgets ($h, 4096);
	$line = trim ($line);
      	if ($line != '')
		$hits++;

	if ($line == $contents)
		$pay = false;
}
fclose($h);
// end  check*****************************************************
//removes too old lines .Removes  fist line if lines>15 ***************
$arrayOflines=file('allpayed.txt');
$count2= count($arrayOflines);
print $count2;

  if ($count2>15)// 15 rows u can edit this**********
{

$linesIWant=array_slice($arrayOflines,1);

$fileContents=implode($linesIWant);

$fp=fopen('allpayed.txt','w+');
fwrite($fp,$fileContents);
fclose($fp);
}
//end remove too  old lines******************************************

if ($pay == true) {
// pay*****************************************************
// add to all payed list******************************
$players_LOG = 'allpayed.txt';
$text=$contents ."
";

if ($file = fopen($players_LOG, 'a+')) {
				fwrite($file, $text);
				fclose($file);
			}
//end list****************************************************



$login=$data[$i];
$win=$data[$i+1];
if ($aseco->server->getGame() == 'TMF') {
		// check for TMUF server				
				settype($win,'integer');
				$aseco->client->query('Pay', $login, $win, "u won manialink lotto");


}				
}
$i++; 
$i++;
$i++;
} 
}
else{
exit;
}
}
?>
Last edited by jouko100 on 15 Jul 2010 15:30, edited 5 times in total.

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Re: Pay in manialink

Post by jouko100 » 09 Oct 2009 05:20

edited 9,10,2009 added check if manialink server is ok

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Re: Pay in manialink

Post by jouko100 » 10 Oct 2009 02:34

With this xaseco plugin u can see 20 last winners from allpayed file from previous plugin in xaseco server.Copy code and save it with name winners.php.Add it to xaseco plugins directory.Add line <plugin>winners.php</plugin> in plugins.xml.
In game use /winners command



[img=http://img527.imageshack.us/img527/7969/winners.th.png]

Code: Select all

<?php

//******* this script is made by jou****************************
// in game  use  command /winners

Aseco::addChatCommand('winners', 'winners command');
function chat_winners($aseco, $command) {	if ($aseco->server->getGame() == 'TMF') {


// count lines**********************************************************
$file = "allpayed.txt";
$lines = count(file($file));

// destroy lines***********************************************************
if($lines>20){
$counter=$lines-21;
}

$i=0;
while($i<$counter)
{


if($lines>20){
$filePath = './allpayed.txt';
// Grab file into an array, by lines
$fileArr = file( $filePath );
// Remove desired line
unset( $fileArr[0] ); // $fileArr[0] == line #1
// Put back with PHP4
$success = FALSE;
if ( ( $fp = fopen( $filePath, 'w' ) ) !== FALSE )
{
    if ( flock( $fp, 2 ) ) // LOCK_EX
    {
        fwrite( $fp, implode( '', $fileArr ) );
        flock( $fp, 3 ); // LOCK_UN
        $success = TRUE;
    }
    fclose( $fp );
}
}
$i++;
}

// grab log*********************************************************
$myFile = "allpayed.txt";
$fh = fopen($myFile, 'r');
$lista = fread($fh, filesize($myFile));
fclose($fh);




		$header = '{#welcome}Last winners in fruit game ';
		$data = array();                
                $data[] = array($lista);
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                $data[] = array('{#message}');
                                
                // display ManiaLink message
		display_manialink($command['author']->login, $header, array('Icons64x64_1', 'IconPlayers', -0.01), $data, array(1.4), 'OK');
	}
}  
?>

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Re: Pay in manialink

Post by jouko100 » 07 Nov 2009 17:20

edited 8.11.09

Post Reply