MakeWebGames

# Exp doesn't work

## Recommended Posts

Hello, I'm having a few problems with getting crime exp to work, below is a screen print of what I have at the moment.

What I'm having problems with, is when I succeed a crime, the exp bar doesn't go up, does anyone have any ideas on what I need to do?

I'm guessing this would be in docrime.php if there was a error in the code?

If someone can confirm this, I'll paste it here, as I dont want to paste it if its not that file etc.

Thanks for any help that anyone can give :)

Edit - It also doesn't go up when I go to the gym.

##### Share on other sites

Re: Exp doesn't work

It will be in your php file where the crime is complete, e.g: docrime.php ;)

Looking at another post of yours this is your formula right:

((WILL*0.8)/2.5)+(LEVEL/4).

I think, your best bet is to make your formula give more exp.

Try...

((WILL*1.5)/2)+(LEVEL/2).

If that doesn't work or it gives out to much, then have a play around with it. Its pretty simple maths.

It may be a good idea to consider what level and how much will your character has when committing the crime.

##### Share on other sites

Re: Exp doesn't work

The formula that I had was already in the field, I added the one that you gave, and I didn't get any exp.

This is the docrime.php file I have

```<?php
\$macropage="docrime.php?c={\$_GET['c']}";
include "globals.php";
if(\$ir['jail'] or \$ir['hospital']) { die("This page cannot be accessed while in jail or hospital."); }
\$_GET['c']=abs((int) \$_GET['c']);
if(!\$_GET['c'])
{
print "Invalid crime";
}
else
{
\$q=mysql_query("SELECT * FROM crimes WHERE crimeID={\$_GET['c']}",\$c);
\$r=mysql_fetch_array(\$q);
if(\$ir['brave'] < \$r['crimeBRAVE'])
{
print "You do not have enough Brave to perform this crime.";
}
else
{
\$ec="\\$sucrate=".str_replace(array("LEVEL","CRIMEXP","EXP","WILL","IQ"), array(\$ir['level'], \$ir['crimexp'], \$ir['exp'], \$ir['will'], \$ir['IQ']),\$r['crimePERCFORM']).";";
eval(\$ec);
print \$r['crimeITEXT'];
\$ir['brave']-=\$r['crimeBRAVE'];
mysql_query("UPDATE users SET brave={\$ir['brave']} WHERE userid=\$userid",\$c);
if(rand(1,100) <= \$sucrate)
{
print str_replace("{money}",\$r['crimeSUCCESSMUNY'],\$r['crimeSTEXT']);
\$ir['money']+=\$r['crimeSUCCESSMUNY'];
\$ir['crystals']+=\$r['crimeSUCCESSCRYS'];
\$ir['exp']+=(int) (\$r['crimeSUCCESSMUNY']/8);
mysql_query("UPDATE users SET money={\$ir['money']}, crystals={\$ir['crystals']}, exp={\$ir['exp']},crimexp=crimexp+{\$r['crimeXP']} WHERE userid=\$userid",\$c);
if(\$r['crimeSUCCESSITEM'])
{
}
}
else
{
if(rand(1, 2) == 1)
{
print \$r['crimeFTEXT'];
}
else
{
print \$r['crimeJTEXT'];
\$db->query("UPDATE `users` SET `jail` = '\$r[crimeJAILTIME]', `jail_reason` = '\$r[crimeJREASON]' WHERE `userid` = '\$userid'");
}
}

print "
[url='docrime.php?c={\$_GET[']Try Again[/url]

[url='criminal.php']Crimes[/url]";
}
}

\$h->endpage();
?>```

I've only really just started php etc (within the last day or so), so its all pretty new to me, this started as something to mess about with in the holidays, and now its starting to annoy me that it wont work and I'm not sure why.

##### Share on other sites

Re: Exp doesn't work

Were talking about exp right, not that other field you have "crimexp"

Exp is based off this variable: \$ir['exp']+=(int) (\$r['crimeSUCCESSMUNY']/8);

So the user will be rewarded exp by dividing the crime success money by 8.

How much money do they get for completing the crime?

You could try diving it by less..

E.g: \$ir['exp']+=(int) (\$r['crimeSUCCESSMUNY']/4);

##### Share on other sites

Re: Exp doesn't work

Ah I see, seems to be working now, although the exp gains are way to high at the moment xD.

Although, the exp when going to the gym doesn't go up, any ideas?

##### Share on other sites

Re: Exp doesn't work

Ah I see, seems to be working now, although the exp gains are way to high at the moment xD.

Although, the exp when going to the gym doesn't go up, any ideas?

Your gonna have to edit the exp formula in your gym file.

##### Share on other sites

Re: Exp doesn't work

Ok, I'm either being really stupid (most likely) or its not there.

```<?php
\$macropage="gym.php";
include "globals.php";
\$statnames=array(
'Strength' => 'strength',
'Agility' => 'agility',
'Guard' => 'guard',
'Labour' => 'labour');
\$_POST['amnt']=abs((int) \$_POST['amnt']);
if(!\$ir['jail'])
{
print "<h3>Gym</h3><hr />";
}
else
{
print "<h3>Jail Gym</h3><hr />";
}
if(\$_POST['stat'] && \$_POST['amnt'])
{
\$stat=\$statnames[\$_POST['stat']];
if(!\$stat)
{
die("This stat cannot be trained.");
}
if(\$_POST['amnt'] > \$ir['energy'])
{
print("You do not have enough energy to train that much.<hr />");
}
else
{
\$gain=0;
for(\$i=0; \$i<\$_POST['amnt']; \$i++)
{
\$gain+=rand(1,3)/rand(800,1000)*rand(800,1000)*((\$ir['will']+20)/150);
\$ir['will']-=rand(1,3);
if(\$ir['will'] < 0) { \$ir['will']=0; }
}
if(\$ir['jail']) { \$gain/=2; }
\$db->query("UPDATE `userstats` SET `{\$stat}` = `{\$stat}` + \$gain WHERE `userid` = \$userid");
\$db->query("UPDATE `users` SET `will` = {\$ir['will']}, energy = energy - {\$_POST['amnt']} WHERE `userid` = \$userid");
\$inc=\$ir[\$stat]+\$gain;
\$inc2=\$ir['energy']-\$_POST['amnt'];
if(\$stat=="strength")
{
print "You begin lifting some weights.

You have gained {\$gain} strength by doing {\$_POST['amnt']} sets of weights.

You now have {\$inc} strength and {\$inc2} energy left.";
}
elseif(\$stat=="agility")
{
print "You begin running on a treadmill.

You have gained {\$gain} agility by doing {\$_POST['amnt']} minutes of running.

You now have {\$inc} agility and {\$inc2} energy left.";
}
elseif(\$stat=="guard")
{
print "You jump into the pool and begin swimming.

You have gained {\$gain} guard by doing {\$_POST['amnt']} minutes of swimming.

You now have {\$inc} guard and {\$inc2} energy left.";
}
elseif(\$stat=="labour")
{
print "You walk over to some boxes filled with gym equipment and start moving them.

You have gained {\$gain} labour by moving {\$_POST['amnt']} boxes.

You now have {\$inc} labour and {\$inc2} energy left.";
}
print "<hr />";
\$ir['energy']-=\$_POST['amnt'];
\$ir[\$stat]+=\$gain;
}
}
\$ir['strank']=get_rank(\$ir['strength'],'strength');
\$ir['agirank']=get_rank(\$ir['agility'],'agility');
\$ir['guarank']=get_rank(\$ir['guard'],'guard');
\$ir['labrank']=get_rank(\$ir['labour'],'labour');
print "Choose the stat you want to train and the times you want to train it.

You can train up to {\$ir['energy']} times.<hr />
<form action='gym.php' method='post'>
Stat: <select type='dropdown' name='stat'>
<option style='color:red;' value='Strength'>Strength (Have {\$ir['strength']}, Ranked {\$ir['strank']})
<option style='color:blue;' value='Agility'>Agility (Have {\$ir['agility']}, Ranked {\$ir['agirank']})
<option style='color:green;' value='Guard'>Guard (Have {\$ir['guard']}, Ranked {\$ir['guarank']})
<option style='color:brown;' value='Labour'>Labour (Have {\$ir['labour']}, Ranked {\$ir['labrank']})
</select>

Times to train: <input type='text' name='amnt' value='{\$ir['energy']}' />

<input type='submit' value='Train' /></form>";
\$h->endpage();
?>
```

I cant see anything that could be to do with Exp, am I missing it? Or is it not there?.

Thanks.

##### Share on other sites

Re: Exp doesn't work

This script does not update the exp column at all. So your gonna have to add it.

Replace

```\$db->query("UPDATE `users` SET `will` = {\$ir['will']}, energy = energy - {\$_POST['amnt']}
WHERE `userid` = \$userid");```

With:

```\$db->query("UPDATE `users` SET `will` = ".\$ir['will'].",
`energy` = `energy` - ".\$_POST['amnt'].", `exp` = `exp` + ".\$exp."
WHERE `userid` = ".\$userid." ");```

`\$exp = \$gain / 2; // The amount of experience `

Hopefully this should work ;)

##### Share on other sites

Re: Exp doesn't work

Yay, thanks so much for that :D.

##### Share on other sites

Re: Exp doesn't work

Were talking about exp right, not that other field you have "crimexp"

Exp is based off this variable: \$ir['exp']+=(int) (\$r['crimeSUCCESSMUNY']/8);

So the user will be rewarded exp by dividing the crime success money by 8.

How much money do they get for completing the crime?

You could try diving it by less..

E.g: \$ir['exp']+=(int) (\$r['crimeSUCCESSMUNY']/4);

Right....this is annoying:

where do I find: \$ir['exp']+=(int) (\$r['crimeSUCCESSMUNY']/8);

:-P

##### Share on other sites

Re: Exp doesn't work

Guessing it could be docrime.php (not sure)

##### Share on other sites

Re: Exp doesn't work

Nopes....lol.

But thanks. :)

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.