|
|
|
|
![]() ![]() |
Dec 3 2007, 05:10 AM
Post
#1
|
|
|
|||[ n00b King ]||| ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 687 Joined: 20-June 07 From: Auckland Member No.: 45,102 |
Heres my merit system at its current stage. http://sonesay.trap17.com/index.php
note: select a character from the drop down list to see output. I've been working on this locally on my mac and because of little or no delay I did not see the problem until I decided to upload to the WWW. The problem lies in the adding of merits to each category. Although there are integrity checks on the PHP side before executing the update to mysql database it somehow fails because of the lag. i.e multiple 'add' buttons can be pressed before the section gets reloaded. so if your modifying the 'Combat Skill' category and its 19/20 you should only be able to add one more merit. But because of page reloading delay you are able to hit more buttons before it finishes reloading. my function to modify merits. CODE function modify_merit($mm_c_id, $mm_mode, $mm_merit, $mm_combo_limit, $mm_item_limit, $mm_table) { include('../db.php'); if ($mm_mode == "remove") { // check if merit is equal or above 1 before lowering by 1 // get users merits $q1 = "SELECT ".$mm_merit." FROM ".$mm_table." WHERE c_id = ".$mm_c_id; $r1 = mysql_query($q1, $link); while ($m = mysql_fetch_array($r1)) { $mm_new_level = $m[$mm_merit]; } if($mm_new_level > 0) { $mm_new_level--; // update hp level $q2 = "UPDATE ".$mm_table." SET ".$mm_merit." = ".$mm_new_level . " WHERE c_id = " . $mm_c_id; mysql_query($q2, $link); } } if ($mm_mode == "add") { $q1 = "SELECT ".$mm_merit." FROM ".$mm_table." WHERE c_id = ".$mm_c_id; $r1 = mysql_query($q1, $link); while ($m = mysql_fetch_array($r1)) { $mm_new_level = $m[$mm_merit]; } // check if under max combo and item limit before adding. if($mm_new_level < $mm_item_limit && $mm_new_level < $mm_combo_limit) { $mm_new_level++; // update hp level $q2 = "UPDATE ".$mm_table." SET ".$mm_merit." = ".$mm_new_level . " WHERE c_id = " . $mm_c_id; mysql_query($q2, $link); } } } each button pressed is added like this CODE if($merit == "sword_level") { modify_merit($c_id, $mode, $merit, 20, 8, 'combat_skill'); } I know I cant blame lag being the cause of my problem its my code. There are two options at this stage I can think of 1. Redo all the sections and reload all Div's in the same category all at once so there is no way to press more then 2 buttons. e.g if HP merit is incresed the whole HPMP div reloads at once so there is no chance to hit the add MP button causing 8 max combo constraint to fail. 2. Use java script to disable all add buttons in the category being modified until its fully reloaded(not sure this will work). What do you think would be the best way to fix this? This post has been edited by sonesay: Dec 3 2007, 05:11 AM |
|
|
|
Jul 10 2008, 08:42 AM
Post
#2
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 40 Joined: 10-July 08 From: Cebu City Philippines Member No.: 64,841 |
I think the second one will work.
|
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 6th October 2008 - 06:24 PM |