Jump to content
MakeWebGames

Adding stats into a Streets Mod.


Recommended Posts

Greetings, I am starting for the first time a thread. I am sure this is basic knowledge but I have, as yet, been unable to discover where it is hidden away.

I would like to add a random amount of stats for my players as they do there steps in the streets mod.

This would be chance 16 of quite a bit.

if ($chance == 16) {

$gained=rand(2,9)*$ir['level'];

print "While , you come across an old tree. Using your might, you knock it down gaining <b>/$gained strength.</b>;

$db->query('UPDATE `userstats` SET `strength'=strength + $gained');

";

}

Ok, here is the out put from doing this step...

While , you come across an old tree. Using your might, you knock it down gaining /300 strength.; ('UPDATE `userstats` SET `strength'=strength + 300');

 

Obviously it should not look like that. It is also not adding the strength to the player stats.

Any help on this would be much appreciated. Although I would like to know what this particular piece of code is, I plan on adding this in to a lot of steps for different stats and hope that a simple generic code string would work. I appreciate your time.

Link to comment
Share on other sites

Problem is you have the query within the print statement. You should do the query, then print the message of "You gain blah...".

if ($chance == 16) {

$gained=rand(2,9)*$ir['level'];

$db->query('UPDATE `userstats` SET `strength'=strength + $gained');

print "While , you come across an old tree. Using your might, you knock it down gaining <b>/$gained strength.</b>;

";

}

adjusted it now getting this error...

Parse error: syntax error, unexpected '=' in /home/thebo41/public_html/street.php on line 106

So I still have some sort of error in the code string.

Link to comment
Share on other sites

Which line is 106?

 

if ($chance == 16) 
{ 
$gained=rand(2,9)*$ir['level'];
$db->query("UPDATE userstats SET strength=strength+{$gained} WHERE userid={$ir['userid']}");
print "You come across an old tree. Using your might, you knock it down gaining <b>{$gained} strength.</b>"; 
} 

 

Try copying that. Should work ok.

Edited by bineye
Added WHERE clause
  • Like 1
Link to comment
Share on other sites

Which line is 106?

 

if ($chance == 16) 
{ 
$gained=rand(2,9)*$ir['level'];
$db->query("UPDATE userstats SET strength=strength+{$gained} WHERE userid={$ir['userid']}");

 

*facepalm* I have been looking at these lines for so long that I forgot to mention which line 106 was. It would have been the third line in my post.

 

Change the query to this;

[php]$db->query("UPDATE `userstats` SET `strength'=strength + $gained");[/php]

 
 
 
 
print "You come across an old tree. Using your might, you knock it down gaining <b>{$gained} strength.</b>"; 
} 

Try copying that. Should work ok.

Sorry yours did not work though.

Thank you bineye!!! Plus one for you!!

Edited by The Bonded Game
Noob Failure on quotes
Link to comment
Share on other sites

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