Jump to content


Need Coding Help With Web-based Rpg Game!


8 replies to this topic

#1 00king00

    Young Padawan

  • Members
  • Pip
  • 13 posts

Posted 31 March 2007 - 03:30 PM

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 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 31 March 2007 - 04:16 PM

If you're coding it and we don't know anything about it, how can we possibly tell you which file to edit or what is wrong with the script. We are people, not psychics.

Also, if you want help, this is a forum, e-mail isn't neccessary.

#3 00king00

    Young Padawan

  • Members
  • Pip
  • 13 posts

Posted 31 March 2007 - 04:20 PM

Ok thanx for your reply! But I thought maybe someone here had the same problem before and he/she got a solve for it!

Anyway. I am think now about the crontab file to solve the problem! Any idea?

#4 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 31 March 2007 - 07:14 PM

not really going to write out the entire code for you or anything but why not just do it with a timestamp of sorts?

Once so much time has gone by, then the player can take another turn.

#5 00king00

    Young Padawan

  • Members
  • Pip
  • 13 posts

Posted 01 April 2007 - 03:02 AM

Thanx but what do you mean by timestamp ?

#6 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 01 April 2007 - 10:27 AM

http://unix.cms.gre....s/timestamp.php

#7 00king00

    Young Padawan

  • Members
  • Pip
  • 13 posts

Posted 01 April 2007 - 10:56 AM

Thanx mate!

But that code dosn't solve the problem with (time.php)

I will write down a part of the (vsys.php) regarding the coding of the game script, and maybe it will give you a hint!

Here:

 //echo "$str<br>";
 //return;
 $q = @mysql_query($str);
 if (!$q) {
  print ('Query failed: '.mysql_error());
  return;
 }
}

function setLastSeen($id, $date){
 updateUser($id," lastTurnTime = '$date' ");
}

function setLastTurnTime($date){
 updateMercenary(" lastTurnTime = '$date' ");
}
function deleteUserWeapon($id,$weaponID=""){
 if ($weaponID ){$str2=" AND weaponID='$weaponID' ";}
 $str = "DELETE FROM  `Weapon` WHERE userID='$id' $str2";
 //echo $str;
 $q = @mysql_query($str);
 if (!$q) {print ('Query failed: '.mysql_error()); return; }
}
function clearRanks($id){
 $str = "update `Ranks` set rank ='0', strikeActionRank  ='0',defenceActionRank   ='0',covertActionRank   ='0' WHERE userID='$id' ";
 //echo $str;
 $q = @mysql_query($str);
 if (!$q) {print ('Query failed: '.mysql_error()); return; }
}
function deleteUser($id){
 $str = "DELETE FROM  `UserDetails` WHERE ID='$id'";
 //echo $str;
 $q = @mysql_query($str);
 $str = "DELETE FROM  `Ranks` WHERE userID='$id'";
 $q = @mysql_query($str);
 deleteUserWeapon($id);
 deleteIP($id);
 deleteAtacksOfUser($id);
 deleteSpyLogsOfUser($id);
 deleteMessagesOfUser($id);
 $str = "update `UserDetails` set commander=0 WHERE commander='$id' ";
 $q = @mysql_query($str);
 /*
 if (!$q) {
  print ('Query failed: '.mysql_error());
  return;
 }*/
}
function deleteOldUsers(){
 $users=getOldUsers();
 //echo 1;
 for ($i=0;$i<count($users);$i++){
  if (($users[$i]->active==1)||((!$users[$i]->active)))
   deleteUser($users[$i]->ID);
 }
 //echo 2;
}
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 ([email="!@mysql_num_rows($q"]!@mysql_num_rows($q[/email])) {
  return 0;
 }
 else{
  $st="";
  $st = mysql_fetch_object($q);
  return $st;
 } 
}

Regards,

#8 evertonian7uk

    Young Padawan

  • Members
  • Pip
  • 249 posts

Posted 02 April 2007 - 03:53 AM

Kings of chaos works using time.php files

you need to set up crons in cpanel, then point them at the time files.

this is pretty simple to do.

if you need more help, let me know i have this script ;)

#9 00king00

    Young Padawan

  • Members
  • Pip
  • 13 posts

Posted 02 April 2007 - 11:05 AM

Cool thanx mate..Hope this will works with my script!

I will try and I will give you a reply

Thanx again!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users