Jump to content
MakeWebGames

sniko

Members
  • Posts

    2,210
  • Joined

  • Last visited

  • Days Won

    47

Everything posted by sniko

  1. Thanks for spotting those! ** Illusions ** sorry for editing this post but i had to change 12
  2. That made it clearer, many thanks!!
  3. Just an idea, but include a story in the game...
  4. @a_bertrand - Although I agree with you 100%, I think, in this day in age, we need to take things with a different approach, sure, use the normal methods, but expand on them, and make computing much faster and logical. Anyway, I thank you for your replies.
  5. @newttster - It frees the memory that's allocated to the query. As the query needs to be held somewhere in memory, as it's put to a variable. As I stated before, select what's needed, when needed, so in the instance of player profiles, more will be selected, but not from the globals.php file, from the players profile. In my view, it depends what you select, I.E not using the wildcard (*), only list the fields you need. @a_bertrand - Although I haven't done physical tests, I've done theory, in my computing class, and how memory can be used and preserved. As explained, McCodes uses the wildcard (*) in globals to select from numerous tables, using a LEFT JOIN. The aim of this post was to cut down the redundant columns being selected, and only selecting what's needed, when needed. What I mean by this, is that some columns rely on other systems to have a change in value, and if they never use that system, it will always be default, 0. Although you've said that using 10 - 40 columns and having little difference, there is difference. "Every little helps" #Tesco ;) @Spudinski - Yeah, I am aware that a table does take more memory than columns, but let's assume that you have a user base of 10,000+. Only using the courses columns `cdays`,`course` - both int(11) - 11 bytes of data - 11 x 10,000 = X. (Maths maybe wrong to calculate the used memory, but you get the drift) As I stated before, if a user doesn't use that system, it'll stay default, 0, which in the way the column is set up, will be 00000000000 (not just a single 0, as the rest of the int has to be filled, as it's set up int(11)). So, X is unused memory, which will be using resources, when you can cut it down. Now, I didn't know about the "All associated result memory is automatically freed at the end of the script's execution.", so thank you for spotting that out! @SomeRandomBastard - Ah, thank you, I'm am just used to putting in values, and pressing 'Go', and forgetting to change the charset I hope this clears some things up, but please state that if I am wrong, I am wrong, or I have a misconception.
  6.   Sorry, that should do it now, review step 6.
  7. Following on from Database Table Design   This will help save resources, as said in the article above; 1. Run this SQL http://codepad.org/ST5AIzuQ   2. Open up education.php 3. Find this query $db->query("UPDATE users SET course={$_GET['cstart']},cdays={$coud['crDAYS']},money=money-{$coud['crCOST']} WHERE userid=$userid"); 4. Replace with $db->query("INSERT INTO `users_courses` (`userid`,`course`,`cdays`) VALUES ({$userid}, {$_GET['cstart']}, {$coud['crDAYS']})");   5. Replace this snippet if($ir['course'] > 0) { $cd=$db->query("SELECT * FROM courses WHERE crID={$ir['course']}"); $coud=$db->fetch_row($cd); print "You are currently doing the {$coud['crNAME']}, you have {$ir['cdays']} days remaining."; } 6. With $get = $db->query("SELECT `course`,`cdays` FROM `users_courses` WHERE `userid`={$userid}"); $r = $db->fetch_row($get); if($r['course'] > 0) { $cd=$db->query("SELECT `crNAME`,`crDAYS` FROM courses WHERE crID={$r['course']}"); $coud=$db->fetch_row($cd); print "You are currently doing the {$coud['crNAME']}, you have {$r['cdays']} days remaining."; mysql_free_result($get); unset($r); }   7. Save education.php 8. Open cron_day.php 9. Find; $q=mysql_query("SELECT * FROM users WHERE cdays=0 AND course > 0"); 10. Replace with; $q=mysql_query("SELECT `course`,`cdays` FROM `users_courses` WHERE `cdays`=0 AND `course` > 0"); 11. Find; mysql_query("UPDATE users SET course=0 WHERE cdays=0"); 12. Replace with; mysql_query("DELETE FROM `users_courses` WHERE cdays=0");   And that's it... -sniko
  8. $_POST['fee'] = preg_match()("[^0-9]",'',$_POST['fee']); $_POST['fee'] = preg_match("[^0-9]",'',$_POST['fee']);
  9. Although this has been pointed out within the community numerous times, I thought I'd write an 'article' on it... Within McCodes Version 2 - Unsure with other versions, the database table designs are poor, in my opinion. Let me explain; Let's look at the most infamous table of them all, `users`. In one of the main files, which are called upon on every request a user makes on your site globals.php, everything (All columns) are selected - with a condition, a userid session, set when you log in - authenticate.php. So, In the base McCodes, it would select 68 columns, on every single request the user makes, just from the users table. You may think, but I need all those columns, and having a Left Join will simply do no help. So, let's take a little snippet from the `users` table. course cdays gang daysingang jobrank fedjail forumban fb_reason friend_count enemy_count boxes_opened As all of these are default 0, and rely on other systems for a change, why don't we create a new table for each (grouping relevant ones together) and having `userid` as the foreign key, to link. Here's my reasoning; As stated before, they rely on other systems for a change, so what happens if they don't use that specific system whilst playing, for example, they never get forum banned, or they don't donate so their friend or enemy count won't go up (pretty useless anyway, as you can use mysql_num_rows or count() with a specific condition) so this means that every time a user makes a request (Clicks a link on your game, to another page) a query to the database is made, which selects these 'redundant' columns, wasting space, and resources. So here's what I propose; We, developers, game owners, whoever, makes a table for these columns (grouping relevant ones together) to save resources and space, possibly resulting in saving money. Here's one for courses The SQL This will take out the two 'redundant' columns from the `users` table, resulting in only 66 columns being selected at each request from the `users` table. 1. Insert data into the new table `users_courses` when they start a new course 2. Select the data when needed 3. Use mysql_free_result once finished with selecting from the new table to free memory Now, if we did this, or better yet, it was set up like this, we'd be saving a lot of resources each request a user makes. Shame it wasn't set up like this, as it would take a while to implement, especially for games that have been edited, with new features/systems.   So, as a community, here's what I propose; Whenever we create a system, for McCodes, or not, we try our very best to not insert more columns into the `users` table, but create a new table, like the one I did for `users_courses`. I'm not telling you what to do, I'm advising you, as users, In my view, will get a better playing experience, from a faster response. Your views? -sniko Systems Courses
  10. I quite like the idea of doing it yourself, a sense of achievement. If you manage to do it all, and it works, as intended, great! If not, well, you tried, and learned, I bet! Anyway, I can see it being cool, and such, but I read somewhere about short tags not being supported in some browsers, or whatever, so, to be on the safe side, edit those.
  11. #content { width: 500px; height: 500px; overflow: scroll; } <div id='content'> something something something something </div> I'm not that good with CSS, but give that a shot
  12. Run me through the process.... Login > TOS - or - Login > White Screen - or - White Screen
  13. <?php session_start(); //some code $_SESSION['username'] = $inf->username; ?> I don't see why that wouldn't work... ? Make sure you have no syntax errors within the code
  14. $something = <value>; session_register("something"); -to- $_SESSION['something'] = <value>;
  15. hehe Bert, I didn't know all that technical stuff (not the customization) but I find the phone really handy, as I have an xbox, and Facebook, so it suits me well! I also love the interface, so that maybe why I'm drawn to Win 8.
  16. I have a Windows phone, and I think it's better than Andriod and iOS (+ all the others) and Windows 8 does look pretty cool. I think I'll be the first to buy it out of us three then :P
  17. sniko

    Game time

    Sounds like a cool idea! Is this a request or....?
  18. Check this video
  19. Here, try this version Hosted at codepad. Edit Thanks Djk, for spotting the link error
  20. It sure has potential. Here's my view; I feel that the icons (Guns and notification icons) are too big. I also get a sense of the template not flowing with other elements, they seem to be there, to take space, but you haven't thought of 1 style of the template, you've mixed a few styles. That's my view.
  21. Line 84, change to Points Cost: <input type='text' name='hPOINTS'' value='{$old['hPOINTS']}' /> To fix the bug found by Newbie
  22. Try; <a href='filename.php?action=userlevelform'>User Level Form</a><br />
  23. You need to edit the link; I'm unsure what the actual case name is, so; - Open the file. - Find the case section of the file - Find the case name of the function you want to link to - Edit the link (Normally, McCodes uses this <a href='file.php?action=casename'>Something</a>) Personally, I don't like the default case returning that error, it would be so much more user friendly if it returned links to the functions...
  24. Alternatively, store the production setting in the database, and do something along the following; $get = $db->query("SELECT <primary_key> FROM <table> WHERE <production_column>='Yes'"); while($r = $db->fetch_row($get)) { $db->query("UPDATE <table> SET <bullet_column>=<bullet_column>+<value> WHERE <primary_key>={$r['<primary_key>']}"); } unset($r); mysql_free_result($get);
  25. If you have enough knowledge (I'm not doubting anyone), you could probably 'convert' it. By me using the word 'convert', I'm not saying A=B=A (Reword a few things, and add a few lines of code here and there) but, re-create it.
×
×
  • Create New...