-BRAIDZ- Posted June 15, 2015 Share Posted June 15, 2015 (edited) brewery.php You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Sql: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add items: Bottle of Beer Bottle of Whiskey Bottle of Cider Bottle of Vodka You will just have to change the item id in the code. Save this image as "brewery.jpg" and add it to your images folder on your database: [ATTACH]2103[/ATTACH] I would like to thank [MENTION=67703]adamhull[/MENTION] for the help with parts of my code. If you have any problems with the script mail me Edit your inventory.php file. And add for each item id You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Just change item id You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. And so on,you should get the drift now. Edited June 15, 2015 by -BRAIDZ- Quote Link to comment Share on other sites More sharing options...
AdamHull Posted June 15, 2015 Share Posted June 15, 2015 Think I will make this more dynamic and make a staff panel to add things if anybody is interested. Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted June 15, 2015 Author Share Posted June 15, 2015 Think I will make this more dynamic and make a staff panel to add things if anybody is interested. If you want to mate, go for it Quote Link to comment Share on other sites More sharing options...
sniko Posted June 15, 2015 Share Posted June 15, 2015 (edited) Below is a compiled list of constructive criticism. The validation on line 16 is unnecessary as it will be handled within the switch cases. You're missing the $h->endpage() call to nicely end the HTML on line 5 and line 8 You don't need to bring this many variables into the local scope of your first function on line 86. You're only using $ir. Hardcoded values are a nuisance on line 209. The form on line 215 is wasted. See http://makewebgames.io/showthread.php/46088-In-Production-Brewery-Mod?p=312017&viewfull=1#post312017 You can make these queries into one on line 269. What is this if() statement for on line 273? Perhaps make use of max_energy (or whatever it's called) in the formula on line 290 so that you don't go over your max energy? It may be a nice idea to make the item id's a constant for more flexibility, for example on line 420 How about making the brew time (on line 479) to take into account a users skill, so it's not always constant (thus boring) See http://makewebgames.io/showthread.php/46088-In-Production-Brewery-Mod?p=311984&viewfull=1#post311984 Why not create another table instead of more columns in an already-crowded users table? Why BIGINT? Overall, nice for your first. However, it could be refactored for easier flexibility, expandability, and less functions with hardcoded values. Edited June 15, 2015 by sniko Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted June 15, 2015 Share Posted June 15, 2015 More dynamic would be better so that you can set the types of alcohol to brew and all the settings for that type. Then you would only need like 3 of those functions. Also, this script can use some heavy optimizing. You call global variables where they are not even used, you stack queries on top of eachother that are updating the same table, and you flood the users table with more useless fields. You should create a separate table that hold all the stuff for the users brewing. You can create a table for that with fields such as an ID, userid, brew type, and time last brewed and use that info to determine if they can brew that type again. Basically what [MENTION=65371]sniko[/MENTION] said haha. I took too long to post and he got in while I was typing Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted June 15, 2015 Author Share Posted June 15, 2015 Below is a compiled list of constructive criticism. The validation on line 16 is unnecessary as it will be handled within the switch cases. You're missing the $h->endpage() call to nicely end the HTML on line 5 and line 8 You don't need to bring this many variables into the local scope of your first function on line 86. You're only using $ir. Hardcoded values are a nuisance on line 209. The form on line is wasted. See http://makewebgames.io/showthread.php/46088-In-Production-Brewery-Mod?p=312017&viewfull=1#post312017 You can make these queries into one on line 269. What is this if() statement for on line 273? Perhaps make use of max_energy (or whatever it's called) in the formula on line 290. It may be a nice idea to make the item id's a constant[/color] for more flexibility, for example on line 420 How about making the brew time (on line 479) to take into account a users skill, so it's not always constant (thus boring) See http://makewebgames.io/showthread.php/46088-In-Production-Brewery-Mod?p=311984&viewfull=1#post311984 Why not create another table instead of more columns in an already-crowded users table? Why BIGINT? Overall, nice for your first. However, it could be refactored for easier flexibility, expandability, and less functions with hardcoded values. Thanks mate. But there is only one way to learn and that is what I am doing. I will go through and see what I can fix up. I know the code is messy as, but what can you expect for someone only just starting out. But thank you for saying it's a nice mod, and thank you for the criticism. This is one way of learning. And by doing it myself also. I hope everyone else likes it as well :) I will not take full credit for the mod as I have had a little bit of help with it Quote Link to comment Share on other sites More sharing options...
Coly010 Posted June 15, 2015 Share Posted June 15, 2015 I will not take full credit for the mod as I have had a little bit of help with it "Little" LOL Good effort though Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted August 26, 2015 Author Share Posted August 26, 2015 I am currently converting this mod to RC Engine, going smoothly at the moment, I will post code once done, just making a few little changes. Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted August 26, 2015 Author Share Posted August 26, 2015 Here it is, converted for RC Engine. I only have one problem with though, the mod it self is fully functioning, its just the queries are not working.. Not too sure where I have gone wrong, but I have been trying to get them working for ages now. Also, I have taken out the item use (drink) functions for RC and will be creating new items for RC Engine for this mod, so there will be different item numbers.. And will be coding them into itemuse.php The changes to the sql table: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Converted code: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Quote Link to comment Share on other sites More sharing options...
~Rob0t Posted August 26, 2015 Share Posted August 26, 2015 Here it is, converted for RC Engine. I only have one problem with though, the mod it self is fully functioning, its just the queries are not working.. Not too sure where I have gone wrong, but I have been trying to get them working for ages now. Also, I have taken out the item use (drink) functions for RC and will be creating new items for RC Engine for this mod, so there will be different item numbers.. And will be coding them into itemuse.php The changes to the sql table: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Converted code: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Don't use INT(11) for everything Why so many hard-coded values? Why are you using mysql_real_escape_string() on an integer value? See this Your indentation is horrible. Have a look at PSR-2 coding standards or even this wikipedia article Line 433 is funny Read this reply to your original post from [MENTION=65371]sniko[/MENTION], then recode it entire thing. Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted August 26, 2015 Author Share Posted August 26, 2015 Don't use INT(11) for everything Why so many hard-coded values? Why are you using mysql_real_escape_string() on an integer value? See this Your indentation is horrible. Have a look at PSR-2 coding standards or even this wikipedia article Line 433 is funny Read this reply to your original post from @sniko, then recode it entire thing. Thanks, but I did not ask for any criticism. I know my coding is horrible, and I use the mysql_real_escape_string() because the whole RC Engine does.. Now what I did ask, was about my queries, where am I stuffing up with them for them not to work? Quote Link to comment Share on other sites More sharing options...
~Rob0t Posted August 26, 2015 Share Posted August 26, 2015 Thanks, but I did not ask for any criticism. I know my coding is horrible, and I use the mysql_real_escape_string() because the whole RC Engine does.. Now what I did ask, was about my queries, where am I stuffing up with them for them not to work? Thanks, but I did not ask for any criticism. And by that logic, I can say you didn't ask for no criticism. Life doesn't work like this, buddy. I know my coding is horrible, and I use the mysql_real_escape_string() because the whole RC Engine does.. Then break the mould. Just because another (shoddy) developer did something differently/wrong, you shouldn't copy them. Now what I did ask, was about my queries, where am I stuffing up with them for them not to work? Which queries, specifically? Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted August 26, 2015 Author Share Posted August 26, 2015 And by that logic, I can say you didn't ask for no criticism. Life doesn't work like this, buddy. Then break the mould. Just because another (shoddy) developer did something differently/wrong, you shouldn't copy them. Which queries, specifically? All of the queries, they aren't working, they wont put anything into the database.... Quote Link to comment Share on other sites More sharing options...
~Rob0t Posted August 26, 2015 Share Posted August 26, 2015 All of the queries, they aren't working, they wont put anything into the database.... You're using ' (quote mark) instead of ` (back tick) causing a SQL error (line 272). If you knew how to debug properly - or even attempted a debug - you would have realised your mistake. Quote Link to comment Share on other sites More sharing options...
IllegalPigeon Posted August 26, 2015 Share Posted August 26, 2015 You're using ' (quote mark) instead of ` (back tick) causing a SQL error (line 272). If you knew how to debug properly - or even attempted a debug - you would have realised your mistake. This forum is obsessed with using back ticks on table and column names. It's bad practice to use back ticks on everything, you only need to use back ticks for reserved MySQL words. Quote Link to comment Share on other sites More sharing options...
Dayo Posted August 26, 2015 Share Posted August 26, 2015 This forum is obsessed with using back ticks on table and column names. It's bad practice to use back ticks on everything, you only need to use back ticks for reserved MySQL words. Its probably because people just copy/paste the output from phpmyadmin. Don't use INT(11) for everything I have been told by a colleague that working with INT's compared to small/tiny INT's is more efficient, modern CPUs are designed to work better with 32-bit values. Granted you use up more space but in this day and age where you get TB of storage for next to nothing it dosent matter about the 16 bits you will save per record. Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted August 26, 2015 Author Share Posted August 26, 2015 Its probably because people just copy/paste the output from phpmyadmin. I have been told by a colleague that working with INT's compared to small/tiny INT's is more efficient, modern CPUs are designed to work better with 32-bit values. Granted you use up more space but in this day and age where you get TB of storage for next to nothing it dosent matter about the 16 bits you will save per record. I always use INT(11) or BIGINT(25) depending on what for, the mod is now working, I removed the quotation marks, and didn't add in any back ticks, works fine now... And removed the endpage function (because [MENTION=67703]adamhull[/MENTION]) said it is not needed... Quote Link to comment Share on other sites More sharing options...
AdamHull Posted August 26, 2015 Share Posted August 26, 2015 I always use INT(11) or BIGINT(25) depending on what for, the mod is now working, I removed the quotation marks, and didn't add in any back ticks, works fine now... And removed the endpage function (because @adamhull) said it is not needed... You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. is the function that has all the footer infromation and the die; function for Mccodes if i am correct and the engine you use has no use for it Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted August 26, 2015 Author Share Posted August 26, 2015 You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. is the function that has all the footer infromation and the die; function for Mccodes if i am correct and the engine you use has no use for it All the You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Functions have been removed.. So do I need the die; functions or not?.. Sorry I didn't quite understand that... Quote Link to comment Share on other sites More sharing options...
Dayo Posted August 26, 2015 Share Posted August 26, 2015 If you want the script to stop processing i.e. after showing an error message you will have to kill the page using die/exit. This was all done for you when using mccodes $h->endpage() function. Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted August 26, 2015 Share Posted August 26, 2015 edit check your error reporting for query's Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted August 27, 2015 Author Share Posted August 27, 2015 Got it working now.. Umm just a quick question? How can I get my game to support mobile devices? Quote Link to comment Share on other sites More sharing options...
~Rob0t Posted August 27, 2015 Share Posted August 27, 2015 Got it working now.. Umm just a quick question? How can I get my game to support mobile devices? Support mobile devices in what fashion? Quote Link to comment Share on other sites More sharing options...
-BRAIDZ- Posted August 27, 2015 Author Share Posted August 27, 2015 Support mobile devices in what fashion? Huh? I mean so when someone loads my game on a mobile device, it loads in like a mobile site? And you do have to zoom in constantly to see what you're doing Quote Link to comment Share on other sites More sharing options...
~Rob0t Posted August 27, 2015 Share Posted August 27, 2015 Huh? I mean so when someone loads my game on a mobile device, it loads in like a mobile site? And you do have to zoom in constantly to see what you're doing There we go - you're learning to be specific in your requests. You're going to need a script to detect the device the client is on. This won't be easy as I assume you don't use a template engine and everything is in one view (business logic and view logic) - so if you need help, open a new thread. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.