michaelbraden Posted February 3, 2014 Share Posted February 3, 2014 I want to add a buy out of jail and hospital function, I got no idea how this is done, Please can someone give me the code I have GRPG silentmafia.co.uk Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted February 3, 2014 Share Posted February 3, 2014 have you tried? if so, what have done? What errors if any? have you looked around your scripts to see how similar things are done? Quote Link to comment Share on other sites More sharing options...
sniko Posted February 3, 2014 Share Posted February 3, 2014 (edited) have you tried? if so, what have done? What errors if any? have you looked around your scripts to see how similar things are done? ██ This x2 Edited February 3, 2014 by sniko Quote Link to comment Share on other sites More sharing options...
michaelbraden Posted February 3, 2014 Author Share Posted February 3, 2014 I believe the script to refill energy and things would be similar??? But dont know what to put :/ Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted February 3, 2014 Share Posted February 3, 2014 (edited) well I don't know grpg off the top of my head but I'm pretty sure you can add a link in the jail and hospital like echo "<a href='?release=#'>Release </a>"; just change the # with the players id. Then you may want to check that the link was clicked using something like: //make sure the array is set && make sure the right key for the array exists && make sure that its an int for tye players id if(isset($_GET["release"]) && array_key_exists("release", $_GET) && abs((int) $_GET["release"])) { //execute the release here } Now its your duty to make it work :) Edited February 3, 2014 by KyleMassacre spellng typo, oops Quote Link to comment Share on other sites More sharing options...
Vaz Posted February 4, 2014 Share Posted February 4, 2014 (edited) if($_GET['buyout'] != NULL && $user_class->points > floor($user_class->hospital / 60)){ $result = mysql_query("UPDATE `grpgusers` SET `hospital` = '0', `points` = '".($user_class->points - floor($user_class->hospital / 60))."' WHERE `id` = '".$user_class->id."'"); } Add the ?buyout=whatever link to your hospital page, and adapt for prison Edited February 4, 2014 by Vaz Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted February 4, 2014 Share Posted February 4, 2014 if($_GET['buyout'] != NULL && $user_class->points > floor($user_class->hospital / 60)){ $result = mysql_query("UPDATE `grpgusers` SET `hospital` = '0', `points` = '".($user_class->points - floor($user_class->hospital / 60))."' WHERE `id` = '".$user_class->id."'"); } Add the ?buyout=whatever link to your hospital page, and adapt for prison Well, thats a start but now you are just adding to the problem of most of these scripts for these engines. Granted your not using $_GET for anything in the database but its still promoting negligent security practices. Also you are passing ints as strings in the database, why when they are ints and not varchar, text, etc? But here we will go with yours just a bit cleaned up: //Always make sure that your gets and posts are set, but now whats are value for this key? anyways we'll just let it be if(isset($_GET['buyout']) && $user_class->points > floor($user_class->hospital / 60)) { $result = "UPDATE `grpgusers` SET `hospital` = 0, `points` = ".($user_class->points - floor($user_class->hospital / 60))." WHERE `id` = ".$user_class->id; mysql_query($result); } Quote Link to comment Share on other sites More sharing options...
Vaz Posted February 4, 2014 Share Posted February 4, 2014 Points noted, but $_GET['buyout'] isn't used at all other than to see if it exists, so there is no issue with it, still the exact same end result Quote Link to comment Share on other sites More sharing options...
MNG Posted February 4, 2014 Share Posted February 4, 2014 If I am correct the use point option has the buy out of the hospital, so use kyle post and add the link echo "<a href='LINK'>Release </a>"; Quote Link to comment Share on other sites More sharing options...
Newbie Posted February 4, 2014 Share Posted February 4, 2014 might of read original post wrong but if i have then owell lol if(isset($_GET['admin']) == "prison") { if($user_class->admin == 1 ) { if($user_class->jail == 0) { echo Message("You're not in prison."); } else { $result = mysql_query("UPDATE `grpgusers` SET `jail` = '0' WHERE `id`='".$_SESSION['id']."'"); echo Message("You used your corruption powers to get out of prison."); } } } <a href='spendpoints.php?admin=prison'>Get Out of Prison</a><br /> Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted February 4, 2014 Share Posted February 4, 2014 might of read original post wrong but if i have then owell lol if(isset($_GET['admin']) == "prison") { if($user_class->admin == 1 ) { if($user_class->jail == 0) { echo Message("You're not in prison."); } else { $result = mysql_query("UPDATE `grpgusers` SET `jail` = '0' WHERE `id`='".$_SESSION['id']."'"); echo Message("You used your corruption powers to get out of prison."); } } } <a href='spendpoints.php?admin=prison'>Get Out of Prison</a><br /> I think he wants it so players can spend currency to get out themselves Quote Link to comment Share on other sites More sharing options...
Newbie Posted February 4, 2014 Share Posted February 4, 2014 ah well use already took care of that now he has one for admins too :P Quote Link to comment Share on other sites More sharing options...
jcvenom Posted February 4, 2014 Share Posted February 4, 2014 //You should already have a form with the method of GET setup, to execute statement if(isset($_GET['buyout']) && $user_class->points > floor($user_class->hospital / 60)){ //Time to execute the statement $query = "UPDATE `grpgusers` SET `hospital` = 0, `points` = ".mysql_real_escape_string(($user_class->points - floor($user_class->hospital / 60)))." WHERE `id` = ".$user_class->id; mysql_query($query) or die(mysql_error()); //End of query echo Message("what ever you want here!"); } Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted February 5, 2014 Share Posted February 5, 2014 //You should already have a form with the method of GET setup, to execute statement if(isset($_GET['buyout']) && $user_class->points > floor($user_class->hospital / 60)){ //Time to execute the statement $query = "UPDATE `grpgusers` SET `hospital` = 0, `points` = ".mysql_real_escape_string(($user_class->points - floor($user_class->hospital / 60)))." WHERE `id` = ".$user_class->id; mysql_query($query) or die(mysql_error()); //End of query echo Message("what ever you want here!"); } If your going to use a form I would use post unless for some strange reason you cannot use post. Also why mres an int? Especially in this case your "points" is and should be an (int) in your database unless you have done something horribly wrong to your database. Also it really doesn't need to be "secured" since its not user input and your not displaying info from the db. Now would this be bad? No. Practical? No. its just adding some unnecessary strain by calling a function that doesn't need to be there. Now back on topic, If the OP takes all of these examples and puts the pieces together just right he has what he is looking for and I appreciate all the spoon feeding you guys have done :p Quote Link to comment Share on other sites More sharing options...
jcvenom Posted February 5, 2014 Share Posted February 5, 2014 If your going to use a form I would use post unless for some strange reason you cannot use post. Also why mres an int? Especially in this case your "points" is and should be an (int) in your database unless you have done something horribly wrong to your database. Also it really doesn't need to be "secured" since its not user input and your not displaying info from the db. Now would this be bad? No. Practical? No. its just adding some unnecessary strain by calling a function that doesn't need to be there. Now back on topic, If the OP takes all of these examples and puts the pieces together just right he has what he is looking for and I appreciate all the spoon feeding you guys have done :p My bad sorry you don't need a form it should be ?action=buyout or something like that Quote Link to comment Share on other sites More sharing options...
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.