Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h06/mnt/10927/domains/dragonprime.net/html/Sources/Load.php(225) : runtime-created function on line 3
Discussion: Auto Level Up
DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • September 17, 2019, 07:54:49 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1] 2   Go Down
  Print  
Author Topic: Discussion: Auto Level Up  (Read 10177 times)
0 Members and 1 Guest are viewing this topic.
MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1752


View Profile
« on: April 05, 2012, 10:05:07 AM »

This is the discussion thread for the module Auto Level up (autolevel.php).

It is a modified version of Thanatos' 'forestprefs' module. I've basically just stripped everything out apart from the levelling up code and tweaked it a bit. Smiley

Aeolus wanted this and it was something I thought others would like so here you go. Cheesy

Feedback and bugs in here please. Smiley

File Submission: Here
File Download: Here

Edit:
New version 1.0.1 uploaded.

16/08/2018 - v1.0.2 + Added code for referrals and companions.
« Last Edit: August 16, 2018, 08:41:45 AM by MarcTheSlayer » Logged

Check My Modules for the latest versions.
Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #1 on: April 05, 2012, 10:11:27 AM »

Be great if you had a link in the thread that linked to the File Submission.. Wink

And if you'd posted this several hours earlier, you would have saved me a ton of trouble XD I was attempting the same thing.
Logged

MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1752


View Profile
« Reply #2 on: April 05, 2012, 10:18:04 AM »

Yeah sorry dude, pizza got in the way of me posting the file earlier. Cheesy
Logged

Check My Modules for the latest versions.
Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1065



View Profile WWW
« Reply #3 on: April 20, 2012, 01:52:34 AM »

It levels you with each fight.  You dont even have to make the exp first.  You just fight a creature and then beat them and bam you level up.  Is there a fix?  That way it calls for the full level exp first before giving you the next level gain..
« Last Edit: May 20, 2012, 07:38:14 PM by Megan|SaraBeth » Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #4 on: April 20, 2012, 02:18:25 AM »

It levels you with each fight.  You dont eve have to make the exp first.  You just fight a creature and then beat them and bam you level up.  Is there a fix?  That way it calls for the full level exp first before giving you the next level gain..

Fixed and attached.

Afkamm, you forgot a line of code xD

Code:
$level = $session['user']['level'];

You had this line in the module:

Code:
$reqexp = exp_for_next_level($level,$dks);

But you didn't have anything defining what $level was.  Wink

EDIT: I also added a line of code that increase the players temporary hitpoints after they level as well as their permanent hitpoints, as would happen if you fought your masters the normal way.
« Last Edit: April 20, 2012, 02:48:52 AM by Aeolus » Logged

MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1752


View Profile
« Reply #5 on: April 22, 2012, 07:40:01 AM »

Thanks for that Aeolus. Smiley
Logged

Check My Modules for the latest versions.
Nder'
Codemeister
****
Offline Offline

Posts: 256


Google is our savior!


View Profile
« Reply #6 on: March 31, 2013, 11:47:25 AM »

Old topic but a quick question none the less.

Since the module hooks into all kinds of level ups, I tried to implement Stephen's Clan Points Module.

I tried using the following code but I get a error saying there's a missing string somewhere. Any ideas?


Code:
<?php
/**
Modified by MarcTheSlayer
05/04/2012 - v1.0.0
+ This is a modified version of the module 'forestprefs' by Thanatos.
  I've stripped out everything apart from the code to allow auto levelling
  in the forest when the player has enough experience for the next level.
+ Changed the file name to suit its function.
*/
function autolevel_getmoduleinfo()
{
$info = array(
"name"=>"Auto Level Up",
"description"=>"Allow players to auto level up in the forest instead of fighting a Master.",
"version"=>"1.0.0",
"author"=>"`4Thanatos`2, modified by `@MarcTheSlayer",
"category"=>"Forest",
"settings"=>array(
"levellimit"=>"Maximum level that can be gained:,int|15",
"`2If you have modified your game to have more levels than 15 then enter the highest level here else leave it at 15.,note",
),
);
return $info;
}

function 
autolevel_install()
{
module_addhook('village');
module_addhook('battle-victory');
return TRUE;
}

function 
autolevel_uninstall()
{
return TRUE;
}

function 
autolevel_dohook($hookname,$args)
{
global $session;

switch($hookname)
{
case 'village':
if (!$session['user']['superuser'] & SU_MEGAUSERblocknav('train.php');
break;

case 'battle-victory':
if( get_module_setting('levellimit') > $session['user']['level'] )
{
require_once('lib/increment_specialty.php');
require_once('lib/experience.php');
$level $session['user']['level'];
$dks $session['user']['dragonkills'];
$reqexp exp_for_next_level($level,$dks);
if( $session['user']['experience'] + $args['creatureexp'] >= $reqexp )
{
$session['user']['level']++;
$session['user']['maxhitpoints']+=10;
$session['user']['hitpoints']+=10;
$session['user']['soulpoints']+=5;
$session['user']['attack']++;
$session['user']['defense']++;
$session['user']['clanpoints']+=100;

output("`n`c`b`2-=-`@=-=`2-=- `@You Level Up! `2-=-`@=-=`2-=-`0`b`c`n'");
output("`c");
output("`#You advance to level `^%s`#!`n"$session['user']['level']");
output("
`^Your hitpoints are now `^%s`#!`n", $session['user']['maxhitpoints']");
output("You gain an attack point!`n");
output("You gain a defense point!"`n");
output("
`^You gain `4100 `~Clan Points `^ for leveling up!`c");
modulehook('training-victory');
increment_specialty("
`^");
output("
`c");
output_notl("
`n`c`b`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`b`c`n");
}
}
break;
}
return 
$args;
}

function autolevel_run()
{
}
?>
Logged

insert sympathy here

Message me!
MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1752


View Profile
« Reply #7 on: March 31, 2013, 01:17:41 PM »

You're using an earlier version, just so you know. Smiley

The error is because of the extra double quotes at the end of 2 output() lines.

The clan points are stored in a database table that the module created. You'll have to access this table to retrieve or update the points.
Logged

Check My Modules for the latest versions.
Nder'
Codemeister
****
Offline Offline

Posts: 256


Google is our savior!


View Profile
« Reply #8 on: March 31, 2013, 01:43:32 PM »

You're using an earlier version, just so you know. Smiley

The error is because of the extra double quotes at the end of 2 output() lines.

The clan points are stored in a database table that the module created. You'll have to access this table to retrieve or update the points.

*updates le file*

So... Stupidity Streak. How would one access the table?

Something like the following?
Code:

$sql = "SELECT * FROM " . db_prefix("clanpoints") . " WHERE clanid=".$session['user']['clanid'];
$result = $session['user']['clanpoints']+=100;
« Last Edit: March 31, 2013, 01:53:31 PM by ~Ender~ » Logged

insert sympathy here

Message me!
Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #9 on: March 31, 2013, 02:40:09 PM »

Clan Points not exist in the $session array.

Something more like this, for example:
Code:
db_query("UPDATE ".db_prefix('clanpoints')." SET clanpoints=clanpoints+100 WHERE clanid = {$session['user']['clanid']");

Or you could just add a modulehook that executes everything done when one levels.
« Last Edit: March 31, 2013, 02:44:59 PM by Aeo » Logged

Nder'
Codemeister
****
Offline Offline

Posts: 256


Google is our savior!


View Profile
« Reply #10 on: March 31, 2013, 02:48:09 PM »

Thanks!


EDIT::

I added your code in this small piece  below and got Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRI NG, expecting '}' in /opt/lampp/htdocs/modules/autolevel.php on line 74.


Code below:


Code:
<?php
/**
Modified by MarcTheSlayer
05/04/2012 - v1.0.0
+ This is a modified version of the module 'forestprefs' by Thanatos.
  I've stripped out everything apart from the code to allow auto levelling
  in the forest when the player has enough experience for the next level.
+ Changed the file name to suit its function.
21/04/2012 - v1.0.1
+ Level bug found and fixed by Aeolus. :)
*/
function autolevel_getmoduleinfo()
{
$info = array(
"name"=>"Auto Level Up",
"description"=>"Allow players to auto level up in the forest instead of fighting a Master.",
"version"=>"1.0.1",
"author"=>"`4Thanatos`2, modified by `@MarcTheSlayer",
"download"=>"http://dragonprime.net/index.php?module=Downloads;sa=dlview;id=1447",
"category"=>"Forest",
"settings"=>array(
"levellimit"=>"Maximum level that can be gained:,int|15",
"`2If you have modified your game to have more levels than 15 then enter the highest level here else leave it at 15.,note",
),
"prefs"=>array(
"Fight Master Training,title",
"user_autotrain"=>"Level up automatically?,bool",
),
);
return $info;
}

function 
autolevel_install()
{
module_addhook('village');
module_addhook('battle-victory');
return TRUE;
}

function 
autolevel_uninstall()
{
return TRUE;
}

function 
autolevel_dohook($hookname,$args)
{
if( get_module_pref('user_autotrain') != ) return $args;

global $session;

switch($hookname)
{
case 'village':
blocknav('train.php');
break;

case 'battle-victory':
if( get_module_setting('levellimit') > $session['user']['level'] )
{
require_once('lib/experience.php');
$reqexp exp_for_next_level($session['user']['level'],$session['user']['dragonkills']);
if( $session['user']['experience'] + $args['creatureexp'] >= $reqexp )
{
require_once('lib/increment_specialty.php');
$session['user']['level']++;
$session['user']['maxhitpoints']+=10;
$session['user']['hitpoints'] = $session['user']['maxhitpoints'];
$session['user']['soulpoints']+=5;
$session['user']['attack']++;
$session['user']['defense']++;
db_query("UPDATE ".db_prefix('clanpoints')." SET clanpoints=clanpoints+100 WHERE clanid = {$session['user']['clanid']");

output('`n`c`b`2-=-`@=-=`2-=- `@You Level Up! `2-=-`@=-=`2-=-`0`b`c`n');
output("
`#You advance to level `^%s`#!`n", $session['user']['level']);
output("
Your maximum hitpoints are now `^%s`#!`n", $session['user']['maxhitpoints']);
output("You gain an attack point!`n");
output("You gain a defense point!");
output("You gain 100 Clan Points!");
modulehook('training-victory');
increment_specialty("`^");
output_notl("`n`c`b`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`b`c`n");
}
}
break;
}
return 
$args;
}

function autolevel_run()
{
}
?>



Line in question is: db_query("UPDATE ".db_prefix('clanpoints')." SET clanpoints=clanpoints+100 WHERE clanid = {$session['user']['clanid']");
« Last Edit: March 31, 2013, 03:00:47 PM by ~Ender~ » Logged

insert sympathy here

Message me!
MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1752


View Profile
« Reply #11 on: March 31, 2013, 04:33:49 PM »

The clue is in the error message. It's expecting a '}'. It's missed it out after the $session['user']['clanid'] bit. Smiley
Logged

Check My Modules for the latest versions.
Nder'
Codemeister
****
Offline Offline

Posts: 256


Google is our savior!


View Profile
« Reply #12 on: March 31, 2013, 04:40:05 PM »

I hate SQL (and for peculiar reasons chose LoGD xD); but I'm learning. Do I take out the { or add a } at the end?
Logged

insert sympathy here

Message me!
MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1752


View Profile
« Reply #13 on: March 31, 2013, 04:55:54 PM »

You need to add it. All array variables need to be enclosed inside curly brackets when they're used inside double quotes.

Code:
<?php

$example 
"This is a {$array['test']}.";

or

$test $array['test'];
$example "This is a $test.";

or

$test $array['test'];
$example 'This is a '.$test.'.';
or

$example "This is a ".$array['test'].".";

or

$example 'This is a '.$array['test'].'.';

PHP parses strings wrapped inside double quotes for variables names. It doesn't for single quotes.

So sometimes one method is better than another for efficiency, etc.

Code:
<?php

$test1 
"This $looks nice $and tidy and is $probably faster.";

$test2 'This '.$can.' be '.$hard.' to '.$look.' at sometimes.';


Smiley
Logged

Check My Modules for the latest versions.
Nder'
Codemeister
****
Offline Offline

Posts: 256


Google is our savior!


View Profile
« Reply #14 on: March 31, 2013, 05:19:39 PM »

*bookmarks this for future reference  Grin*

Thanks a ton Mark!
Logged

insert sympathy here

Message me!
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
85 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search