Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Php coding help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Matiashelland" data-source="post: 418671" data-attributes="member: 54282"><p>Here is my crime.php</p><p>I have fix one of the problem but the timer will not update in database.</p><p></p><p>[CODE]<?php</p><p></p><p> class crimes extends module {</p><p> </p><p> public $allowedMethods = array('crime'=>array('type'=>'get'));</p><p> </p><p> public $pageName = 'Crimes';</p><p> </p><p> public function constructModule() {</p><p> </p><p> $crimes = $this->db->prepare("SELECT * FROM crimes WHERE C_level <= :level");</p><p> $crimes->bindParam(':level', $this->user->info->US_rank);</p><p> $crimes->execute();</p><p> </p><p> $crimePercs = explode('-', $this->user->info->US_crimes);</p><p> </p><p> while ($crime = $crimes->fetchObject()) {</p><p> </p><p> $crimeID = $crime->C_id;</p><p> </p><p> $crimeInfo = array(</p><p> $crime->C_name,</p><p> $this->timeLeft($crime->C_cooldown),</p><p> $crimePercs[($crimeID-1)],</p><p> $crimeID</p><p> );</p><p> </p><p> $this->html .= $this->page->buildElement('crimeHolder', $crimeInfo);</p><p> </p><p> }</p><p> </p><p> }</p><p> </p><p> public function method_commit() {</p><p> </p><p> $id = abs(intval($this->methodData->crime));</p><p> </p><p> if (!$this->user->checkTimer('crime')) {</p><p> </p><p> $time = $this->user->getTimer('crime') - time();</p><p> $crimeError = array('You cant commit another crime untill your timer is up! (<span data-timer-type="inline" data-timer="'.($this->user->getTimer("crime") - time()).'"></span>)');</p><p> $this->html .= $this->page->buildElement('error', $crimeError);</p><p> </p><p> } else {</p><p> </p><p> $chance = mt_rand(1, 100);</p><p> $jailChance = mt_rand(1, 3);</p><p> $crimeID = $id;</p><p> </p><p> $crime = $this->db->prepare("SELECT * FROM crimes WHERE C_id = :crime");</p><p> $crime->bindParam(':crime', $crimeID);</p><p> $crime->execute();</p><p> $crimeInfo = $crime->fetchObject();</p><p> </p><p> $userCrimeChance = explode('-', $this->user->info->US_crimes);</p><p> $userChance = $userCrimeChance[($crimeInfo->C_id - 1)];</p><p> $reward = mt_rand($crimeInfo->C_money, $crimeInfo->C_maxMoney);</p><p> </p><p> if ($chance > $userChance && $jailChance == 1) {</p><p> $crimeError = array('You failed to commit the crime, you were caught and sent to jail!');</p><p> $this->html .= $this->page->buildElement('error', $crimeError);</p><p> $query = "UPDATE userStats SET US_crimes = :crimes WHERE US_id = :user";</p><p> $this->user->updateTimer('crime', ($crimeInfo->C_id * 15), true);</p><p> $add = 0;</p><p> } else if ($chance > $userChance) {</p><p> $crimeError = array('You failed to commit the crime!');</p><p> $this->html .= $this->page->buildElement('error', $crimeError);</p><p> $query = "UPDATE userStats SET US_crimes = :crimes WHERE US_id = :user";</p><p> $add = mt_rand(1, 2);</p><p> } else {</p><p> $crimeError = array('You successfuly commited the crime and earned $'.number_format($reward).'!');</p><p> $this->html .= $this->page->buildElement('success', $crimeError);</p><p> $query = "UPDATE userStats SET US_money = US_money + ".$reward.", US_exp = US_exp + 1, US_crimes = :crimes WHERE US_id = :user";</p><p> $add = mt_rand(1, 4);</p><p> }</p><p> </p><p> $update = $this->db->prepare($query);</p><p> $update->bindParam(':user', $this->user->info->US_id);</p><p> </p><p> $this->user->updateTimer('crime', $crimeInfo->C_cooldown, true);</p><p> </p><p> $userCrimeChance[($crimeID-1)] = $userCrimeChance[($crimeID-1)] + $add;</p><p> </p><p> if ($userCrimeChance[($crimeID-1)] > 100) {</p><p> $userCrimeChance[($crimeID-1)] = 100;</p><p> }</p><p> </p><p> $update->bindParam(':crimes', implode('-', $userCrimeChance));</p><p> $update->execute();</p><p> </p><p> }</p><p> </p><p> }</p><p> </p><p> }</p><p></p><p>?>[/CODE]</p></blockquote><p>[/QUOTE]</p>
[QUOTE="Matiashelland, post: 418671, member: 54282"] Here is my crime.php I have fix one of the problem but the timer will not update in database. [CODE]<?php class crimes extends module { public $allowedMethods = array('crime'=>array('type'=>'get')); public $pageName = 'Crimes'; public function constructModule() { $crimes = $this->db->prepare("SELECT * FROM crimes WHERE C_level <= :level"); $crimes->bindParam(':level', $this->user->info->US_rank); $crimes->execute(); $crimePercs = explode('-', $this->user->info->US_crimes); while ($crime = $crimes->fetchObject()) { $crimeID = $crime->C_id; $crimeInfo = array( $crime->C_name, $this->timeLeft($crime->C_cooldown), $crimePercs[($crimeID-1)], $crimeID ); $this->html .= $this->page->buildElement('crimeHolder', $crimeInfo); } } public function method_commit() { $id = abs(intval($this->methodData->crime)); if (!$this->user->checkTimer('crime')) { $time = $this->user->getTimer('crime') - time(); $crimeError = array('You cant commit another crime untill your timer is up! (<span data-timer-type="inline" data-timer="'.($this->user->getTimer("crime") - time()).'"></span>)'); $this->html .= $this->page->buildElement('error', $crimeError); } else { $chance = mt_rand(1, 100); $jailChance = mt_rand(1, 3); $crimeID = $id; $crime = $this->db->prepare("SELECT * FROM crimes WHERE C_id = :crime"); $crime->bindParam(':crime', $crimeID); $crime->execute(); $crimeInfo = $crime->fetchObject(); $userCrimeChance = explode('-', $this->user->info->US_crimes); $userChance = $userCrimeChance[($crimeInfo->C_id - 1)]; $reward = mt_rand($crimeInfo->C_money, $crimeInfo->C_maxMoney); if ($chance > $userChance && $jailChance == 1) { $crimeError = array('You failed to commit the crime, you were caught and sent to jail!'); $this->html .= $this->page->buildElement('error', $crimeError); $query = "UPDATE userStats SET US_crimes = :crimes WHERE US_id = :user"; $this->user->updateTimer('crime', ($crimeInfo->C_id * 15), true); $add = 0; } else if ($chance > $userChance) { $crimeError = array('You failed to commit the crime!'); $this->html .= $this->page->buildElement('error', $crimeError); $query = "UPDATE userStats SET US_crimes = :crimes WHERE US_id = :user"; $add = mt_rand(1, 2); } else { $crimeError = array('You successfuly commited the crime and earned $'.number_format($reward).'!'); $this->html .= $this->page->buildElement('success', $crimeError); $query = "UPDATE userStats SET US_money = US_money + ".$reward.", US_exp = US_exp + 1, US_crimes = :crimes WHERE US_id = :user"; $add = mt_rand(1, 4); } $update = $this->db->prepare($query); $update->bindParam(':user', $this->user->info->US_id); $this->user->updateTimer('crime', $crimeInfo->C_cooldown, true); $userCrimeChance[($crimeID-1)] = $userCrimeChance[($crimeID-1)] + $add; if ($userCrimeChance[($crimeID-1)] > 100) { $userCrimeChance[($crimeID-1)] = 100; } $update->bindParam(':crimes', implode('-', $userCrimeChance)); $update->execute(); } } } ?>[/CODE] [/QUOTE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Php coding help
Top