Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and lost your copy? Just file a support ticket through your "My Mods" page.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: New Crime System  (Read 663 times)

BlackVengeance

  • Basic Member
  • *
  • Reputation Power: 18
  • BlackVengeance has no influence.
  • Offline Offline
  • Posts: 22
    • View Profile
New Crime System
« on: January 17, 2011, 10:45:37 AM »
Well i have another mod i would like to post. Tell me what you guys think. And please give me some ideas of things you would like to see!

First replace docrime.php with this

Code: [Select]
<?php
session_start
();
require 
"global_func.php";
if(
$_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require 
"header.php";
$h = new headers;
$h->startheaders();
include 
"mysql.php";
global 
$c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['credits'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
$_GET['c']=abs$_GET['c']);
if(
$ir['jail'] > 0)
{
die(
"<b><font color=darkblue size=+1>You are in Jail for {$ir['jail']} more minute(s).<br />
Until you are out you can't view this page</font></b><br /><br />
<a href='jail.php'>Return to Jail</a>"
);
}
if(
$ir['hospital'] > 0)
{
die(
"<b><font color=red size=+1>You are in the Hospital for {$ir['hosptime']} more minute(s).<br />
Until you are out you can't view this page</font></b><br /><br />
<a href='hospital.php'>Return to Hospital</a>"
);
}
if(!
$_GET['c'])
{
print 
"Invalid crime";
}
else
{
$q=mysql_query("SELECT * FROM newcrimes WHERE crimeID={$_GET['c']}",$c);
$r=mysql_fetch_array($q);
if(
$ir['brave'] < $r['crimeBRAVE'])
{
print 
"You do not have enough Brave to perform this crime.";
$h->endpage();
exit;
}
else
{
$ec="\$sucrate=".str_replace(array("LEVEL","EXP","WILL","IQ"), array($ir['level'], $ir['exp'], $ir['will'], $ir['IQ']),$r['crimePERCFORM']).";";
eval(
$ec);
print 
$r['crimeITEXT'];
$ir['brave']-=$r['crimeBRAVE'];
mysql_query("UPDATE users SET brave={$ir['brave']} WHERE userid=$userid",$c);
$temp1 rand(1,100);
$temp2 $sucrate 3;
$temp3 $temp2 4;
if(
$temp1 <= $temp3)
{
print 
str_replace("{money}",$r['crimeSUCCESSMUNY'],$r['crimeSTEXT']);
$ir['money']+=$r['crimeSUCCESSMUNY'];
$ir['exp']+= ($r['crimeSUCCESSMUNY']/5);
if(
$r['crimeITEM'] > 0)
{
$itemidforcrime $r['crimeITEM'];
mysql_query("INSERT INTO inventory VALUES('',$itemidforcrime,'{$er['userid']}','1','0');",$c);
}
else
{
$award=$r['crimeAWARD'];
$min=$r['crimeSUCCESSMIN'];
$max=$r['crimeSUCCESSMAX'];
$prize=rand($min,$max);
mysql_query("UPDATE users SET $award=$award+$prize,exp={$ir['exp']} WHERE userid=$userid",$c);
mysql_query("UPDATE users SET crimesdone=crimesdone+1 WHERE userid=$userid",$c);
}
}
else
{
print 
$r['crimeFTEXT'];
$where=$r['crimePLACE'];
$fmin=$r['crimeFAILMIN'];
$fmax=$r['crimeFAILMAX'];
$time=rand($fmin,$fmax);
if(
$where == 'hospital')
{
$reason='hospreason';
}
else
{
$reason='jailreason';
}
$text=$r['crimeREASON'];
mysql_query("UPDATE users SET $where=$time WHERE userid=$userid",$c);
mysql_query("UPDATE users SET $reason='$text' WHERE userid=$userid",$c);
}
print 
"<br /><a href='docrime.php?c={$_GET['c']}'>Try Again</a><br />
<a href='criminal.php'>Crimes</a>"
;
}
}

$h->endpage();
?>

After that add this SQL into your MYSQL database

Code: [Select]
CREATE TABLE IF NOT EXISTS `crimes` (
`crimeID` int(11) NOT NULL auto_increment,
`crimeNAME` varchar(255) NOT NULL default '',
`crimeBRAVE` int(11) NOT NULL default '0',
`crimePERCFORM` text NOT NULL,
`crimePLACE` enum('hospital','jail') NOT NULL default 'jail',
`crimeAWARD` enum('money','credits') NOT NULL default 'money',
`crimeSUCCESSMIN` int(11) NOT NULL default '0',
`crimeSUCCESSMAX` int(11) NOT NULL default '0',
`crimeGROUP` int(11) NOT NULL default '0',
`crimeITEXT` text NOT NULL,
`crimeSTEXT` text NOT NULL,
`crimeFTEXT` text NOT NULL,
`crimeFAILMIN` int(11) NOT NULL default '0',
`crimeFAILMAX` int(11) NOT NULL default '0',
`crimeITEM` int(11) NOT NULL default '0',
`crimeREASON` varchar(255) default '',
PRIMARY KEY (`crimeID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=38 ;
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.