Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Coding Help With Web-based Rpg Game!

    Hello coders!

    I have a slight problem coding the last php script of the game (RPG war system game) similar as Kings of chaos!

    Actually I can't let the (turns) and the time move on every 10, 20 or whatever time I want!!

    I need your help guys!

    Which php file I should edit? What's wrong with the script?

    this is my email

    crims123@gmail.com

    Thanx

  • #2
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    we need to see your code! were not psychic!

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanx

    This is the code in (vsys.php) :

    Code:
    <?php
    session_start();
    $this_country=0;
    
    include "lib.php";
    
    
    foreach($HTTP_POST_VARS as $key => $value ){
    	$cgi[$key]=$value;
    }
    foreach($HTTP_GET_VARS as $key => $value ){
    	$cgi[$key]=$value;
    }
    
    $db = @mysql_connect('localhost', $conf["sites_database_login"], $conf["sites_database_password"]);
    if (!$db) {
    	alert (mysql_error());
    }
    if (!@mysql_select_db($conf["sites_database_name"], $db)) {
    	$str=mysql_error();
    	if ($str)	alert ($str);
    }  
    
    if ($cgi["uname"]){
    	//echo $cgi["uname"].$cgi["uemail"].$cgi["psword"];
    	$isLogined1=isLogined($cgi["uname"],$cgi["uemail"],$cgi["psword"]);
    	if ($isLogined1){
    		$usT=getUserDetails($isLogined1," active ");
    		logIP($isLogined1);
    		if ($usT->active==1){
    			$_SESSION["isLogined"]=$isLogined1;
    			$sN=$HTTP_SERVER_VARS['SCRIPT_NAME'];
    			//echo "==".$sN."==";
    			
    			if (($sN==$conf["path"].'/index.php')||($sN==$conf["path"].'/battlefield.php')||($sN==$conf["path"].'/help.php')||($sN==$conf["path"].'/aboutus.php')||($sN==$conf["path"].'/register.php')||($sN==$conf["path"].'/forgotpass.php')||($sN==$conf["path"].'/spam.php')||($sN==$conf["path"].'/privacy.php')||($sN==$conf["path"].'/advertising.php')||($sN==$conf["path"].'/tos.php')||($sN==$conf["path"].'/activate.php')||($sN==$conf["path"].'/forgotpass.php')){
    				header("Location: base.php"); 
    				exit;
    			}
    		}elseif($usT->active==2){
    			$MessageStr="You are banned.<br> Try to contact admins of the site to get to know why this have taken place.";
    			include "message.php";
    			exit;
    		}elseif($usT->active==3){
    			$MessageStr="You are supporter.<br> Right now this status is not supported. <br> Try to contact admins of the site to get to know why this have taken place.";
    			include "message.php";
    			exit;
    		}elseif($usT->active==4){
    			setcookie ("isLogin", "1",time()+3600); 
    			header("Location: admin/index.php"); 
    			exit;
    		}else{
    			$_SESSION["activationID"]=$isLogined1;
    			header("Location: activate.php"); 
    		}
    		
    	}else {
    		$MessageStr="The login and password you have entered do not match.<br> Try to retype them again.";
    		include "message.php";
    
    function getWeaponArray($weaponA1){
    	$k=0;
    	for ($i=0;$i<count($weaponA1);$i++){
    		for ($j=0; $j<$weaponA1[$i]->weaponCount ;$j++){
    			$weaponA[$k]=$weaponA1[$i];
    			$k++;
    }
    function addTurns($id,$addTurns,$lastTurnTime){
    	//$str = "INSERT INTO `UserDetails` (attackTurns ,lastTurnTime ) VALUES ('/banners/$bname')";
    	$str = "update `UserDetails` set attackTurns='$addTurns', lastTurnTime='$lastTurnTime' where ID='$id'";
    	//echo $str;
    	mysql_query($str);
    }
    
    
    function getNextTurn($user){
    	global $conf;
    	$info=getCommonInfo();
    	$lastTurnTime=$info->lastTurnTime;
    	$thisTime=time();
    	$dif=$thisTime-$lastTurnTime;
    	//$nextTurn=$dif;
    	$nextTurnMin=$dif/60;
    	/*if ($nextTurnMin>$conf["minutes_per_turn"]){
    		//echo "--------";
    		$addTurnsF=$dif/($conf["minutes_per_turn"]*60);
    		$addTurns=floor($addTurnsF);
    		//$nextTurn1=($addTurnsF-$addTurns)*$conf["minutes_per_turn"];
    		$nextTurn1=$dif-(($conf["minutes_per_turn"]*60)*$addTurns);
    		//echo $addTurns."##".$nextTurn1."##".($thisTime-$nextTurn1)."<br>";
    		$nextTurn=round($nextTurn1/60);
    		$addTurns+=$user->attackTurns;
    		addTurns($user->ID,$addTurns,$thisTime-$nextTurn1);
    		
    	}else*/
    	{
    		$nextTurn=round($nextTurnMin);
    	}
    	//echo $dif."<br>";
    	$nextTurn=$conf["minutes_per_turn"]-$nextTurn;
    	if ($nextTurn<0)$nextTurn=0;
    	return $nextTurn;//($conf["minutes_per_turn"]-$nextTurn);
    }
    
    function getCommonInfo(){
    	$str="select * from `Mercenaries`";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {
    		print ('Query failed: '.mysql_error());
    		return;
    	}
    	if (!@mysql_num_rows($q)) {
    		return 0;
    	}
    	else{
    		$st="";
    		$st = mysql_fetch_object($q);
    		return $st;
    	}	
    }
    
    //----------------------------Messages-----------------------------------------------
    function getMessagesCount($userID){
    	$str = "SELECT COUNT(*) FROM `Messages` where userID='$userID' ";
    	$q = @mysql_query($str);
    	if ($q){
    		$st = mysql_fetch_array($q);
    		return $st[0];
    	}else{return 0;}
    }
    function getAllMessages($userID ){
    	$str="SELECT * FROM `Messages` WHERE userID='$userID'";
    	//print $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if (!@mysql_num_rows($q)) {return;}
    	else{
    		$st="";
    		$i=0;
    		while ($row = mysql_fetch_object($q)){
    			$st[$i]=$row;
    			$st[$i]->subject =urldecode ($st[$i]->subject);
    			$st[$i]->text =urldecode ($st[$i]->text);
    			$i++;
    		}
    		return $st;
    	}	
    }
    function getMessage($messID){
    	$str="select * from `Messages` where  ID='$messID' ";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {
    		print ('Query failed: '.mysql_error());
    		return;
    	}
    	if (!@mysql_num_rows($q)) {
    		return 0;
    	}
    	else{
    		$st="";
    		$st = mysql_fetch_object($q);
    		$st->subject =urldecode ($st->subject);
    		$st->text =urldecode ($st->text);
    		return $st;
    	}	
    }
    function sendMessage($id,$toid,$subject,$text){
    	$text=urlencode($text);
    	$subject=urlencode($subject);
    	$date=time();
    	$str = "INSERT INTO `Messages` (fromID , userID ,subject ,text,date ) VALUES ('$id','$toid','$subject','$text','$date')";
    	$q = @mysql_query($str);
    	return $q;
    }
    function deleteMessage($mesID){
    	$str = "DELETE FROM  `Messages` WHERE ID='$mesID'";
    	//echo $str;
    	$q = @mysql_query($str);
    }
    function deleteMessagesOfUser($id){
    	$str = "DELETE FROM  `Messages` WHERE userID='$id'";
    	//echo $str;
    	$q = @mysql_query($str);
    }
    //----------------------------END Messages-----------------------------------------------
    
    //----------------------------Officers-----------------------------------------------
    function getOfficers($id, $page, $fields="userID,userName, rank, trainedAttackSold ,trainedAttackMerc ,trainedDefSold ,trainedDefMerc ,untrainedSold, untrainedMerc, spies, race"){
    	global $conf;
    	$start=($page-1)*$conf['users_per_page'];
    	$str="SELECT $fields  FROM `UserDetails`,`Ranks` WHERE Ranks.userID=UserDetails.ID  AND commander='$id' AND active='1' AND rank<>'0' ORDER BY `rank` ASC LIMIT $start,{$conf['users_per_page']}  ";
    	//print $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if (!@mysql_num_rows($q)) {return;}
    	else{
    		$st="";
    		$i=0;
    		while ($row = mysql_fetch_object($q)){
    			$st[$i]=$row;
    			$i++;
    		}
    		return $st;
    	}	
    }
    function getOfficersCount($id){
    	$str="SELECT COUNT(*) FROM `UserDetails`,`Ranks` where Ranks.userID=UserDetails.ID AND commander='$id' AND active='1' AND rank<>'0'";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if ($q){
    		$st = mysql_fetch_array($q);
    		return $st[0];
    	}else{return 0;}
    	//echo "--{$st[0]}---";
    }
    //----------------------------END Officers-----------------------------------------------
    
    //-----------------------------Convertions--------------------------------------------
    function numecho ($str){
    	if ($str=="unranked"){echo $str;}
    	elseif($str=="None"){echo $str;}
    	else{
    		//echo $str;
    		echo number_format($str);
    	}
    }
    function vDate($time){
    	$timenow=time();
    	$timenow=date ("M d, Y",$timenow);
    	$time1=date ("M d, Y",$time);
    	if ($timenow==$time1){
    		$time1=date ("H:i",$time);
    	}
    
    	return $time1;
    }
    function genRandomPas(){
    	$pas=rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
    	return $pas;
    }
    function genUniqueLink(){
    	$time=time();
    	$str=chr( rand(ord('a'),ord('z')) ).chr( rand(ord('a'),ord('z')) ).$time;
    	return $str;
    	/*
    	for ($i=0; $i<strlen($time);$i++){
    		//$str.=chr(ord('a'))
    	}
    	*/
    	
    }
    function genUniqueTxt($n){
    	for ($i=0;$i<$n;$i++){
    		if (rand(0,1)){
    			$str.=chr( rand(ord('A'),ord('Z')) );
    		}else{
    			$str.=chr( rand(ord('0'),ord('9')) );
    		}
    	}
    	return $str;
    	/*
    	for ($i=0; $i<strlen($time);$i++){
    		//$str.=chr(ord('a'))
    	}
    	*/
    	
    }
    
    //-----------------------------End Convertions--------------------------------------------
    //------------------------------Security---------------------------------------------
    function addIP($ip,$userID){
    	$time=time();
    	$str= "INSERT INTO `IPs` (ip,userID,time) VALUES ('$ip','$userID','$time') ";
    	$q = @mysql_query($str);
    	if (!$q) {	print ('Query failed: '.mysql_error());	return; }
    }
    function isIP($ip){
    	return 0;
    	$str="SELECT * FROM `IPs` WHERE ip='$ip' ";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if ($q){
    		$st = mysql_fetch_array($q);
    		return $st[0];
    	}else{return 0;}
    }
    function isIPandUser($ip,$id){
    	
    	$str="SELECT * FROM `IPs` WHERE ip='$ip' AND userID='$id' ";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if ($q){
    		$st = mysql_fetch_array($q);
    		return $st[0];
    	}else{return 0;}
    }
    function isIPNewerThen($ip,$time){
    	//return 0;
    	$time=time()-$time;
    	$str="SELECT * FROM `IPs` WHERE ip='$ip' AND time>'$time' ";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if ($q){
    		$st = mysql_fetch_object($q);
    		return $st;
    	}else{return 0;}
    }
    function getIP($id){
    	$str="select * from `IPs` where  userID='$id' ";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {
    		print ('Query failed: '.mysql_error());
    		return;
    	}
    	if (!@mysql_num_rows($q)) {
    		return 0;
    	}
    	else{
    		$st="";
    		$st = mysql_fetch_object($q);
    		return $st;
    	}	
    }
    function getUserIPs($id){
    	$str="SELECT * FROM `IPs` Where  userID='$id' ORDER BY `time` DESC ";
    	//print $str;
    	$q = @mysql_query($str);
    	if (!$q) {	print ('Query failed: '.mysql_error());	return;	}
    	if (!@mysql_num_rows($q)) { return;	}
    	else{
    		$st="";
    		$i=0;
    		while ($row = mysql_fetch_object($q)){
    			$st[$i]=$row;	$i++;
    		}
    		return $st;
    	}	
    }
    function deleteIP($id){
    	$str = "DELETE FROM  `IPs` WHERE userID='$id'";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	
    }
    function deleteIPByIP($ip){
    	$str = "DELETE FROM  `IPs` WHERE ip='$ip'";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	
    }
    function deleteIPByID($id){
    	$str = "DELETE FROM  `IPs` WHERE ID='$id'";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	
    }
    function logIP($id){
    	global $HTTP_SERVER_VARS,$conf;
    	$ip=$HTTP_SERVER_VARS['REMOTE_ADDR'];
    	if (!isIPandUser($ip,$id)){
    		$IPs=getUserIPs($id);
    		if (count ($IPs)>=$conf["ips_to_hold_per_user"]){
    			//print_r ($IPs);
    			//echo $IPs[count($IPs)-1]->ID;
    			//echo "##".count($IPs);
    			deleteIPByID($IPs[count($IPs)-1]->ID);
    		}
    		addIP($ip,$id);
    	}
    	
    }
    //------------------------------END Security---------------------------------------------
    
    //-----------------------------Atack---------------------------------------------------
    function getAtackCount($userID){
    	$str = "SELECT COUNT(*) FROM `AtackLog` where userID='$userID' ";
    	$q = @mysql_query($str);
    	if ($q){
    		$st = mysql_fetch_array($q);
    		return $st[0];
    	}else{return 0;}
    }
    function getDefenceCount($userID){
    	$str = "SELECT COUNT(*) FROM `AtackLog` where toUserID='$userID' ";
    	$q = @mysql_query($str);
    	if ($q){
    		$st = mysql_fetch_array($q);
    		return $st[0];
    	}else{return 0;}
    }
    function getAllAtacks($userID ){
    	$str="SELECT * FROM `AtackLog` WHERE userID='$userID'";
    	//print $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if (!@mysql_num_rows($q)) {return;}
    	else{
    		$st="";
    		$i=0;
    		while ($row = mysql_fetch_object($q)){
    			$st[$i]=$row;
    			$i++;
    		}
    		return $st;
    	}	
    }
    function getAllDefences($userID ){
    	$str="SELECT * FROM `AtackLog` WHERE toUserID='$userID'";
    	//print $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if (!@mysql_num_rows($q)) {return;}
    	else{
    		$st="";
    		$i=0;
    		while ($row = mysql_fetch_object($q)){
    			$st[$i]=$row;
    			$i++;
    		}
    		return $st;
    	}	
    }
    function getAtack($id){
    	$str="select * from `AtackLog` where  ID='$id' ";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {
    		print ('Query failed: '.mysql_error());
    		return;
    	}
    	if (!@mysql_num_rows($q)) {
    		return 0;
    	}
    	else{
    		$st="";
    		$st = mysql_fetch_object($q);
    		return $st;
    	}	
    }
    function getAtackByAtackerCount($id){
    	$str="SELECT COUNT(*) FROM `AtackLog` where  userID='$id'";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if ($q){
    		$st = mysql_fetch_array($q);
    		return $st[0];
    	}else{return 0;}
    }
    function getAtackByAtacker($id,$page){
    	global $conf;
    	$start=($page-1)*$conf['users_per_page'];
    	//ORDER BY `rank` ASC LIMIT $start,{$conf['users_per_page']} 
    	$str="select * from `AtackLog` where  userID='$id' ORDER BY `time` DESC LIMIT $start,{$conf['users_per_page']}";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {
    		print ('Query failed: '.mysql_error());
    		return;
    	}
    	if (!@mysql_num_rows($q)) {return;}
    	else{
    		$st="";
    		$i=0;
    		while ($row = mysql_fetch_object($q)){
    			$st[$i]=$row;
    			$st[$i]->subject =urldecode ($st[$i]->subject);
    			$st[$i]->text =urldecode ($st[$i]->text);
    			$i++;
    		}
    		return $st;
    	}	
    }
    function getAtackByDefenderCount($id){
    	$str="SELECT COUNT(*) FROM `AtackLog` where  toUserID='$id'";
    	//echo $str;
    	$q = @mysql_query($str);
    	if (!$q) {print ('Query failed: '.mysql_error());	return;	}
    	if ($q){
    		$st = mysql_fetch_array($q);
    		return $st[0];
    	}else{return 0;}
    		$q = @mysql_query("update `UserDetails` set currentSpySkill=currentSpySkill+'1', gold=gold-'$pris' where ID='$user->ID' ");
    	else return 'NO GOLD LEFT!!!';}
    if($type=='unit'){
    	$pris=$user->currentUnitProduction*10000+10000;
    	if($pris <= ($user->gold))
    		$q = @mysql_query("update `UserDetails` set currentUnitProduction=currentUnitProduction+'1', gold=gold-'$pris' where ID='$user->ID' ");
    	else return 'NO GOLD LEFT!!!';}
    } 
    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •