MoodAvatar Script...

Community Forums/Showcase/MoodAvatar Script...

darklordz(Posted 2004) [#1]
Well i made a lil mood avatar script. it's kinda like a random script only it sets the mood .

<?php 
	#MOOD AVATAR SCRIPT...
	$avatrimg = "avatar.png";
	
	if(!isset($act)) {$act="1";}
	
	if($act=="1") {
		print "<body>".file_get_mood()."</body>";
	}
	elseif($act=="2") {
		if(!isset($mood)) {$mood="1";}
		file_set_mood($mood);
		header("Location: ".$PHP_SELF."?act=1");
	}
	
	function file_get_mood() {
		global $avatrimg;
		return "<img src=\"$avatrimg\" border=0 alt=\"\">";
	}
	
	function file_set_mood($mood) {
		global $avatrimg;
		if (!copy("img/mood_$mood.png",$avatrimg)) {
			echo "failed to set mood...<br />\n";
		}
	}
?>


what this does is: Say for instance the script location is http://www.website.com/mood.php. it'll use query$'s to set the mood of your avatar. http://www.website.com/mood.php?act=1 (display current mood), http://www.website.com/mood.php?act=2&mood=1 the mood=1 copies a file with that number number as part of the imagefilename overwriting the original avatar.. witch is http://www.website.com/avatar.png...


jfk EO-11110(Posted 2004) [#2]
nice. reminds me of a cookie-driven tamagotchi I wrote some time ago. users had to feed it at least 1 time a week. it used 8 diffrent pics where number 8 was the graveyard.