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.
Revive players
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Revive players
give me about and hour or so and I will make you a script.
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Revive players
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.
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
Works like a charm! Thankshallsofvallhalla 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"); } ?>
