Page 1 of 1

Revive players

Posted: Wed Oct 14, 2009 12:09 pm
by skacke
Hello!

How do i make a script that revive all players and set their hp to max? I know how to make a cron, i just don't know the script.

Re: Revive players

Posted: Wed Oct 14, 2009 1:27 pm
by hallsofvallhalla
give me about and hour or so and I will make you a script.

Re: Revive players

Posted: Wed Oct 14, 2009 3:56 pm
by hallsofvallhalla
here is a script for healing players and spell points,

just copy it into your tutorial directory, then browse to it. It will load a blank page.

Code: Select all

<?php
include_once 'connect.php';


?>
 <?php
 
  $selectplayers="SELECT id,hpoints,maxhp,maxspoints,spoints, from players";
     $selectplayers2=mysql_query($selectplayers) or die("could not select players");
      while($selectplayers3=mysql_fetch_array($selectplayers2))
      {
       $health =$selectplayers3[maxhp] * .15;
	   $health = (int)$health;
	   $health = $health + $selectplayers3[hpoints];
	   if ($health > $selectplayers3[maxhp]){$health = $selectplayers3[maxhp];}
	    $spell = $selectplayers3[maxspoints] * .15;
	   $spell = (int)$spell;
	   $spell = $spell + $selectplayers3[spoints];
	   if ($spell > $selectplayers3[maxspoints]){$spell = $selectplayers3[maxspoints];}
	 
	   $updateplayers="Update players set hpoints='$health',spoints='$spell' where id = '$selectplayers3[id]'";
	    mysql_query($updateplayers) or die("Could not update player stats");
	  
	   
      }
    
?>

Re: Revive players

Posted: Wed Oct 14, 2009 4:53 pm
by skacke
hallsofvallhalla wrote:here is a script for healing players and spell points,

just copy it into your tutorial directory, then browse to it. It will load a blank page.

Code: Select all

<?php
include_once 'connect.php';


?>
 <?php
 
  $selectplayers="SELECT id,hpoints,maxhp,maxspoints,spoints, from players";
     $selectplayers2=mysql_query($selectplayers) or die("could not select players");
      while($selectplayers3=mysql_fetch_array($selectplayers2))
      {
       $health =$selectplayers3[maxhp] * .15;
	   $health = (int)$health;
	   $health = $health + $selectplayers3[hpoints];
	   if ($health > $selectplayers3[maxhp]){$health = $selectplayers3[maxhp];}
	    $spell = $selectplayers3[maxspoints] * .15;
	   $spell = (int)$spell;
	   $spell = $spell + $selectplayers3[spoints];
	   if ($spell > $selectplayers3[maxspoints]){$spell = $selectplayers3[maxspoints];}
	 
	   $updateplayers="Update players set hpoints='$health',spoints='$spell' where id = '$selectplayers3[id]'";
	    mysql_query($updateplayers) or die("Could not update player stats");
	  
	   
      }
    
?>
Works like a charm! Thanks :)