Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have errors in your coding or want something specific added to your game? Check out our paid support here.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: Gym Level V2  (Read 749 times)

Coder

  • Basic Member
  • *
  • Reputation Power: 3
  • Coder has no influence.
  • Offline Offline
  • Posts: 4
    • View Profile
    • Email
Gym Level V2
« on: June 14, 2010, 02:09:10 AM »
This is my first mod ever. I know it is simple but i tmay be a bit useful I also liked to give credit to Sniko from who i got this idea from.

Please dont give rude comments it is my first mod ever

Here it goes first the queries:

ALTER TABLE `usersADD `gexp_neededdecimal(11,4NOT NULL default '50.0000';

ALTER TABLE `usersADD `gymlevelint(11NOT NULL default '1';

ALTER TABLE `usersADD `gymxpdecimal(11,4NOT NULL default '0.0000';


Then open up global_func.php and add this under above ?>
function check_gymlevel()
{
global 
$db;
global 
$ir,$c,$userid;

if(
$ir['gymxp'] >= $ir['gexp_needed'])
{
$gexpu=$ir['gymxp']-$ir['gexp_needed'];
$gneeded=$ir['gexp_needed']*$ir['gymlevel'];
$ir['gymlevel']+=1;
$ir['gymexp']=$gexpu;
$ir['gexp_needed']+=$gneeded;

$db->query("UPDATE users SET gymlevel=gymlevel+1,gymxp=$gexpu,gexp_needed=gexp_needed+$gneeded where userid=$userid");
}
}


Then open up globals.php and find
check_level();

add underneath
check_gymlevel();

Then open header.php and find

$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);
$wiperc=(int) ($ir['will']/$ir['maxwill']*100);
$experc=(int) ( $ir['exp']/$ir['exp_needed']*100);
$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);
$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);
$enopp=100-$enperc;
$wiopp=100-$wiperc;
$exopp=100-$experc;
$bropp=100-$brperc;
$hpopp=100-$hpperc;


Replace with:
$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);
$wiperc=(int) ($ir['will']/$ir['maxwill']*100);
$experc=(int) ( $ir['exp']/$ir['exp_needed']*100);
$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);
$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);
$gymperc=(int) ($ir['gymxp']/$ir['gexp_needed']*100);
$enopp=100-$enperc;
$wiopp=100-$wiperc;
$exopp=100-$experc;
$bropp=100-$brperc;
$hpopp=100-$hpperc;
$gymopp=100-$gymperc;


Then in the same file find
<b>Energy:</b> {$enperc}%<br />
<
img src=greenbar.png width=$enperc height=10><img src=redbar.png width=$enopp height=10><br />
<
b>Will:</b> {$wiperc}%<br />
<
img src=bluebar.png width=$wiperc height=10><img src=redbar.png width=$wiopp height=10><br />
<
b>Brave:</b> {$ir['brave']}/{$ir['maxbrave']}<br />
<
img src=yellowbar.png width=$brperc height=10><img src=redbar.png width=$bropp height=10><br />
<
b>EXP:</b> {$experc}%<br />
<
img src=navybar.png width=$experc height=10><img src=redbar.png width=$exopp height=10><br />
<
b>Health:</b> {$hpperc}%<br />
<
img src=greenbar.png width=$hpperc height=10><img src=redbar.png width=$hpopp height=10><br /><hr />


Add underneath:
<b>Gym Exp:</b> {$gymperc}%<br />

<
img src=greenbar.png width=$gymperc height=10><img src=redbar.png width=$gymopp height=10><br /><hr />



Then in header find:
<b>Crystals:</b> {$ir['crystals']}<br />

Add underneath
<b>Gym Level:</b> {$ir['gymlevel']}<br />

Then open Gym.php find

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");


replace it with

 else
{

$gain=0;
for(
$i=0$i<$_POST['amnt']; $i++)
{
$gain+=rand(1,3)/rand(800,1000)*rand(800,1000)*(($ir['will']+20)*(($ir['gymlevel']/rand(3,12))/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");
$db->query("UPDATE users SET gymxp=gymxp+{$_POST['amnt']} WHERE userid=$userid");



That is it i know it is a bit long but that is because i am not a good coder I hpe u like it.

P.S For People with a Gym Level Under 12 it sometimes decreases the gain of a stat then the normal one but once u have a gym level of lets say 20-30 u have a increase in the gain of a stat then the normal one


If there is prob plz post

Tested on my game

I am savage on MWG so plz dont think that i copyed this mod from there
Logged

kingdkknox

  • Basic Member
  • *
  • Reputation Power: 30
  • kingdkknox has no influence.
  • Offline Offline
  • Posts: 25
    • View Profile
    • WWW
Re: Gym Level V2
« Reply #1 on: June 14, 2010, 03:46:44 AM »
I hate to ask stupid questions which someone might say this is but what exactly does this do? Thanks!
Logged
If you are for hire or if you want to find some work it can be found here.
Freelance work at home jobs

Coder

  • Basic Member
  • *
  • Reputation Power: 3
  • Coder has no influence.
  • Offline Offline
  • Posts: 4
    • View Profile
    • Email
Re: Gym Level V2
« Reply #2 on: June 14, 2010, 09:54:53 PM »
It is a gym level everytime a person trains he gets gymxp and he gains higher gym levels the higher the gm level the more he will gain while training in the gym
Logged

vlad

  • Basic Member
  • *
  • Reputation Power: 3
  • vlad has no influence.
  • Offline Offline
  • Posts: 7
    • View Profile
    • WWW
    • Email
Re: Gym Level V2
« Reply #3 on: June 10, 2011, 10:13:39 AM »
Nice mod , will be using it :)
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.