Page 1 of 1

User Stats

Posted: Sun Mar 23, 2014 10:29 pm
by cyborg
I'm currently working on a layout for my game, and I would like certain stats to appear is set locations. I understand that I would need recreate the stats module, and maybe look at passing the data through a multidimensional array. Is that the best way to go about it? any tips would be extremely welcome. Thanks

Re: User Stats

Posted: Mon Mar 24, 2014 5:20 am
by a_bertrand
Not sure what you want here. Is that the user profile you want to redo? Such that you can see other players stats? Or is it the stats on top of the page?

Re: User Stats

Posted: Mon Mar 24, 2014 6:21 am
by cyborg
Sorry it's the stats at the top of the page; level, experience, AP etc with the maxValue as well.

Edit - just had a thought about changing the for loop from outputting the data to putting it into an array. Could that work? I did try putting in an array but got an error but I think I didn't put it into a multi array

Re: User Stats

Posted: Mon Mar 24, 2014 1:03 pm
by a_bertrand
You should rewrite the module stats then, and display what you want.

Re: User Stats

Posted: Mon Mar 24, 2014 10:59 pm
by cyborg
okay i've made a start:

Code: Select all

$search = $db->Execute("select user_stats.*,user_stat_types.*
				from user_stats
				left join user_stat_types
				on user_stat_types.id=user_stats.stat_type where user_id = ?", $userId);
	if ($search->EOF)			
        return array();
        $display = $search->fields['name']. " " . $search->fields['value'];
        echo $display		
        $search->Close();
	
What I get back is:

Code: Select all

Health 100
Which is exactly what I wanted. However, it only puts the health information into an array. How do I add, the XP, Level etc into another array? is there code already available in the engine that could help me?

Thanks!

Re: User Stats

Posted: Tue Mar 25, 2014 5:05 am
by a_bertrand
Here you should start to check out what a loop is, and how to do it. Sorry but those are really basic things, and I'm not sure if I fix your code you will actually learn it.

Re: User Stats

Posted: Tue Mar 25, 2014 6:51 am
by KaL
So you want to put your stats in a different order? or you want to add additional stats: "MaxValue" on top? or you want to display Health in a set location: "Health" display in location= 5 only (block all display of stats at this location= 5)

i'm confuse too on what you really want?

Re: User Stats

Posted: Tue Mar 25, 2014 9:50 pm
by cyborg
I want to show XP, Health and AP in the forms of bars, so need the data to be able to produce those. I've tried a couple of while loops but not having much luck at the moment. Will battle on

Re: User Stats

Posted: Wed Mar 26, 2014 6:54 am
by KaL
maybe try to make it simple as possible. ok, lets try using a table as a "BAR" and the background as filling the "BAR"

for example:

if 445HP = 100% So for every 1% = 4.45HP.

Now take the percentage from the background size and replace it with a variable"

for example:

background health size= $Hp ">


every time the player click on the attack or defend button it will give you a damage of:

for example:

222 damage! (which is equal to 48.88% of HP, which also the size of the background)

pretty much create a table with a color background and adjust the size of the background base on the outcome damage.
i hope that helps. if not i sux! :lol: