Jump to content

Recommended Posts

Been looking for a couple days now hard to find exactly what I'm looking for.  Is there a hospital mod for allowing people to either heal themselves or others out of the hospital for cash or crystals? Thanks for helping in advance.  And sorry if I posted this in the wrong spot.

Share this post


Link to post
Share on other sites
Posted (edited)

Add this in your hospital page - 

	$healcost = $r['level'] * 500;
$cf = money_formatter($healcost);
	 
	echo "[<a href='hospitalheal.php?ID={$r['userid']}'>Heal for {$healcost}</a>]";
	

 

create hospitalheal.php

	<?php
define('PAGE_HEADER', 'Hospital: Heal');
	require_once('globals.php');
echo "<h3><u>Hospital: Heal</u></h3>";
if ($ir['hopsital'])
{
    echo "You cannot heal  while in hospital.";
    exit($h->endpage());
}
$_GET['ID'] =
        (isset($_GET['ID']) && is_numeric($_GET['ID']))
                ? abs(intval($_GET['ID'])) : 0;
$hospital_q =
        $db->query(
                "SELECT `userid`, `hospital`, `level`, `username`
                 FROM `users`
                 WHERE `userid` = {$_GET['ID']}");
if ($db->num_rows($hospital_q) == 0)
{
    $db->free_result($hospital_q);
    echo "Invalid user.";
    exit($h->endpage());
}
$r = $db->fetch_row($hospital_q);
$db->free_result($hospital_q);
if (!$r['hospital'])
{
    echo "That user is not in hospital!";
    exit($h->endpage());
}
	$cost = $r['level'] * 500;
$cf = money_formatter($r['level'] * 500);
if ($ir['money'] < $cost)
{
    echo "Sorry, you do not have enough money to heal out {$r['username']}. You need {$cf}.";
}
	echo "You successfully healed {$r['username']} out of hospital for {$cf}.";
$db->query(
        "UPDATE `users`
         SET `money` = `money` - {$cost}
         WHERE `userid` = $userid");
$db->query(
        "UPDATE `users`
         SET `hospital` = 0
         WHERE `userid` = {$r['userid']}");
event_add($r['userid'],
        "<a href='viewuser.php?u={$ir['userid']}'>{$ir['username']}</a> healed you out of hospital.",
        $c);
$h->endpage();
	?>
	

 

Hope this helps.

Edited by Shades
  • Like 1

Share this post


Link to post
Share on other sites

Aha didn’t realise. Since my broadband is down! EE Fibre Optic taking the piss once again seriously second time this month my broadband has been down. I would have converted it for you as I am on my phone it would be very difficult for me to convert it. I shall however later convert it for you. Or if you can not wait I believe there is a conversion tutorial made by MTG somewhere 

Share this post


Link to post
Share on other sites

Tested and sure ain't guaranteeing perfection here..

hospital.php [v1]

<?php

$globals = __DIR__.'/globals.php';
if (file_exists($globals)) {
    require_once $globals;
} else {
    session_start();
    if (!array_key_exists('loggedin', $_SESSION) or !$_SESSION['loggedin']) {
        exit(header('Location: /login.php'));
    }
    $userid = array_key_exists('userid', $_SESSION) && ctype_digit($_SESSION['userid']) && $_SESSION['userid'] > 0 ? $_SESSION['userid'] : null;
    if (!$userid) {
        exit(header('Location: /login.php'));
    }
    require_once __DIR__.'/mysql.php';
    global $c;
    require_once __DIR__.'/global_func.php';
    require_once __DIR__.'/header.php';
    $selectMe = mysql_query('SELECT u.*, us.*
        FROM users AS u
        INNER JOIN userstats AS us ON u.userid = us.userid
        WHERE u.userid = '.$userid, $c) or exit(mysql_error());
    if (!mysql_num_rows($selectMe)) {
        session_unset();
        session_destroy();
        exit(header('Location: /login.php'));
    }
    $ir = mysql_fetch_assoc($selectMe);
    check_level();
    $fm = money_formatter($ir['money']);
    $cm = money_formatter($ir['crystals'], '');
    $lv = date('F j, Y, g:i a', $ir['laston']);
    $h = new headers();
    $h->startheaders();
    $h->userdata($ir, $lv, $fm, $cm);
    $h->menuarea();
}
$_GET['heal'] = array_key_exists('heal', $_GET) && ctype_digit($_GET['heal']) && $_GET['heal'] > 0 ? $_GET['heal'] : null;
echo '<h3><u>Hospital</u></h3>';
if (null !== $_GET['heal']) {
    if ($ir['hospital'] < 1) {
        if ($_GET['heal'] != $ir['userid']) {
            $selectPatient = mysql_query('SELECT userid, username, hospital, level, gender FROM users WHERE userid = '.$_GET['heal'], $c) or exit(mysql_error());
            if (mysql_num_rows($selectPatient)) {
                $row = mysql_fetch_assoc($selectPatient);
                $name = '<a href="viewuser.php?u='.$row['userid'].'">'.stripslashes(htmlspecialchars($row['username'])).'</a>';
                if ($row['hospital'] > 0) {
                    $cost = $row['hospital'] * $row['level'];
                    $himHer = 'Male' == $row['gender'] ? 'him' : 'her';
                    $extra = 'To heal '.$name.' with '.$row['hospital'].' minute'.(1 == $row['hospital'] ? '' : 's').' remaining, it would cost $'.number_format($cost);
                    if ($ir['money'] >= $cost) {
                        if (array_key_exists('ans', $_GET)) {
                            mysql_query('UPDATE users SET hospital = 0, hp = maxhp WHERE userid = '.$row['userid'], $c) or exit(mysql_error());
                            mysql_query('UPDATE users SET money = money - '.$cost.' WHERE userid = '.$ir['userid'], $c) or exit(mysql_error());
                            event_add($row['userid'], 'You were healed by <a href="viewuser.php?u='.$ir['userid'].'">'.$ir['username'].'</a>');
                            echo 'You\'ve healed '.$name.' for $'.number_format($cost);
                        } else {
                            echo $extra.'<br>
                            <a href="hospital.php?heal='.$row['userid'].'&ans=yes">Ok, heal '.$himHer.'</a>';
                        }
                    } else {
                        echo 'You don\'t have enough money. '.$extra;
                    }
                } else {
                    echo $name.' isn\'t in hospital';
                }
            } else {
                echo 'Your intended patient doesn\'t exist';
            }
        } else {
            echo 'You can\'t heal yourself';
        }
    } else {
        echo 'You can\'t heal others whilst in hospital';
    }
}
$selectPatients = mysql_query('SELECT userid, username, hospital, hospreason, level FROM users WHERE hospital > 0 ORDER BY hospital DESC', $c) or exit(mysql_error()); ?>
<table class="table">
    <thead>
        <tr>
            <th>Patient</th>
            <th>Level</th>
            <th>Time</th>
            <th>Reason</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody><?php
if (!mysql_num_rows($selectPatients)) {
    ?>
        <tr>
            <td colspan="5" class="center">There are currently no patients</td>
        </tr><?php
} else {
        while ($row = mysql_fetch_assoc($selectPatients)) {
            ?>
        <tr>
            <td><a href="viewuser.php?u=<?php echo $row['userid']; ?>"><?php echo stripslashes(htmlspecialchars($row['username'])); ?></a></td>
            <td><?php echo number_format($row['level']); ?></td>
            <td><?php echo $row['hospital'].' minute'.(1 == $row['hospital'] ? '' : 's'); ?></td>
            <td><?php echo stripslashes($row['hospreason']); ?></td>
            <td><?php
            if (!$ir['hospital']) {
                ?>
                <a href="hospital.php?heal=<?php echo $row['userid']; ?>">Heal</a><?php
            } ?>
            </td>
        </tr><?php
        }
    } ?>
    </tbody>
</table><?php
$h->endpage();


hospital.php [v2]

<?php
require_once __DIR__.'/globals.php';
$_GET['heal'] = array_key_exists('heal', $_GET) && ctype_digit($_GET['heal']) && $_GET['heal'] > 0 ? $_GET['heal'] : null;
echo '<h3><u>Hospital</u></h3>';
if (null !== $_GET['heal']) {
    if ($ir['hospital'] < 1) {
        if ($_GET['heal'] != $ir['userid']) {
            $selectPatient = $db->query('SELECT userid, username, hospital, level, gender FROM users WHERE userid = '.$_GET['heal']);
            if ($db->num_rows($selectPatient)) {
                $row = $db->fetch_row($selectPatient);
                $name = '<a href="viewuser.php?u='.$row['userid'].'">'.stripslashes(htmlspecialchars($row['username'])).'</a>';
                if ($row['hospital'] > 0) {
                    $cost = $row['hospital'] * $row['level'];
                    $himHer = 'Male' == $row['gender'] ? 'him' : 'her';
                    $extra = 'To heal '.$name.' with '.$row['hospital'].' minute'.(1 == $row['hospital'] ? '' : 's').' remaining, it would cost $'.number_format($cost);
                    if ($ir['money'] >= $cost) {
                        if (array_key_exists('ans', $_GET)) {
                            $db->query('UPDATE users SET hospital = 0, hp = maxhp WHERE userid = '.$row['userid']);
                            $db->query('UPDATE users SET money = money - '.$cost.' WHERE userid = '.$ir['userid']);
                            event_add($row['userid'], 'You were healed by <a href="viewuser.php?u='.$ir['userid'].'">'.$ir['username'].'</a>');
                            echo 'You\'ve healed '.$name.' for $'.number_format($cost);
                        } else {
                            echo $extra.'<br>
                            <a href="hospital.php?heal='.$row['userid'].'&ans=yes">Ok, heal '.$himHer.'</a>';
                        }
                    } else {
                        echo 'You don\'t have enough money. '.$extra;
                    }
                } else {
                    echo $name.' isn\'t in hospital';
                }
            } else {
                echo 'Your intended patient doesn\'t exist';
            }
        } else {
            echo 'You can\'t heal yourself';
        }
    } else {
        echo 'You can\'t heal others whilst in hospital';
    }
}
$selectPatients = $db->query('SELECT userid, username, hospital, hospreason, level FROM users WHERE hospital > 0 ORDER BY hospital DESC'); ?>
<table class="table">
    <thead>
        <tr>
            <th>Patient</th>
            <th>Level</th>
            <th>Time</th>
            <th>Reason</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody><?php
if (!$db->num_rows($selectPatients)) {
    ?>
        <tr>
            <td colspan="5" class="center">There are currently no patients</td>
        </tr><?php
} else {
        while ($row = $db->fetch_row($selectPatients)) {
            ?>
        <tr>
            <td><a href="viewuser.php?u=<?php echo $row['userid']; ?>"><?php echo stripslashes(htmlspecialchars($row['username'])); ?></a></td>
            <td><?php echo number_format($row['level']); ?></td>
            <td><?php echo $row['hospital'].' minute'.(1 == $row['hospital'] ? '' : 's'); ?></td>
            <td><?php echo stripslashes($row['hospreason']); ?></td>
            <td><?php
            if (!$ir['hospital']) {
                ?>
                <a href="hospital.php?heal=<?php echo $row['userid']; ?>">Heal</a><?php
            } ?>
            </td>
        </tr><?php
        }
    } ?>
    </tbody>
</table><?php
$h->endpage();

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

thanks ill test it :) no problems with that :) let ya know what happens thanks so much 

ok the only bug im finding is when you click heal it shows the name of a different player and says they are not in the hospital

but its amazing thank you 

first pic it when you click hospital second pic is what i got when i clicked heal.  i have looked it over and cant see where its wrong at .

Opera Snapshot_2019-07-27_214046_battleforobsidianmoon.com.png

Opera Snapshot_2019-07-27_214106_battleforobsidianmoon.com.png

Share this post


Link to post
Share on other sites

Maybe Remove healing  Item from healers inv when they use the HEAL. and if user doesnt have anything to heal anyone with the the HEAL option isnt displayed 

Share this post


Link to post
Share on other sites

Still happening lol but heres a better idea of whats up.  when you click the address bar it gives the wrong id if you get the players id and plug it in the bar you can heal them.

heal 1.png

heal 2.png

heal 3.png

heal 4.png

heal 5.png

Share this post


Link to post
Share on other sites
Posted (edited)

is it healing both users at same time ?

 

Edited by Uridium

Share this post


Link to post
Share on other sites

I edited the code. It was displaying the hospital minutes in the "Heal" URL. It now displays userid.
If you've definitely updated from my edits, you shouldn't be getting that issue

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...