Jump to content
MakeWebGames

Random Hint


Miks

Recommended Posts

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]

randmessage.thumb.png.fcbd6d07a0d59dabdfab65bad1b15e8a.png

Link to comment
Share on other sites

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 by TheMasterGeneral
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...