how to get the HP to refresh the actual numbers
how to get the HP to refresh the actual numbers
Ok, i set the restore_rate= 0 from user_stat_types on myphpadmin. so i can stop the restore HP.
here is my module to reduce HP, it works! But the HP doesn't refresh it self. i verified it through the database and the numbers dropped but the website didn't. How can i refresh the HP on the website to show the actual numbers that are left?
$result = $db->Execute("select value from user_stats where stat_type = ?",1);
$hp = $result->fields[0];
header("Location: index.php");
$reducer = $hp - 5;
$db->Execute("update user_stats set value = $reducer WHERE stat_type = ?",1);
if ($hp < 6)
{
$result = $db->Execute("select value from user_stats where stat_type = ?",1);
$hp = $result->fields[0];
$add = $hp + 1;
$db->Execute("update user_stats set value = $add WHERE stat_type = ?",1);
}
here is my module to reduce HP, it works! But the HP doesn't refresh it self. i verified it through the database and the numbers dropped but the website didn't. How can i refresh the HP on the website to show the actual numbers that are left?
$result = $db->Execute("select value from user_stats where stat_type = ?",1);
$hp = $result->fields[0];
header("Location: index.php");
$reducer = $hp - 5;
$db->Execute("update user_stats set value = $reducer WHERE stat_type = ?",1);
if ($hp < 6)
{
$result = $db->Execute("select value from user_stats where stat_type = ?",1);
$hp = $result->fields[0];
$add = $hp + 1;
$db->Execute("update user_stats set value = $add WHERE stat_type = ?",1);
}
- a_bertrand
- Posts: 1536
- Joined: Mon Feb 25, 2013 1:46 pm
Re: how to get the HP to refresh the actual numbers
The engine cache those value in the session, and only reload while loggin in or if you set stats_modified (in the users table) to yes
Creator of Dot World Maker
Mad programmer and annoying composer
Mad programmer and annoying composer
- KyleMassacre
- Posts: 573
- Joined: Wed Nov 27, 2013 12:42 pm
Re: how to get the HP to refresh the actual numbers
I could be wrong and bert can correct me if so but I think if you use the $userStats you maybe able to achieve what you wish
Re: how to get the HP to refresh the actual numbers
Yeah! I added $userStat, It works! Thanks guys! I have 2 more question. How do I select all user from the database? I tried the * Sign for: where user_id =?",*)and fail and another question, If I change the stat modifed to yes will that slow the game down a bit?
- KyleMassacre
- Posts: 573
- Joined: Wed Nov 27, 2013 12:42 pm
Re: how to get the HP to refresh the actual numbers
KaL wrote:Yeah! I added $userStat, It works! Thanks guys! I have 2 more question. How do I select all user from the database? I tried the * Sign for: where user_id =?",*)and fail and another question, If I change the stat modifed to yes will that slow the game down a bit?
- Your very welcome
-
Code: Select all
$users = $db->Execute("select * from users where id = ?",$someUserId); - Well with any query you are adding a bit of strain. Its best to be as optimal as you can when dealing with any kind of database manipulation. So to put it into laments terms, as long as you are limiting you update or select queries or whatever have you by using some sort of clause like "WHERE" or a "LIMIT" you should be fine.
Code: Select all
$stats = UserStat::LoadStats($users->fields[0]);
$stats['!Currency']->value += $someValue;
UserStat::SaveStats($stats, $users->fields[0]);
And another thing you should avoid using wildcards because that may produce unnecessary strain as well. Just select the fields you know your going to use.
- a_bertrand
- Posts: 1536
- Joined: Mon Feb 25, 2013 1:46 pm
Re: how to get the HP to refresh the actual numbers
Creator of Dot World Maker
Mad programmer and annoying composer
Mad programmer and annoying composer
- KyleMassacre
- Posts: 573
- Joined: Wed Nov 27, 2013 12:42 pm
Re: how to get the HP to refresh the actual numbers
Well in my defense it was a tricky question. Did he want all the users or all the users info?a_bertrand wrote:if you want to query all users, you don't put a condition
Code: Select all
select * from users
Since he did have the condition I just went with thatKal wrote: How do I select all user from the database? I tried the * Sign for: where user_id =?",*)
Re: how to get the HP to refresh the actual numbers
Thanks for the help again! I just learned how to use userstat load and save command now. This will come in handy! 
- a_bertrand
- Posts: 1536
- Joined: Mon Feb 25, 2013 1:46 pm
Re: how to get the HP to refresh the actual numbers
the user stats should load and save automatically. You normally don't need to call those functions. What are you doing?
Creator of Dot World Maker
Mad programmer and annoying composer
Mad programmer and annoying composer
Re: how to get the HP to refresh the actual numbers
I''m trying to build a module that will reduce all players HP every hour even if they are offline. This will then make all the item food in the game more unique. But i can't seem to get the cronjobs (host provider) to run it. I got it to work using the cron engine to run it daily= daily_cron.php. Is there something i'm missing?