Jump to content
MakeWebGames

Recommended Posts

Posted

So i've decided to revisit this project with a fresh outlook. So aside from just requesting a an overly complicated modification that asks to remove/add stats and recode the entire engine i'll start with another.

How does one simply add additional "new" stats? Lets say.... Vitality.

I appreciate any time taken out to answer this

Posted

A number of things to consider when adding new stats.

*The userstats table in the db. It would need the new column.

*On registration, the adding of the new stat into the query alongside the other values.

*Increasing the stat. Should be easy to replicate any such methods, like the gym or the school.

*Using the stat. If the stat is to become a dependent factor in battles, the attack will need modified.

Posted

I will attempt this on my own and get back to you. I hope this to be the first in my learning experience regarding what I'd like to do. Thank you

Posted

here is what i have edited thus far;

db userstats table

CREATE TABLE `userstats` (

`userid` int(11) NOT NULL default '0',

`strength` decimal(11,4) NOT NULL default '0.0000',

`agility` decimal(11,4) NOT NULL default '0.0000',

`vitality` decimal(11,4) NOT NULL default '0.0000',

`IQ` decimal(11,4) NOT NULL default '0.000000'

`guile` decimal(11,4) NOT NULL default '0.000000'

`spirit` decimal(11,4) NOT NULL default '0.000000'

) ENGINE=MyISAM ;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Register

$db->query("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$IP', '$IP')");

$i=$db->insert_id();

$db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10)");

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

loggedin

$ts=$ir['strength']+$ir['agility']+$ir['vitality']+$ir['IQ']+$ir['guile']+$ir['spirit'];

$ir['strank']=get_rank($ir['strength'],'strength');

$ir['agirank']=get_rank($ir['agility'],'agility');

$ir['vitrank']=get_rank($ir['vitality'],'vitality');

$ir['IQrank']=get_rank($ir['IQ'],'IQ');

$ir['guirank']=get_rank($ir['guile'],'guile');

$ir['sptrank']=get_rank($ir['spirit'],'spirit');

$tsrank=get_rank($ts,'strength+agility+vitality+IQ+guile+spirit');

$ir['strength']=number_format($ir['strength']);

$ir['agility']=number_format($ir['agility']);

$ir['vitality']=number_format($ir['vitality']);

$ir['spirit']=number_format($ir['spirit']);

$ir['IQ']=number_format($ir['IQ']);

$ir['guile']=number_format($ir['guile']);

$ir['spirit']=number_format($ir['spirit']);

$ts=number_format($ts);

print <<<OUT

<tr>

<td class="h" colspan="2"><b>Stats Info</b></td></tr>

<tr>

<td><b>Strength:</b> {$ir['strength']} [Ranked: {$ir['strank']}]</td>

<td><b>Agility:</b> {$ir['agility']} [Ranked: {$ir['agirank']}]</td>

<td><b>Vitality:</b> {$ir['vitality']} [Ranked: {$ir['vitrank']}]</td></tr>

<tr>

<td><b>Intelligence:</b> {$ir['IQ']} [Ranked: {$ir['IQrank']}]</td>

<td><b>Guile:</b> {$ir['guile']} [Ranked: {$ir['guirank']}]</td>

<td><b>Spirit:</b> {$ir['spirit']} [Ranked: {$ir['sptrank']}]</td></tr>

I am still receiving the same error...;

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND us.userid != 1 AND u.user_level != 0' at line 1

Query was SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.vitality > AND us.userid != 1 AND u.user_level != 0

 

Perhaps i'm starting to large or I am missing something else. maybeI I should reset everything to default and try adding in one statistic at a time. Anythoughts ?

Posted
WHERE us.vitality > AND us.userid != 1

If you get a SQL error, try reading the query in normal english. This line reads "Where userstats.vitality is greater than AND userstats.userid is not equal to 1"

You missed something there.

Posted

$db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10)");

You added stats you need to add it to the values there is only 6 there should be 7.

1---`userid` int(11) NOT NULL default '0',

2---`strength` decimal(11,4) NOT NULL default '0.0000',

3---`agility` decimal(11,4) NOT NULL default '0.0000',

4---`vitality` decimal(11,4) NOT NULL default '0.0000',

5---`IQ` decimal(11,4) NOT NULL default '0.000000'

6---`guile` decimal(11,4) NOT NULL default '0.000000'

7---`spirit` decimal(11,4) NOT NULL default '0.000000'

should be...

$db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10,10)");

Posted

Changed the amount of values in .register and came up with this error while creating another user for testing purposes.

 

QUERY ERROR: Column count doesn't match value count at row 1

Query was INSERT INTO userstats VALUES(7, 10, 10, 10, 10, 10, 10, 10)

 

and after subsequently received another error while testing under a different user ;

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND us.userid != 2 AND u.user_level != 0' at line 1

Query was SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.strength > AND us.userid != 2 AND u.user_level != 0

So what could cause the error to change when the only variable is the user ?

Posted (edited)

It should if you do not have it there... all your stats in your table should be set to 10.0000

These werent...

5---`IQ` decimal(11,4) NOT NULL default '0.000000'

6---`guile` decimal(11,4) NOT NULL default '0.000000'

7---`spirit` decimal(11,4) NOT NULL default '0.000000'

11,4

4 is the zeros after the decimal... 11 is for numbers before the dec..

what page is this from

SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.strength > AND us.userid != 2 AND u.user_level != 0

the problem with that is userlevel... or after that...post that part.

Edited by lucky3809
Posted

Both errors are recieved via loggedin.

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND us.userid != 1 AND u.user_level != 0' at line 1

Query was SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.vitality > AND us.userid != 1 AND u.user_level != 0

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND us.userid != 2 AND u.user_level != 0' at line 1

Query was SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.strength > AND us.userid != 2 AND u.user_level != 0

Posted

here is what i have in for loggedin.php

 

<?php

$housequery=1;

include "globals.php";

print "<b>Welcome, {$ir['username']}!</b><br />

<em>Your last visit was: $lv.</em>";

$q=$db->query("SELECT * FROM papercontent LIMIT 1",$c);

$content=$db->fetch_single($q);

$exp=(int)($ir['exp']/$ir['exp_needed']*100);

if ($ir['hospital'])

$geninf = '<tr><td colspan="2"><font color="red">You are in Hospital for ' . $ir['hospital'] . ' minute(s)</font></td></tr>';

elseif ($ir['jail'])

$geninf = '<tr><td colspan="2"><font color="red">You are in Jail for ' . $ir['jail'] . ' minute(s)</font></td></tr>';

else

$geninf = '';

print <<<OUT

<table cellspacing="1" border="0" cellpadding="3" class="table" width="70%">

<tr><td colspan="2" class="h"><b>General Information</b></td></tr>

{$geninf}

<tr>

<td><b>Name:</b> {$ir['username']}</td>

<td><b>Crystals:</b> {$cm}</td>

</tr>

<tr>

<td><b>Level:</b> {$ir['level']}</td>

<td><b>Exp:</b> {$exp}%</td>

</tr>

<tr>

<td><b>Wong:</b> $fm</td>

<td><b>HP:</b> {$ir['hp']}/{$ir['maxhp']}</td>

</tr>

<tr>

<td><b>Property:</b> {$ir['hNAME']}</td>

<td><b>Days Old:</b> {$ir['daysold']}</td>

</tr>

OUT;

$ts=$ir['strength']+$ir['agility']+$ir['vitality']+$ir['IQ']+$ir['guile']+$ir['spirit'];

$ir['strank']=get_rank($ir['strength'],'strength');

$ir['agirank']=get_rank($ir['agility'],'agility');

$ir['vitrank']=get_rank($ir['vitality'],'vitality');

$ir['IQrank']=get_rank($ir['IQ'],'IQ');

$ir['guirank']=get_rank($ir['guile'],'guile');

$ir['sptrank']=get_rank($ir['spirit'],'spirit');

$tsrank=get_rank($ts,'strength+agility+vitality+IQ+guile+spirit');

$ir['strength']=number_format($ir['strength']);

$ir['agility']=number_format($ir['agility']);

$ir['vitality']=number_format($ir['vitality']);

$ir['spirit']=number_format($ir['spirit']);

$ir['IQ']=number_format($ir['IQ']);

$ir['guile']=number_format($ir['guile']);

$ir['spirit']=number_format($ir['spirit']);

$ts=number_format($ts);

print <<<OUT

<tr>

<td class="h" colspan="2"><b>Stats Info</b></td></tr>

<tr>

<td><b>Strength:</b> {$ir['strength']} [Ranked: {$ir['strank']}]</td>

<td><b>Agility:</b> {$ir['agility']} [Ranked: {$ir['agirank']}]</td>

<td><b>Vitality:</b> {$ir['vitality']} [Ranked: {$ir['vitrank']}]</td></tr>

<tr>

<td><b>Intelligence:</b> {$ir['IQ']} [Ranked: {$ir['IQrank']}]</td>

<td><b>Guile:</b> {$ir['guile']} [Ranked: {$ir['guirank']}]</td>

<td><b>Spirit:</b> {$ir['spirit']} [Ranked: {$ir['sptrank']}]</td></tr>

 

</tr>

</table>

OUT;

print "{$set['game_name']} Latest News:<br />

$content<br />

";

$h->endpage();

?>

Posted

I already said those SQL errors are a result of the > symbol. You are setting a parameter for something being greater than and nothing else. In effect it's value > _______ , with the line representing a blank

Posted

So somewhere within db SQL there is an > symbol floating around ? If so I havn't seen it. I'm still having trouble identifying where the error itself is originating from...

Thanks for the patience, i'll go back and look over each file carefully.

Posted (edited)

If your getting the error from the gym you need to add your new stats to the gym also.

As for the rank in global_func.php is calling $stat which is your query error, which I have only seen $stat in gym.php

$statnames=array(

'Strength' => 'strength',

'Agility' => 'agility',

'Guard' => 'guard',

'Labour' => 'labour');

that part you need to add those new stats to.

 

this is the query your having problems with

function get_rank($stat, $mykey)

{

global $db;

global $ir,$userid,$c;

$q=$db->query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.$mykey > $stat AND us.userid != $userid AND u.user_level != 0") ;

return $db->fetch_single($q)+1;

}

Edited by lucky3809
Posted

statnames=array is present with additional names. Still receiving error...

perhaps somewhere in 'loggedin' or 'index' ?

Posted

I'm going to call it a night and mull this over. maybe set all the pages to default and try adding just one stat at a time.

Posted
QUERY ERROR: Column count doesn't match value count at row 1

Query was INSERT INTO userstats VALUES(7, 10, 10, 10, 10, 10, 10, 10)

This is an issue here, you but only 6 values in before, and then you took 5 and added 7, so now you have

1. $i

2. 10

3. 10

4. 10

5. 10

6. 10

7. 10

8. 10

Get rid of the last '10' from

($i, 10, 10, 10, 10, 10, 10, 10)

Should be ok after that :)

Posted (edited)

He needs 7 values thats how many fields he has in userstats table

1---`userid` int(11) NOT NULL default '0',

2---`strength` decimal(11,4) NOT NULL default '0.0000',

3---`agility` decimal(11,4) NOT NULL default '0.0000',

4---`vitality` decimal(11,4) NOT NULL default '0.0000',

5---`IQ` decimal(11,4) NOT NULL default '0.000000'

6---`guile` decimal(11,4) NOT NULL default '0.000000'

7---`spirit` decimal(11,4) NOT NULL default '0.000000'

should be...

$db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10,10)");

His problem is the query in global_func the rank

function get_rank($stat, $mykey)

{

global $db;

global $ir,$userid,$c;

$q=$db->query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.$mykey > $stat AND us.userid != $userid AND u.user_level != 0") ;

return $db->fetch_single($q)+1;

}

 

where

$mykey>$stat

$mykey is in config.php which is the code for crons...

$stat is the array table in gym.php

 

$statnames=array(

'Strength' => 'strength',

'Agility' => 'agility',

'Guard' => 'guard',

'Labour' => 'labour');

 

also when he altered the userstats table he has more zero's then there should be, when he is using 11,4 decimal.

Edited by lucky3809
Posted (edited)

lol my bad all this time i thought 11,4 meant

11 numbers here >11111111111.0000<4 numbers here.

I guess it pays to read from the mysql site.

Edited by lucky3809
  • 2 months later...
Posted (edited)

Trying to re- energize this conversation: What pages should I post?

I will post them in their entirety.

IF this task is too much to do on my own given my relativity low mysql/php scripting skills I will say , if i havn't before. I am willing to pay to have this modification done.

My health is beginning to decline again and I would like to finish before the summer is through.

Thank you for your patience.

Edited by Roh

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