Page 1 of 1
					
				1 round behind
				Posted: Wed Apr 21, 2010 2:31 am
				by Kirbie
				Has anyone noticed that you are 1 round behind on taking and recceiving damage. I also noticed the the bank ( which the bank tut is cool) is also a round behind on showing a trans action. Is there any way to make these action a real time with out clicking twice or refreshing to get correct amount?
			 
			
					
				Re: 1 round behind
				Posted: Wed Apr 21, 2010 4:23 am
				by Jackolantern
				Welcome to PHP 

 If you want real-time, you will have to use a client-side technology such as Javascript/AJAX. PHP is server-side, so to get new info you have to hit the server and refresh the page, so it is going to appear as though it is one round behind.
 
			
					
				Re: 1 round behind
				Posted: Wed Apr 21, 2010 12:57 pm
				by Kirbie
				Works for me.....thanks
			 
			
					
				Re: 1 round behind
				Posted: Wed Apr 21, 2010 7:18 pm
				by Jackolantern
				I think some of Halls' video tutorials cover some Javascript and AJAX. I know that his games he has released the code for use AJAX pretty extensively, so even if it is not in any of the videos yet (check the Urban Realms videos to see if any is in there), you could at least study it a bit and possibly customize it for your uses 

 
			
					
				Re: 1 round behind
				Posted: Thu Apr 22, 2010 2:44 am
				by Kirbie
				I will have a look into that. thanks
			 
			
					
				Re: 1 round behind
				Posted: Thu Apr 22, 2010 6:13 pm
				by Gustava
				I ran into this a while back and didn't like how it appeared to lag, so I just recalled it right before it was supposed to post.
Call it,
Calculate,
Recall it,
Post to page.
So say it's 1 round behind on giving you damage. The damage will be 5. *shrugs*
I'm guessing you have something like
Code: Select all
$userhp="SELECT from user_stats where yada yada'"; To retrieve their stats
$battle_damage = 5
$userhp = $userhp - $battle_damage
Your hp: $userhp
Rough example. So that's calling it, calculating, and posting to page. To make it real time just add this in,
$userhp="SELECT from user_stats where yada yada'"; To retrieve their stats
$battle_damage = 5
$userhp = $userhp - $battle_damage
$userhp="SELECT from user_stats where yada yada'"; To retrieve their stats - Updates whatever you calculated
Your hp: $userhp
I don't really know if that's good code practice or not but it has been working fine for me for as long as I can remember.
 
			
					
				Re: 1 round behind
				Posted: Fri Apr 23, 2010 12:36 am
				by hallsofvallhalla
				yes just call the display code after you update it. So update then query then display.