Miks Posted March 31, 2015 Share Posted March 31, 2015 I created something very basic but adds another element to your game. You can display random game tips at the top of your pages Create a page called randmessage.php You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Then on the pages you want to include the random tip you have to put this line of code You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Theres no styles so you can simply drop it into your current design, all you need to do is play with the location of the include path so it displays in the right place [ATTACH=CONFIG]1865[/ATTACH] Quote Link to comment Share on other sites More sharing options...
Miks Posted April 1, 2015 Author Share Posted April 1, 2015 Users that have played the game for awhile might not want to see the tips so you can change the if statements to 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...
TheMasterGeneral Posted April 1, 2015 Share Posted April 1, 2015 (edited) A nice little addon. However, I would have done something like: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Also, maybe you could implement it in SQL, so you don't have to manually enter the files? It'd be something like: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Probably won't work, but you get the idea. Edited April 1, 2015 by TheMasterGeneral Quote Link to comment Share on other sites More sharing options...
Miks Posted April 1, 2015 Author Share Posted April 1, 2015 Thank you, I will probably update it using your SQL suggestion and allow staff to insert tips easier I'm pretty sure I know how to do it but how would I set the max random number? Can the random maximum number be a variable of a row count query or something? Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 1, 2015 Share Posted April 1, 2015 Thank you, I will probably update it using your SQL suggestion and allow staff to insert tips easier I'm pretty sure I know how to do it but how would I set the max random number? Can the random maximum number be a variable of a row count query or something? Yeah, or I think you may be able to use SQL Rand(): 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...
NonStopCoding Posted April 1, 2015 Share Posted April 1, 2015 Yeah, or I think you may be able to use SQL Rand(): You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Yea that will work and bring up a new hint every time page is refreshed and is much less code Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted April 1, 2015 Share Posted April 1, 2015 Thank you, I will probably update it using your SQL suggestion and allow staff to insert tips easier[...] Done: https://bitbucket.org/Magictallguy/mwg-hints Quote Link to comment Share on other sites More sharing options...
Miks Posted April 1, 2015 Author Share Posted April 1, 2015 [MENTION=53425]Magictallguy[/MENTION] haha awesome! Works great! Quote Link to comment Share on other sites More sharing options...
SRB Posted April 2, 2015 Share Posted April 2, 2015 @Magictallguy haha awesome! Works great! As an addition to this, it's worth considering throwing the data into a session to cut down on queries. This code will load all hints into sessions on the first load, which means after that, you can randomly load them from an array without querying the database ... again! 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...
Magictallguy Posted April 2, 2015 Share Posted April 2, 2015 As an addition to this, it's worth considering throwing the data into a session to cut down on queries. This code will load all hints into sessions on the first load, which means after that, you can randomly load them from an array without querying the database ... again! You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Updated my repo with your idea, thanks :) 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.