Jump to content
MakeWebGames

How to Buy out of hosp and jail!


michaelbraden

Recommended Posts

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 by KyleMassacre
spellng typo, oops
Link to comment
Share on other sites

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 by Vaz
Link to comment
Share on other sites

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);
}
Link to comment
Share on other sites

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 />

Link to comment
Share on other sites

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

Link to comment
Share on other sites

//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!");
}
Link to comment
Share on other sites

//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

Link to comment
Share on other sites

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
Link to comment
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...