Revive players

Post all your tuts or request for tuts here.
Post Reply
skacke
Posts: 38
Joined: Mon Oct 12, 2009 10:08 pm

Revive players

Post 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.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Revive players

Post by hallsofvallhalla »

give me about and hour or so and I will make you a script.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Revive players

Post 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");
	  
	   
      }
    
?>
skacke
Posts: 38
Joined: Mon Oct 12, 2009 10:08 pm

Re: Revive players

Post 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 :)
Post Reply

Return to “Tutorials”