Jump to content
MakeWebGames

Update Vitals in Template


wrux

Recommended Posts

This is a subtle modification. It basically just updates the details in the sidebar (energy, hp, money, mail notifications etc) using JSON. I've seen other implementations of this, just getting the entire sidebar which isn't necessary so I just created a nicer way to do it.

I have written a more in-depth explanation of it on my dev blog here which explains how to install it in more detail; probably a good idea if you are relatively new. To install this modification it basically requires a few edits to the template and uploading the javascript file and php file.

I do not have the latest version of mccodes, so this may be outdated for some, however feel free to update it for me :P

Heres the PHP code:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

And heres the JavaScript code:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Edited by wrux
  • Like 1
Link to comment
Share on other sites

Very nice clean implementation. Good to see decent use of commenting.

Maybe you should detect if the browser window is in focus? Or you'll potentially be making requests whilst the player isn't even looking at the site.

Link to comment
Share on other sites

i must be a complete idiot of something, but what does it exactly do....

Well normally you would have to reload the page to see your updated energy and stuff if it's been a few minutes, this will load it automatically without having to reload.

Link to comment
Share on other sites

Very nice clean implementation. Good to see decent use of commenting.

Maybe you should detect if the browser window is in focus? Or you'll potentially be making requests whilst the player isn't even looking at the site.

Yea I make might make a revision for that another day. It was really just an attempt to show people that things can be done differently

Link to comment
Share on other sites

I am really confused. Where do I add what?

You need them two on your server. Make sure jQuery and the javascript file I posted are loaded. After that you then need open up header.php and wrap all the numbers to update in a corresponding span tag.

An example: <span class="label" data-value="energypercent">{$enperc}</span>

the data-value tag needs to be set to the variable to update it to. Another example (sets the mail notifications if the player has any):

<span class="label" data-value="new_mail">{$ir['new_mail']}</span>

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

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