nb Core Community
February 07, 2012, 11:14:18 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: 1.2.3 +nb is now final and released

@new registrations. I will not allow any new registrations here as there are more (real person) spambots here than ever.... captcha proved to be ineffective.

After your registration, mail me at ( admin AT shinobilegends.com ) from the mail address you want to register. Provide some text about you and possibly your game.
 
   Home   Help Search Calendar Downloads Login Register  
Pages: 1 [2] 3
  Print  
Author Topic: Forest search countdown  (Read 3690 times)
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #15 on: August 15, 2008, 09:39:54 pm »

 Cheesy I know...

but I won't write you the module or teach you how to do it =) I give you a rough guideline, and  then you have to start doing...

 Grin
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #16 on: August 16, 2008, 12:52:32 am »

Made the lodge module : forestsearch_timeoutreducer.php ...


Code:
<?php

function forestsearch_timeoutreducer_getmoduleinfo(){
$info = array(
"name"=>"Forest timeout speed up search",
"version"=>"1.0",
"author"=>"Alchemion with help from Nightborn",
"category"=>"Lodge",
"download"=>"......",
"settings"=>array(
"reduceminutes"=>"How many minutes to reduce with the waiting time out between forest search?,int|2",
"days"=>"How many days of reduced forest timeout?,int|30",
"cost"=>"How much does this cost in points?,int|333",
),
"prefs"=>array(
"Forest timeout speed up search User Preferences,title",
"daysleft"=>"How many days are left?,int|0",
),
);
return $info;
}

function 
forestsearch_timeoutreducer_install(){
module_addhook("forest");
module_addhook("lodge");
module_addhook("pointsdesc");
module_addhook("newday");
return true;
}

function 
forestsearch_timeoutreducer_uninstall(){
return true;
}

function 
forestsearch_timeoutreducer_dohook($hookname,$args){
global $session;
$cost get_module_setting("cost");
$days get_module_setting("days");
$daysleft get_module_pref("daysleft");
$reduceminutes get_module_setting("reduceminutes");

switch($hookname){

case "forest":
if($daysleft 0){
output("The Forest Search TimeOut Reducer, that you bought from the Hunters Lodge, speeds up your recovering between forest searches and readies you for new great adventures.`n");
increment_module_pref("lastforestsearch",-($reduceminutes)*60);
}
break;
case "lodge":
addnav(array("Forest timeout speed up search(%s points)",$cost),"runmodule.php?module=forestsearch_timeoutreducer&op=reduceminutes");
break;
case "newday":
if(get_module_pref("daysleft") > 0){
if(get_module_pref("daysleft")==1){
output("Your speed up Forest Search Timeout reducer has expired... you will search the forest at normal speed now...`n");
}else{
output("Good luck in the Nemesis hunt!`n");
}
set_module_pref("daysleft"$daysleft 1);
}
break;
case "pointsdesc":
$reduceminutes get_module_setting("reduceminutes");
$args['count']++;
$format $args['format'];
$str translate("Get a Forest Search TimeOut Reducer of %s minutes for %s days.");
$str sprintf($str$reduceminutes$days);
output($format$strtrue);
break;
}

return $args;
}

function 
forestsearch_timeoutreducer_run(){
global $session;
$op httpget("op");
$cost get_module_setting("cost");
$days get_module_setting("days");
$reduceminutes get_module_setting("reduceminutes");
$pointsavailable $session['user']['donation'] - $session['user']['donationspent'];

page_header("Hunter's Lodge");
if ($op=="reduceminutes"){
addnav("L?Return to the Lodge","lodge.php");
output("`7You approach someone who slightly resembles an old, dirty rock.`n`n");
output("\"`&If you wish, I can give you an item to reduce with %s minutes the Forest Search TimeOut for %s days with only %s points.\"`7, they say."$reduceminutes,$days,$cost);
addnav("Confirm Forest Search TimeOut Reducer");
addnav("Yes""runmodule.php?module=forestsearch_timeoutreducer&op=reduceminutesconfirm");
addnav("No""lodge.php");
}elseif ($op=="reduceminutesconfirm"){
addnav("L?Return to the Lodge","lodge.php");
$pointsavailable $session['user']['donation'] - $session['user']['donationspent'];
if($pointsavailable >= $cost){
$num get_module_pref("daysleft");
$num += $days;
set_module_pref("daysleft"$num);
$session['user']['donationspent'] += $cost;
output("`7The old crusty character rummages around its folds of clothing and comes up with a small pendative.`n`n");
output("\"`&Just keep this on you when you explore the forest...`7\", they remark.`n`n");
output("`7Not really sure about the pendative, you place it in your pocket and pray that fortune helped you making a good investment...");
}else{
output("The old crusty character completely ignores you.  Maybe you don't have enough donations points availalbe.");
}
}
page_footer();
}
?>

////


Though the donation points are substracted, the timeout is not reduced with the "reduceminutes" setting....

Please, Nightborn, check and point where I have missed some code...

Thank you very much.
« Last Edit: August 20, 2008, 09:56:15 pm by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #17 on: August 16, 2008, 06:40:59 am »

on 1.2.0 (note: this is a *development version that has almost daily changes, no guarantee working(!)*) it should block out all navs, including autofight (untested).

You may simply copy+paste the other ops required into a blocknav()

if you want to make a  module to buy a personal timelifter...

well, a three-liner.

use a "buy-stuff-from-lodge" module like .. say, fairydust.
it has most of the stuff you need.

now, you only need to put the "activate fairydust" navigation to the forest, not to battle or whatever it is on right now to the "forest" hook.

then when activate just to a
Code:
increment_module_pref("lastforestsearch',-(get_module_setting('reduceminutes')*60));
which will make it appear the player searched an amount of minutes earlier than he actually did, crediting him 'reduceminutes' (setting in the module!) to his lastforestsearch timestamp.
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #18 on: August 16, 2008, 10:17:14 am »

I have replaced

increment_module_pref("lastforestsearch",-($reduceminutes)*60);

with :

increment_module_pref("lastforestsearch",-(get_module_setting("reduceminutes")*60));

if that is what you have pointed out... still doesn't  work the reducer... (though it is bought from lodge, substracted points and and showing in prefs the daysleft...

Please look through the code that does the timeout between the forest searches, maybe is not "lastforestsearch" that must be incremented  in the forestsearch_timeoutreducer.php (the lodge module) Huh? ... :

/// this is the forestsearch_timeout.php module that works great ....

<?php
function forestsearch_timeout_getmoduleinfo(){
   $info = array(
      "name"=>"Forest Search Time Out",
      "author"=>"`%Alchemion`0 with technical help from `%Oliver Brendel`0",
      "download"=>"http://www.xevolution.ro/lotgd/forestsearch_timeout.tar",
      "description"=>"Forest Search Time Out, so that users enjoy other game areas...",
      "settings"=>array(
         "Forest Search Time Out Settings,title",
         "timeout"=>"How long users stay out of forest search area (in minutes)?,int|3",
      ),
      "category"=>"General",
      "version"=>"1.0",
      );
   return $info;
}
function forestsearch_timeout_install(){
   module_addhook("forest");
   module_addhook("forestsearch");
   
   return true;
}
function forestsearch_timeout_uninstall(){
   return true;
}
function forestsearch_timeout_dohook($where,$args){
   global $session;
   $timeout = get_module_setting("timeout");
   $diff = (get_module_pref("lastforestsearch")-strtotime("- $timeout minutes"));
   

   switch($where){
      
      case "forest":      
         if ($diff>0) blocknav("Fight") & blocknav("forest.php?op=search") & blocknav("forest.php?op=search&type=slum") & blocknav("forest.php?op=search&type=thrill") & blocknav("forest.php?op=search&type=suicide") & output("`n`\$`bYou are a bit tired from forest exploration... please, take your time to replenish your health, augment your strength, if needed, spend some useful time in the village or simply relax in the public forum, as new forest search and thrilling adventures will become available to you in `^$diff`0 seconds...`b`0");
         
         break;
      
      case "forestsearch":
         set_module_pref("lastforestsearch",strtotime("now"));
         break;
      
      
   }
   return $args;
}
function forestsearch_timeout_run(){}
?>

///


Looking forward to your help...

Thanks.
« Last Edit: August 16, 2008, 10:24:06 am by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #19 on: August 17, 2008, 08:23:03 am »

why are you posting me a module that has nothing to do with the reduce of the wait time?

you can only use something like $reduceminutes if you have PREVIOUSLY SET $reduceminutes in that function.

if it does NOT decrease the wait time, then it is obvious it results to 0 zero.

check your code...
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #20 on: August 17, 2008, 09:56:29 am »

The forest "timeout" search is set to 3 minutes and the lodge "reducetime" is set to 2...

The difference between these is not zero... nor between "lastforestsearch" and "reducetime"...

Yet, the time is not reducing at all...

Please,  Nightborn, review and help with a correction code...

Danke schoen.
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #21 on: August 17, 2008, 10:58:35 am »

Code:
=)

[code]      case "forest":
         if($daysleft > 0){
            output("The Forest Search TimeOut Reducer, that you bought from the Hunters Lodge, speeds up your recovering between forest searches and readies you for new great adventures.`n");
            increment_module_pref("lastforestsearch",-($reduceminutes)*60);
         }

change to
         if($daysleft > 0){
            output("The Forest Search TimeOut Reducer, that you bought from the Hunters Lodge, speeds up your recovering between forest searches and readies you for new great adventures.`n");
            increment_module_pref("lastforestsearch",-($reduceminutes)*60,"forestsearch_timeout");
         }[/code]

you have not assigned the right module...it will always check into the current module for the pref, not the one you wanted.

NOTE: you do this EVERY forest hit. people can then CIRCUMVENT ANY WAIT TIME completely =)


Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Iori
Guest
« Reply #22 on: August 18, 2008, 02:45:46 am »

Instead of modifying the wait time AFTER it has been set, you can just modify the wait time BEFORE it gets set (example, set the timer to 2 mins instead of 3 when applying the wait time if th eplayer has the donation thing active).
Logged
Alchemion
Guest
« Reply #23 on: August 18, 2008, 09:01:25 am »

Nightborn, I have "partially" completed the forest access time limiter module as I inteded :

Result:

forestsearch_timeoutreducer_more.php

It does:

1. Sets a time out of forest searches, default to 3 minutes, modifiable by admins'

2. Sets a corespondent buy in the Hunter's Lodge, so that users can pay donation points and get a " Forest time out Reducer" whch will set the time out between searches to 1 minute, modifiable by admins, also the duration and price of the buy are modifiable;

3. Sets a information bar in the charstats - personal info, in the right screen, which shows to user how long does s/he has to still wait before new forest search becomes available, and also puts a direct link to forest.php when the timeout has finished and search is 'Available"

Module available here:

http://www.xevolution.ro/lotgd/forestsearch_timeoutreducer_more.tar

When I thought our work ( Smiley ) is done, I rememberd the graveyard.... and the "partially" makes sense... Smiley

I couldn't see any hook in the graveyard so that I can extend the scope of this module also to graveyard torments...

I am pondering now if I should unify the scopes for forest and graveyard timeout searches or make two separate lodge modules...

Please, Nightborn, have a look on the updated module and advise on the hooks I should put for the graveyard...

Thank you very much for your great help so far.
« Last Edit: August 18, 2008, 09:20:47 am by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #24 on: August 18, 2008, 09:11:01 am »

As I indicated, and as you can see by the forum name, I am not giving primarily "how do I get my stuff done in my modules" support here.

if you have Linux, try a
Code:
grep "modulehook" graveyard.php lib/graveyard/*.php -niR
to find hooks in them

and you'll get
lib/graveyard/case_default.php:10:   modulehook("graveyard-desc");
lib/graveyard/case_default.php:20:modulehook("graveyard");
lib/graveyard/case_enter.php:14:modulehook("mausoleum");
lib/graveyard/case_question.php:22:modulehook("ramiusfavors");

use graveyard as hook to do the same as in forest...


Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #25 on: August 18, 2008, 09:26:37 am »

To tell you honestly, I gave it a try with the graveyard hook, but hadn't time last night to test it... thought I could ask a php master for a hint to make sure...

Yet, I have two hooks for the "forest" and "forestsearch", while in the graveyard I could only find "graveyard" hook,but the second hook ?...

Thank you, very much.
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #26 on: August 18, 2008, 09:45:29 am »

It seems more like "ask for getting the right code without having to do the work" ... which is clearly something I do not like.

In the graveyard, there is no forestsearch hook.

Think what you need to do ^^ it's not hard, and you got example code for the same problem already for the forest.

Make use of text search (!) and read the core files (!).
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #27 on: August 18, 2008, 01:27:34 pm »

Does I appear to you, when finalising a 3 in 1 full working module, only with 2 snippets of code from you, that I just want somebody else to code it for me ?...

Of course, forestsearch is not found in the graveyard... not with that kind of logic I could compile, with ZERO php knowledge, three modules in one...

I have already admited that I don't have the stomach for the source files to read and digest, but I also admited that when fed quality (predigested code) I have (proved) the intellegence to mix and paste a valid code...

One should be happy when intelligent individuals gather around, instead of placing acid remarks on them...

As a matter of fact I did place a search for specific words in the .php source files and modules, but I don't know why the xp search engine returns zero results, even if the searched words are there...

Thank you very much for your help so far.

Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #28 on: August 18, 2008, 03:20:43 pm »

The acid you hear is the acid reaction to what you are trying to do... you state you have zero knowledge, but you want something done... copy+paste does not always work, as you have realized.

You asked for a core features which I denied for good reasons.

And those 2 snippets were in fact all the working code necessary, you used for the donation module the complete frame of another module except changed textparts and added the code I said.

Well, anyway, you need proper tools.
First off, the XP search engine is not that great, you need to do that either on command line or with a text editor that can search across multiple files.

Examples: Crimson Editor or Notepad++ (I prefer the latter)

Putting Linux in a Virtualbox is also a good start, but maybe too far for you... though it would teach you file permissions and other stuff, needless to say it's great to run your own server (like with easyphp) though *without* having to scram your windows installation.

You need to read only a few files...not even 100 lines. I mean it when I ask you to work for it...
the little step to adapt it to the graveyard is something we can help, but will not say "okay, do this and that..." because that would be exactly "doing the work for you" :-/

I already said: it works like with the forest... I try to encourage you to finish it with your own skills.
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #29 on: August 20, 2008, 04:44:31 pm »

Back with news !...

I used notepad++ and found what I was missing with the xp windows search... thanks, Nightborn, for the good tip.

Updated the graveyardsearch_timeoutreducer_more.php module, yet the strtotime doesn't initialise...

I know the 'gravesearh' hook is a bogus, but I couldn't find a better mismatch hook  Undecided

graveyardsearch_timeoutreducer_more.php

Code:
<?php

function graveyardsearch_timeoutreducer_more_getmoduleinfo(){
$info = array(
"name"=>"Graveyard timeout speed up search",
"version"=>"1.0",
"author"=>"Alchemion with help from Nightborn",
"category"=>"Lodge",
"download"=>"......",
"description"=>"Graveyard Search Time Out, so that users enjoy other game areas...",
"settings"=>array(
"Graveyard Search Time Out Settings,title",
"timeout"=>"How long users stay out of Graveyard search area (in minutes)?,int|3",
"cost"=>"How much does the timeout reducer costs in Lodge points?,int|333",
"reduceminutes"=>"How many minutes to reduce the waiting time out between Graveyard search?,int|1",
"days"=>"How many days of reduced Graveyard timeout?,int|30",
"showtime"=>"Show time to new Graveyard search,bool|1",
"showbar"=>"Show time as a bar,bool|1",
),
"prefs"=>array(
"Graveyard timeout speed up search User Preferences,title",
"daysleft"=>"How many days are left?,int|0",
),
);
return $info;
}

function 
graveyardsearch_timeoutreducer_more_install(){
module_addhook("graveyard");
module_addhook("gravesearch");
module_addhook("lodge");
module_addhook("pointsdesc");
module_addhook("newday");
module_addhook("charstats");
return true;
}

function 
graveyardsearch_timeoutreducer_more_uninstall(){
return true;
}

function 
graveyardsearch_timeoutreducer_more_dohook($hookname,$args){
global $session;
$cost get_module_setting("cost");
$days get_module_setting("days");
$daysleft get_module_pref("daysleft");
$reduceminutes get_module_setting("reduceminutes");
$timeout get_module_setting("timeout");
$diff = (get_module_pref("lastgraveyardsearch")-strtotime("- $timeout minutes"));

switch($hookname){

case "graveyard":
if($daysleft 0){
output("The Graveyard Search TimeOut Reducer, that you bought from the Hunters Lodge, speeds up your recovering between Graveyard searches and readies you for new great adventures.`n");
$diff = (get_module_pref("lastgraveyardsearch")-strtotime("- $reduceminutes minutes"));
}
if ($diff>0blocknav("graveyard.php?op=search")  & output("`n`\$`bYou are a bit tired from Graveyard exploration... please, take your time to replenish your health, augment your strength, if needed, spend some useful time in the village or simply relax in the public forum, as new Graveyard search and thrilling adventures will become available to you in `^$diff`0 seconds...`b`0");
break;

case "gravesearch":
set_module_pref("lastgraveyardsearch",strtotime("now"));
break;

case "lodge":
addnav(array("Graveyard timeout speed up search(%s points)",$cost),"runmodule.php?module=graveyardsearch_timeoutreducer_more&op=reduceminutes");
break;

case "newday":
if(get_module_pref("daysleft") > 0){
if(get_module_pref("daysleft")==1){
output("Your speed up Graveyard Search Timeout reducer has expired... you will search the Graveyard at normal speed now...`n");
}else{
output("Good luck in the Nemesis hunt!`n");
}
set_module_pref("daysleft"$daysleft 1);
}
break;

case "pointsdesc":
$reduceminutes get_module_setting("reduceminutes");
$args['count']++;
$format $args['format'];
$str translate("Get a Graveyard Search TimeOut Reducer of %s minutes for %s days.");
$str sprintf($str$reduceminutes$days);
output($format$strtrue);
break;

case "charstats":
if($daysleft 0){
$diff = (get_module_pref("lastgraveyardsearch")-strtotime("- $reduceminutes minutes"));
}
if ($diff>0)
{
        require_once("lib/datetime.php");
$secstonewday $diff;

                        
$newdaypct round($diff / (5*60) * 100,0);
$newdaynon 100 $newdaypct;

        
$newdaytxt date("G\\h i\\m s\\s",$secstonewday);

        if ($newdaypct 100) { $newdaypct 100$newdaynon 0; }
        
elseif ($newdaypct 0) { $newdaypct 0$newdaynon 100; }

        $color "#00ff00";
        
$ccode "`@";
$hicode "`&";
                $stat "Graveyard Search";

$showtime get_module_setting("showtime");
$showbar  get_module_setting("showbar");
         $new "";

if (!$showtime && !$showbar$new="`b`\$hidden`b";
if ($showtime$new .= $ccode $newdaytxt;
if ($showbar) {
if ($showtime$new .= "<br />";
$new .= "<table style='border: solid 1px #000000' bgcolor='#777777' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='$newdaypct%' bgcolor='$color'></td><td width='$newdaynon%'></td></tr></table>";
}
setcharstat("Personal Info"$stat$new);

} else {
//DISPLAYING THE Graveyard Available LINK
$mes translate_inline("`bAvailable !`b");
$display ="(<a href='graveyard.php' align='center' class=\"colLtGreen\" style=\"font-size:12px\"> $mes </a>)";
setcharstat("Personal Info""Graveyard Search"$display);
addnav("","graveyard.php");

}
break;

}
return $args;
}

function 
graveyardsearch_timeoutreducer_more_run(){
global $session;
$op httpget("op");
$cost get_module_setting("cost");
$days get_module_setting("days");
$reduceminutes get_module_setting("reduceminutes");
$pointsavailable $session['user']['donation'] - $session['user']['donationspent'];

page_header("Hunter's Lodge");
if ($op=="reduceminutes"){
addnav("L?Return to the Lodge","lodge.php");
output("`7You approach someone who slightly resembles an old, dirty rock.`n`n");
output("\"`&If you wish, I can give you an item to reduce with %s minutes the Graveyard Search TimeOut for %s days with only %s points.\"`7, they say."$reduceminutes,$days,$cost);
addnav("Confirm Graveyard Search TimeOut Reducer");
addnav("Yes""runmodule.php?module=graveyardsearch_timeoutreducer_more&op=reduceminutesconfirm");
addnav("No""lodge.php");
}elseif ($op=="reduceminutesconfirm"){
addnav("L?Return to the Lodge","lodge.php");
$pointsavailable $session['user']['donation'] - $session['user']['donationspent'];
if($pointsavailable >= $cost){
$num get_module_pref("daysleft");
$num += $days;
set_module_pref("daysleft"$num);
$session['user']['donationspent'] += $cost;
output("`7The old crusty character rummages around its folds of clothing and comes up with a small pendative.`n`n");
output("\"`&Just keep this on you when you explore the Graveyard...`7\", they remark.`n`n");
output("`7Not really sure about the pendative, you place it in your pocket and pray that fortune helped you making a good investment...");
}else{
output("The old crusty character completely ignores you.  Maybe you don't have enough donations points availalbe.");
}
}
page_footer();
}
?>

So, dear, Nightborn, what hook do you suggest I should use and make things real ?!...

Thank you very much for your help so far, I couldn't have done the least I did without your help...
« Last Edit: August 20, 2008, 06:04:57 pm by Alchemion » Logged
Pages: 1 [2] 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!