rednspirited Posted July 19, 2019 Posted July 19, 2019 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. Quote
Magictallguy Posted July 19, 2019 Posted July 19, 2019 Not to my knowledge, but one can be created for you 1 Quote
rednspirited Posted July 19, 2019 Author Posted July 19, 2019 So would you be volunteering to help me then ? cant blame me for asking :P 1 Quote
Magictallguy Posted July 20, 2019 Posted July 20, 2019 S'pose I can spare the time ? MCC Lite, aye? 1 Quote
Shades Posted July 21, 2019 Posted July 21, 2019 (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 July 21, 2019 by Shades 1 Quote
Magictallguy Posted July 22, 2019 Posted July 22, 2019 As this topic was tagged with mccodes-lite, the code above won't work without conversion Quote
Shades Posted July 22, 2019 Posted July 22, 2019 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 Quote
Magictallguy Posted July 23, 2019 Posted July 23, 2019 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(); 1 1 Quote
rednspirited Posted July 29, 2019 Author Posted July 29, 2019 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 . Quote
Uridium Posted July 30, 2019 Posted July 30, 2019 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 Quote
rednspirited Posted July 30, 2019 Author Posted July 30, 2019 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. Quote
Uridium Posted July 30, 2019 Posted July 30, 2019 (edited) is it healing both users at same time ? Edited July 30, 2019 by Uridium Quote
Magictallguy Posted July 30, 2019 Posted July 30, 2019 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 1 Quote
rednspirited Posted July 30, 2019 Author Posted July 30, 2019 I did but it was still doing it ? Quote
Magictallguy Posted July 31, 2019 Posted July 31, 2019 My tests show this working as intended 1 Quote
rednspirited Posted July 31, 2019 Author Posted July 31, 2019 ok ill retry :) this time it worked dont know what my silly self did wrong first time :) Quote
rednspirited Posted August 12, 2019 Author Posted August 12, 2019 ok i up graded to v2 did shades mod but this is what i get. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.