Jump to content
MakeWebGames

Recommended Posts

Posted

I have the mod that removes crimeSUCESSMUNY and replaces it with a minmoney and maxmoney value for entering a high and low amount for crime payouts. My question is, how can I display whatever random amount of money is earned through the success text..through the use of the staff panel edit crime page..

For example..when I'm making a crime through the staff panel..I enter in all the info, etc. I want to have a crime payout anywhere from $5-$10. In my success text, I'd like it to say: "You searched around and found $7." It's easy to just type in the success text that you found $7, but since I'm using a random number for my payout, I can't necessarily type a flat rate, since I don't know what that would be.

I was wondering if there was some code I could enter into the success text box to have it display whatever value is given to the result. I've tried all different variations of the values I could think of and nothing is working for me..anyone know how to make this work?

Posted

Re: Displaying a random $ within Crime text

$payout = mt_rand($r['crimeMIN'], $r['crimeMAX']);

echo str_replace('[+money+]', $payout, $r['crimeSUCCESSTEXT']);

You might need to show some more code..

And to display the payout jus put [+money+] inside your successtext

Posted

Re: Displaying a random $ within Crime text

I'll try what you have, but here's my docrime.php:

Basically I have:

print str_replace("{money}",$r['crimeSUCCESSMUNY'],"<font color='green'>

{$r['crimeSTEXT']}

</font>");

$muny = rand($r['crimeMINMONEY'],$r['crimeMAXMONEY']);

 

<?php
$macropage="docrime.php?c={$_GET['c']}";
include "globals.php";
if($ir['jail'] or $ir['hospital']) { die("You can't do that while in jail or hospital."); }
$_GET['c']=abs((int) $_GET['c']);
if(!$_GET['c'])
{
print "Invalid crime";
}
else
{
$q=$db->query("SELECT * FROM crimes WHERE crimeID={$_GET['c']}",$c);
$r=$db->fetch_row($q);
if($ir['brave'] < $r['crimeBRAVE'])
{
print "You don't have enough Intensity to perform this action.";
}
else
{
$ec="\$sucrate=".str_replace(array("LEVEL","CRIMEXP","EXP","WILL","IQ"), array($ir['level'], $ir['crimexp'], $ir['exp'], $ir['will'], $ir['IQ']),$r['crimePERCFORM']).";";
eval($ec);
print "
[b]{$r['crimeITEXT']}[/b]";
$ir['brave']-=$r['crimeBRAVE'];
$db->query("UPDATE users SET brave={$ir['brave']} WHERE userid=$userid",$c);
if(rand(1,100) <= $sucrate)
{
print str_replace("{money}",$r['crimeSUCCESSMUNY'],"<font color='green'>
[b]{$r['crimeSTEXT']}[/b]

</font>");
$muny = rand($r['crimeMINMONEY'],$r['crimeMAXMONEY']);
$ir['money']+=$muny;
$ir['crystals']+=$r['crimeSUCCESSCRYS'];
$ir['exp']+=(int) ($r['crimeSUCCESSMUNY']/8);
$db->query("UPDATE users SET money={$ir['money']}, crystals={$ir['crystals']}, exp=exp+{$r['crimeXP']},crimexp=crimexp+{$r['crimeXP']} WHERE userid=$userid",$c);

if($r['crimeSUCCESSITEM'])
{
 item_add($userid, $r['crimeSUCCESSITEM'], 1);
}
}
else
{
if(rand(1, 2) == 1)
{
print "<font color='orange'>

[b]{$r['crimeFTEXT']}[/b]

</font>";
}
else
{
print "<font color='red'>
[b]{$r['crimeJTEXT']} 

[/b]

</font>";
$db->query("UPDATE `users` SET `jail` = '$r[crimeJAILTIME]', `jail_reason` = '$r[crimeJREASON]' WHERE `userid` = '$userid'");

}
}

print "
[url='docrime.php?c={$_GET[']Try again.[/url]

[url='criminal.php']Choose a different action.[/url]";
}
}


$h->endpage();
?>
Posted

Re: Displaying a random $ within Crime text

Awesome, I changed my code around a bit like you had yours structured and it works like a charm! Thanks! +1 8-)

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