Jump to content
MakeWebGames

Adding crimes and cities in v2


mr smith

Recommended Posts

Re: Adding crimes and cities in v2

this should work:

replace staff_crimes.php with this:

<?php
include "sglobals.php";
if($ir['user_level'] > 2)
{
die("403");
}
//This contains course stuffs
switch($_GET['action'])
{
case 'newcrime': new_crime_form(); break;
case 'newcrimesub': new_crime_submit(); break; 
case 'editcrime': edit_crime_begin(); break;
case 'editcrimeform': edit_crime_form(); break;
case 'editcrimesub': edit_crime_sub(); break;
case 'delcrime': delcrime(); break; 
case 'newcrimegroup': new_crimegroup_form(); break;
case 'newcrimegroupsub': new_crimegroup_submit(); break;
case 'editcrimegroup': edit_crimegroup_begin(); break;
case 'editcrimegroupform': edit_crimegroup_form(); break;
case 'editcrimegroupsub': edit_crimegroup_sub(); break;
case 'delcrimegroup': delcrimegroup(); break;
case 'reorder': reorder_crimegroups(); break;
default: print "Error: This script requires an action."; break;
}
function new_crime_form()
{
global $ir, $c, $db;
print "Adding a new crime.

<form action='staff_crimes.php?action=newcrimesub' method='post'>
Name: <input type='text' name='name' />

Brave Cost: <input type='text' name='brave' />

Success % Formula: <input type='text' name='percform' value='((WILL*0.8)/2.5)+(LEVEL/4)' />

Success Money: <input type='text' name='money' />

Success Crystals: <input type='text' name='crys' />

Success Item: ".item2_dropdown($c, 'item')."

Group: ".crimegroup_dropdown($c,'group')."

Initial Text: <textarea rows=4 cols=40 name='itext'  /></textarea>

Success Text: <textarea rows=4 cols=40 name='stext' /></textarea>

Failure Text: <textarea rows=4 cols=40 name='ftext' /></textarea>

Jail Text: <textarea rows=4 cols=40 name='jtext' /></textarea>

Jail Time: <input type='text' name='jailtime' />

Jail Reason: <input type='text' name='jailreason' />

Crime XP Given: <input type='text' name='crimexp' />

<input type='submit' value='Create Crime' /></form>";
}
function new_crime_submit()
{
global $ir,$c,$userid, $db;
if($_POST['itemon'] != "on") { $_POST['item']=0; }
$db->query("INSERT INTO crimes (crimeNAME, crimeBRAVE, crimePERCFORM, crimeSUCCESSMUNY, crimeSUCCESSCRYS, crimeSUCCESSITEM, crimeGROUP, crimeITEXT, crimeSTEXT, crimeFTEXT, crimeJTEXT, crimeJAILTIME, crimeJREASON, crimeXP) VALUES( '{$_POST['name']}', '{$_POST['brave']}', '{$_POST['percform']}', '{$_POST['money']}', {$_POST['crys']}, {$_POST['item']}, '{$_POST['group']}', '{$_POST['itext']}', '{$_POST['stext']}', '{$_POST['ftext']}', '{$_POST['jtext']}', {$_POST['jailtime']}, '{$_POST['jailreason']}', {$_POST['crimexp']})");
print "Crime created!";
stafflog_add("Created crime {$_POST['name']}");
} 
function edit_crime_begin()
{
global $ir,$c,$h,$userid,$db;
print "<h3>Editing Crime</h3>
You can edit any aspect of this crime. 

<form action='staff_crimes.php?action=editcrimeform' method='post'>
Crime: ".crime_dropdown($c,'crime')."

<input type='submit' value='Edit Crime' /></form>";
}
function edit_crime_form()
{
global $ir,$c,$h,$userid,$db;

$d=$db->query("SELECT * FROM crimes WHERE crimeID={$_POST['crime']}");
$itemi=$db->fetch_row($d);
print "<h3>Editing Crime</h3>
<form action='staff_crimes.php?action=editcrimesub' method='post'>
<input type='hidden' name='crimeID' value='{$_POST['crime']}' />

Name: <input type='text' name='crimeNAME' value='{$itemi['crimeNAME']}' />

Brave Cost: <input type='text' name='crimeBRAVE' value='{$itemi['crimeBRAVE']}' />

Success % Formula: <input type='text' name='crimePERCFORM' value='{$itemi['crimePERCFORM']}' />

Success Money: <input type='text' name='crimeSUCCESSMUNY' value='{$itemi['crimeSUCCESSMUNY']}' />

Success Crystals: <input type='text' name='crimeSUCCESSCRYS' value='{$itemi['crimeSUCCESSCRYS']}' />

Success Item: ".item2_dropdown($c, 'crimeSUCCESSITEM', $itemi['crimeSUCCESSITEM'])."

Group: ".crimegroup_dropdown($c,'crimeGROUP', $itemi['crimeGROUP'])."

Initial Text: <textarea rows=4 cols=40 name='crimeITEXT'  />{$itemi['crimeITEXT']}'</textarea>

Success Text: <textarea rows=4 cols=40 name='crimeSTEXT' />{$itemi['crimeSTEXT']}</textarea>

Failure Text: <textarea rows=4 cols=40 name='crimeFTEXT' />{$itemi['crimeFTEXT']} </textarea>

Jail Text: <textarea rows=4 cols=40 name='crimeJTEXT' />{$itemi['crimeJTEXT']} </textarea>

Jail Time: <input type='text' name='crimeJAILTIME' value='{$itemi['crimeJAILTIME']}' />

Jail Reason: <input type='text' name='crimeJREASON' value='{$itemi['crimeJREASON']}' />

Crime XP Given: <input type='text' name='crimeXP' value='{$itemi['crimeXP']}' />

<input type='submit' value='Edit Crime' /></form>";
}
function edit_crime_sub()
{
global $ir,$c,$h,$userid, $db;
$db->query("UPDATE crimes SET  crimeNAME='{$_POST['crimeNAME']}', crimeBRAVE='{$_POST['crimeBRAVE']}', crimePERCFORM='{$_POST['crimePERCFORM']}', crimeSUCCESSMUNY='{$_POST['crimeSUCCESSMUNY']}', 
crimeSUCCESSCRYS='{$_POST['crimeSUCCESSCRYS']}', 
crimeSUCCESSITEM='{$_POST['crimeSUCCESSITEM']}', crimeGROUP='{$_POST['crimeGROUP']}', crimeITEXT='{$_POST['crimeITEXT']}', crimeSTEXT='{$_POST['crimeSTEXT']}', crimeFTEXT='{$_POST['crimeFTEXT']}', crimeJTEXT='{$_POST['crimeJTEXT']}', crimeJAILTIME={$_POST['crimeJAILTIME']}, crimeJREASON='{$_POST['crimeJREASON']}', crimeXP={$_POST['crimeXP']} WHERE crimeID={$_POST['crimeID']}");
print "Crime edited...";
stafflog_add("Edited crime {$_POST['crimeNAME']}");

} 
function delcrime()
{
global $ir,$c,$h,$userid, $db;
switch ($_GET['step'])
{
  default:
     echo "<h3>Deleting Crime</h3>
     Here you can delete a crime. 

     <form action='staff_crimes.php?action=delcrime&step=2' method='post'>
     Crime: ".crime_dropdown($c,'crime')."

     <input type='submit' value='Delete Crime' /></form>";
  break;
  case 2:
     $target = $_POST['crime'];
     $d=$db->query("SELECT crimeNAME FROM crimes WHERE crimeID='$target'");
     $itemi=$db->fetch_row($d);
     print "<h3>Confirm</h3>
     Delete crime -  ".$itemi["crimeNAME"]."?
     <form action='staff_crimes.php?action=delcrime&step=3' method='post'>
     <input type='hidden' name='crimeID' value='$target' />
     <input type='submit' name='yesorno' value='Yes' />
     <input type='submit' name='yesorno' value='No' onclick=\"window.location='staff_crimes.php?action=delcrime';\" /></form>";
  break;
  case 3:
     $target = $_POST['crimeID'];
     if($_POST['yesorno']=='No')
     {
        die("Crime not deleted.
[url='staff_crimes.php?action=delcrime']>Back to main delete crimes page.[/url]");
     }
     if ($_POST['yesorno'] != ("No" || "Yes")) die('Eh');
     $d=$db->query("SELECT crimeNAME FROM crimes WHERE crimeID='$target'");
     $itemi=$db->fetch_row($d);
     $db->query("DELETE FROM crimes WHERE crimeID='$target'");
     echo "Crime {$itemi['crimeNAME']} Deleted.
[url='staff_crimes.php?action=delcrime']>Back to main delete crimes page.[/url]"; 
stafflog_add("Deleted crime {$itemi['crimeNAME']}");    
  break;
}
} 
function new_crimegroup_form()
{
global $ir, $c,$db;
print "Adding a new crime group.

<form action='staff_crimes.php?action=newcrimegroupsub' method='post'>
Name: <input type='text' name='cgNAME' />

Order Number: <input type='text' name='cgORDER' />

<input type='submit' value='Create Crime Group' /></form>";
}
function new_crimegroup_submit()
{
global $ir,$c,$userid,$db;
if(!isset($_POST['cgNAME']) || !isset($_POST['cgORDER']))
{
print "You missed one or more of the required fields. Please go back and try again.

[url='staff_crimes.php?action=newcrimegroup']> Back[/url]";
$h->endpage();
exit;
}
$db->query("INSERT INTO `crimegroups` (`cgNAME`, `cgORDER`) VALUES('{$_POST['cgNAME']}','{$_POST['cgORDER']}')");
print "Crime Group created!";
stafflog_add("Created Crime Group {$_POST['cgNAME']}");
}

function edit_crimegroup_begin()
{
global $ir,$c,$h,$userid,$db;
print "<h3>Editing A Crime Group</h3>
<form action='staff_crimes.php?action=editcrimegroupform' method='post'>
Crime Group: ".crimegroup_dropdown($c,'crimeGROUP')."

<input type='submit' value='Edit Crime Group' /></form>";
}

function edit_crimegroup_form()
{
global $ir,$c,$h,$userid,$db;

$d=$db->query("SELECT * FROM crimegroups WHERE cgID={$_POST['crimeGROUP']}");
$itemi=$db->fetch_row($d);
print "<h3>Editing Crime Group</h3>
<form action='staff_crimes.php?action=editcrimegroupsub' method='post'>
<input type='hidden' name='cgID' value='{$_POST['crimeGROUP']}' />
Name: <input type='text' name='cgNAME' value='{$itemi['cgNAME']}' />

Order Number: <input type='text' name='cgORDER' value='{$itemi['cgORDER']}' />

<input type='submit' value='Edit Crime Group' /></form>";
}

function edit_crimegroup_sub()
{
global $ir,$c,$h,$userid, $db;
if(!isset($_POST['cgORDER']) || !isset($_POST['cgNAME']))
{
print "You missed one or more of the required fields. Please go back and try again.

[url='staff_crimes.php?action=editcrimegroup']> Back[/url]";
$h->endpage();
exit;
}
else
{
$db->query("UPDATE crimegroups SET  cgNAME='{$_POST['cgNAME']}', cgORDER='{$_POST['cgORDER']}' WHERE cgID='{$_POST['cgID']}'");
print "Crime Group edited...";
stafflog_add("Edited Crime Group {$_POST['cgNAME']}");
}
}

function delcrimegroup()
{
global $ir,$c,$h,$userid, $db;
switch ($_GET['step'])
{
  default:
     echo "<h3>Deleting Crime Group</h3>
<script type='text/javascript'>
function checkme()
{
if(document.theform.crimeGROUP.value==document.theform.crimeGROUP2.value)
{
alert('You cannot select the same crime group to move the crimes to.');
return false;
}
return true;
}
</script>
     <form action='staff_crimes.php?action=delcrimegroup&step=2' method='post' name='theform' onsubmit='return checkme();'>
     Crime Group: ".crimegroup_dropdown($c,'crimeGROUP')."

Move crimes in deleted group to: ".crimegroup_dropdown($c, 'crimeGROUP2')."

     <input type='submit' value='Delete Crime Group' /></form>";
  break;
  case 2:
     $target = $_POST['crimeGROUP'];
$target2 = $_POST['crimeGROUP2'];
if($target==$target2) { die("You cannot select the same crime group to move the crimes to."); }
     $d=$db->query("SELECT cgNAME FROM crimegroups WHERE cgID='$target'");
     $itemi=$db->fetch_row($d);
     print "<h3>Confirm</h3>
     Delete crime group -  ".$itemi["cgNAME"]."?
     <form action='staff_crimes.php?action=delcrimegroup&step=3' method='post'>
     <input type='hidden' name='cgID' value='$target' />
<input type='hidden' name='cgID2' value='$target2' />
     <input type='submit' name='yesorno' value='Yes' />
     <input type='submit' name='yesorno' value='No' onclick=\"window.location='staff_crimes.php?action=delcrimegroup';\" /></form>";
  break;
  case 3:
     $target = $_POST['cgID'];
$target2 = $_POST['cgID2'];
     if($_POST['yesorno']=='No')
     {
        die("Crime Group not deleted.");
     }
     if ($_POST['yesorno'] != ("No" || "Yes")) die('This shouldnt happen');
     $d=$db->query("SELECT cgNAME FROM crimegroups WHERE cgID='$target'");
     $itemi=$db->fetch_row($d);
     $db->query("DELETE FROM crimegroups WHERE cgID='{$_POST['cgID']}'");
$db->query("UPDATE crimes SET crimeGROUP={$target2} WHERE crimeGROUP={$target}");
stafflog_add("Deleted crime group {$itemi['cgNAME']}");
     echo "Crime Group deleted.";     
  break;
}
}
function reorder_crimegroups()
{
global $db,$ir,$c,$h,$userid;
if($_POST['submit'])
{
unset($_POST['submit']);
$used=array();
foreach($_POST as $v)
{
if(in_array($v, $used))
{
print "You have used the same order number twice! Go back and try again.";
$h->endpage();
exit;
}
$used[]=$v;
}
foreach($_POST as $k => $v)
{
$cg=str_replace("order","", $k);
if(is_numeric($cg))
{
$db->query("UPDATE crimegroups SET cgORDER={$v} WHERE cgID={$cg}");
}
}
print "Crime group order updated!";
stafflog_add("Reordered crime groups");
}
else
{
$q=$db->query("SELECT * FROM crimegroups ORDER BY cgORDER ASC, cgID ASC");
$rows=$db->num_rows($q);
$i=0;
print "<h3>Re-ordering Crime Groups</h3><hr />
<table width='80%' cellspacing='1' class='table'>
<tr>
<th>Crime Group</th>
<th>Order</th>
</tr>
<form action='staff_crimes.php?action=reorder' method='post'>
<input type='hidden' name='submit' value='1' />";
while($r=$db->fetch_row($q))
{
$i++;
print "<tr>
<td>{$r['cgNAME']}</td>
<td><select name='order{$r['cgID']}' type='dropdown'>";
for($j=1;$j<=$rows;$j++)
{
if($j == $i)
{
print "<option value='{$j}' selected='selected'>{$j}</option>";
}
else
{
print "<option value='{$j}'>{$j}</option>";
}
}
print "</select></td></tr>";
}
print "<tr>
<td colspan='2' align='center'><input type='submit' value='Reorder' /></td>
</tr></form></table>";
}
}
function report_clear()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 3)
{
die("403");
}
$_GET['ID'] = abs((int) $_GET['ID']);
stafflog_add("Cleared player report ID {$_GET['ID']}");
$db->query("DELETE FROM preports WHERE prID={$_GET['ID']}");
print "Report cleared and deleted!

[url='staff_users.php?action=reportsview']> Back[/url]";
}
$h->endpage();
?>

 

Replace staff_cities.php with this:

 

<?php
include "sglobals.php";
if($ir['user_level'] > 2)
{
die("403");
}
//This contains city stuffs
switch($_GET['action'])
{
case "addcity": addcity(); break;
case "editcity": editcity(); break;
case "delcity": delcity(); break;
default: print "Error: This script requires an action."; break;
}
function addcity()
{
global $db, $ir, $c, $h, $userid;
$minlevel=abs((int) $_POST['minlevel']);
$name=$_POST['name'];
$desc=$_POST['desc'];
if($minlevel and $desc and $name)
{
$q=$db->query("SELECT * FROM cities WHERE cityname='{$name}'");
if($db->num_rows($q))
{
print "Sorry, you cannot have two cities with the same name.";
$h->endpage();
exit;
}
$db->query("INSERT INTO cities VALUES(NULL, '$name', '$desc', '$minlevel')");
print "City {$name} added to the game.";
stafflog_add("Created City $name");
}
else
{
print "<h3>Add City</h3><hr />
<form action='staff_cities.php?action=addcity' method='post'>
Name: <input type='text' name='name' />

Description: <input type='text' name='desc' />

Minimum Level: <input type='text' name='minlevel' />


<input type='submit' value='Add City' /></form>";
}
}

function editcity()
{
global $db, $ir, $c, $h, $userid;
switch($_POST['step'])
{
case "2":
$minlevel=abs((int) $_POST['minlevel']);
$name=$_POST['name'];
$desc=$_POST['desc'];
$q=$db->query("SELECT * FROM cities WHERE cityname='{$name}' AND cityid!={$_POST['id']}");
if($db->num_rows($q))
{
print "Sorry, you cannot have two cities with the same name.";
$h->endpage();
exit;
}
$name=$_POST['name'];
$q=$db->query("SELECT * FROM cities WHERE cityid={$_POST['id']}");
$old=$db->fetch_row($q);
$db->query("UPDATE cities SET cityminlevel=$minlevel, citydesc='$desc', cityname='$name' WHERE cityid={$_POST['id']}");
print "City $name was edited successfully.";
stafflog_add("Edited city $name");
break;
case "1":
$q=$db->query("SELECT * FROM cities WHERE cityid={$_POST['city']}");
$old=$db->fetch_row($q);
print "<h3>Editing a City</h3><hr />
<form action='staff_cities.php?action=editcity' method='post'>
<input type='hidden' name='step' value='2' />
<input type='hidden' name='id' value='{$_POST['city']}' />
Name: <input type='text' name='name' value='{$old['cityname']}' />

Description: <input type='text' name='desc' value='{$old['citydesc']}' />

Minimum Level: <input type='text' name='minlevel' value='{$old['cityminlevel']}' />

<input type='submit' value='Edit City' /></form>";
break;
default:
print "<h3>Editing a City</h3><hr />
<form action='staff_cities.php?action=editcity' method='post'>
<input type='hidden' name='step' value='1' />
City: ".location_dropdown($c, "city")."

<input type='submit' value='Edit City' /></form>";
break;
}
}
function delcity()
{
global $db,$ir,$c,$h,$userid;
if($_POST['city'])
{
$q=$db->query("SELECT * FROM cities WHERE cityid={$_POST['city']}");
$old=$db->fetch_row($q);
if($old['cityid']==1)
{
die("This city cannot be deleted.");
}

$db->query("UPDATE users SET location=1 WHERE location={$old['cityid']}");
$db->query("UPDATE shops SET shopLOCATION=1 WHERE shopLOCATION={$old['cityid']}");
$db->query("DELETE FROM cities WHERE cityid={$old['cityid']}");
print "City {$old['cityname']} deleted.";
stafflog_add("Deleted city {$old['cityname']}");
}
else
{
print "<h3>Delete City</h3><hr />
Deleting a city is permanent - be sure. Any users and shops that are currently in the city you delete will be moved to the default city (ID 1).<form action='staff_cities.php?action=delcity' method='post'>
City: ".location_dropdown($c, "city")."

<input type='submit' value='Delete City' /></form>";
}
}
function report_clear()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 3)
{
die("403");
}
$_GET['ID'] = abs((int) $_GET['ID']);
stafflog_add("Cleared player report ID {$_GET['ID']}");
$db->query("DELETE FROM preports WHERE prID={$_GET['ID']}");
print "Report cleared and deleted!

[url='staff_users.php?action=reportsview']> Back[/url]";
}
$h->endpage();
?>
Link to comment
Share on other sites

Re: Adding crimes and cities in v2

 

? lol dont understand this convo lmao

I think stryker was trying to say my game wasnt legal, Because i didnt have the add_crime script you had, seeing as i told mr smith to do it through the DB.But, I dont think he realised that script doesnt come with V1. Well it kinda gives it away with the header info being v2 in the script. But oh well. :lol:

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