私はこの関数を functions.php に持っています。私は、crimes.php でこの関数をどのように呼び出すかという名前の php ページを持っています。
function jailMe($script, $reason, $unbustable = false){
global $fetch;
if($unbustable == false){ $unbustable = "0"; }else{ $unbustable = "1"; }
if($script == 'Crime'){
$chanceToJail = rand(1,5);
if($chanceToJail == 2){
$jailTime = time() + (rand(60,90));
mysql_query("INSERT INTO `jail` (`name`, `release`, `reason`, `bustable`) VALUES ('{$fetch['name']}','$jailTime','$reason','$unbustable')");
return "<br /><br /><h1>You have been thrown into jail!</h1>";
}
犯罪.php
session_start();
include_once("../src/connect.php");
include_once("../src/functions.php");
if($_POST['DoCrime']){
$Crime = (int)makesafe($_POST['DoCrime']);
if($Crime == '1'){
$NewRankXP = rand(1,15);
$NewMoney = rand(30,100);
$CrimeTime = (time()+ 60*1);
mysql_query("UPDATE `Users` SET `RankXP` = `RankXP` + '$NewRankXP' WHERE `id` = '{$fetchChar['id']}'");
mysql_query("UPDATE `Users` SET `Money` = `Money` + '$NewMoney' WHERE `id` = '{$fetchChar['id']}'");
mysql_query("UPDATE `Users` SET `last_crime` = '$CrimeTime' WHERE `id` = '{$fetchChar['id']}'");
echo "<font color='lime'>Success You got away with $NewRankXP XP and $$NewMoney!</font>";
}
}