From OBEY wiki
Jump to: navigation, search

Customize your own trophy server

Different trophies and awards can be given to the players on your servers. They show up as markings next to the name of the player on the leader boards.
Any trophy can be automatically given for playing in a tournament or they can be manually assigned by a moderator.
If you are running your own server, they can mean whatever you want.


The default configuration for trophies.

This is managed through the following files: config.php, trophyPost.php, and trophies.txt on a web server.

For this all to work you must first upload the two php files given below onto a server that you own, and then set the following in your serverSettings.txt


Then, when you want to give a bunny an award you must be a mod on your server and use the /trophy Console Commands.

For example: Typing ```/trophy playerID 1st``` will give that player a "1st" trophy. Whatever trophies you want are defined in this file. In the comments you can get an idea for what the trophies look like, and change it accordingly if you want your trophies to be different.

The trophy records are stored in a text file which is defined inside of config.php as shown below:


$postPW = "myPassword";
$trophiesFile = 'trophies.txt';	

In this case, trophies.txt is changed by trophyPost.php each time a trophy is awarded. When your server loads a new map it also goes on the web and reads trophies.txt so it can know who has trophies and will show their trophies next to their names respectively in the in-game leader boards.

trophyPost.php is what the server talks to when a mod tells it to give a player a trophy. trophyPost.php processes the server message, and saves it into the trophies.txt file as necessary in the appropriate format. Below is an example of a single line in the trophies.txt file. This example player has 3 trophies of different kinds, but each happens to be green colored. Each player that has won trophies has their own line in the trophies file. playerName^playerID^b1:00ff00#b2:00ff00#a1:00ff00



	if ($_GET["pw"] != $postPW)

	//convert what the server told us happened, into some kind of "record or trophy" that can be displayed next to the player's name
	//the format is: playerName^playerID^b1:00ff00#b2:00ff00#a1:00ff00
	//OBEY servers will read this and search it for players that are joining.  
	//Each time they find the player's ID (the name is just for convenience of manual editing) it will display the award in the score board
	//a1 = a vertical line next to the name
	//a2 = a thick vertical line 
	//a3 = a large cube
	//b1 = a small dot 
	//b2 = 2 small dots , one over the other 

	$trophy = $_GET["trophy"];	
	$profileID = $_GET["profileID"];	 
	$playerName = $_GET["playerName"];	
	if ($profileID == "" || $playerName == "" || $trophy == "")
	 if ($trophy != "1st" && $trophy != "2nd" && $trophy != "3rd")
		 echo "[ff0000]Trophy not recognized.[-]"; //this will be printed to everyone on the server

 	$data = file($trophiesFile); // reads an array of lines
	$recordExists = 0;

	$outData = array();
	//below, we transcribe each line from $data into $outData, making any needed changes as we go.
	for ($i = 0; $i < Count($data); $i++)
		if (strncmp($data[$i], $profileID, strlen($profileID)) === 0)  //does the line starts with the profileID?
			$recordExists = 1;
			//we may have a mix of dots.. so lets order them. First place on the left, 2nd markers in the middle, 3rds on the right. 
			//count any we may have
			$firsts = (int)substr_count($data[$i], 'b1:00ff00'); 
			$firsts += (int)substr_count($data[$i], 'b2:00ff00') * 2;
			$seconds = (int)substr_count($data[$i], 'b1:00ffff'); 
			$seconds += (int)substr_count($data[$i], 'b2:00ffff') * 2;
			$thirds = (int)substr_count($data[$i], 'b1:008989'); 
			$thirds += (int)substr_count($data[$i], 'b2:008989') * 2;
			//add the trophy given by the url
			if ($trophy == "1st") //won first place
			else if ($trophy == "2nd") 
			else if ($trophy == "3rd") 
 				 echo "[ff0000]Trophy not recognized.[-]"; //this will be printed to everyone on the server

			//reorganize and print all awards, so that they appear in order 1st, 2nd, 3rd place wins
			$awards = "";
			for ($d = 0; $d < (int)floor($firsts/ 2); $d++)  //firsts/2 in a way that will not round or cast to float
				$awards .= "b2:00ff00#";
			if ($firsts % 2 == 1)
				$awards .= "b1:00ff00#";
			for ($d = 0; $d < (int)floor($seconds/ 2); $d++)   
				$awards .= "b2:00ffff#";
			if ($seconds % 2 == 1)
				$awards .= "b1:00ffff#";
			for ($d = 0; $d < (int)floor($thirds/ 2); $d++)  
				$awards .= "b2:008989#";
			if ($thirds % 2 == 1)
				$awards .= "b1:008989#";

			$outData[Count($outData)] = $profileID."^".$playerName."^".$awards."\n";
	   else if ($data[$i] != "" && $data[$i] != "\n" && $data[$i] != "\n\n")
		   $outData[Count($outData)] = $data[$i]; //nothing noted, just copy this line to the end of the output
	if ($recordExists == 0) //this is the first trophy for this player
		if ($trophy == "1st") //won first place
			 $outData[Count($outData)] = $profileID."^".$playerName."^b1:00ff00\n"; //add the new record
		else if ($trophy == "2nd") 
			 $outData[Count($outData)] = $profileID."^".$playerName."^b1:00ffff\n"; 
		else if ($trophy == "3rd") 
			 $outData[Count($outData)] = $profileID."^".$playerName."^b1:008989\n"; 	
	file_put_contents($awardsFile, implode("", $outData));
	echo "[00ff00]". $playerName ." = ". $trophy."![-]"; //this will be printed to everyone on the server