DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • November 17, 2017, 09:32:20 AM
Home Forums News Downloads Login Register Advanced Search
* *
DragonPrime Menu
Login
 
 
Resource Pages
Search

  Show Posts
Pages: [1] 2 3 ... 11
1  Coding Support / Coding Support Desk / Re: How To Convert Array Into String?? on: November 09, 2017, 10:22:00 AM
So here is original coding
Code:
//split into array of words
$filtstr = explode(" ", trim($string));
foreach ($filtstr as $key => $filtstr1)
$filtstr[$key] = trim($filtstr1);

This is lines 71-74
The call stack happens at line 85
Code:
if (strlen($filtstr) > strlen($filterpost1))

Somewhere along the line you have edited the code incorrectly.  The correct line 85 in riddles.php is
Code:
if (strlen($filtstr1) > strlen($filterpost1))
(note the '1' in 'filtstr1').

Thanks, Boris...this worked!
2  Coding Support / Coding Support Desk / Re: Question About Item System on: November 06, 2017, 09:40:50 AM
I have not looked at the item system module at all, and you did not provide a full snippet of the _dohook() function, so I am going to assume that this is in a switch case. It is better to just add a break for those under 100 Dragon kills - it will look a lot nicer in the code, rather than wrapping everything in an if statement.

Code:
<?php
        
global $session;
        if (
$session['user']['dragonkills'] <= 100) {
            break;
        }
require_once("lib/itemhandler.php");
$inventory get_inventory();
$count=0;
while ($item db_fetch_assoc($inventory)) {
$destroyed 0;
for($c=0;$c<$item['quantity'];$c++) {
if($item['dkloosechance'] >= e_rand(1,100)) $destroyed++;

}
if ($destroyedremove_item((int)$item['itemid'], $destroyed);
$count+=$destroyed;
}
if ($count == 1) {
output("`n`2Shattered around you lie the remains of a once mighty item destroyed by the power of the dragon's flames. ");
} else if ($count 1) {
output("`n`2Shattered around you lie the remains of once mighty items destroyed by the power of the dragon's flames. ");
output("It seems `^%s items`2 have been destroyed."$count);
}

So it accomplished the same thing...
It just breaks the case if under 100 dragonkills, and allows it to continue if not.

Thanks.

Not sure really why that is cleaner...I guess I do not know a whole lot about standards and practices...I'm a pretty sloppy coder and always have just done what works, regardless of any standards or protocols, LOL.

Thanks for this, I will try it.

It seems like this would work, from what I know of the code.

Just trying to add a machanism in that balances the game a bit for the elite players, and helps the newbies.
3  Coding Support / Coding Support Desk / Re: How To Convert Array Into String?? on: November 06, 2017, 09:37:17 AM
So here is original coding
Code:
//split into array of words
$filtstr = explode(" ", trim($string));
foreach ($filtstr as $key => $filtstr1)
$filtstr[$key] = trim($filtstr1);

This is lines 71-74
The call stack happens at line 85
Code:
if (strlen($filtstr) > strlen($filterpost1))

Somewhere along the line you have edited the code incorrectly.  The correct line 85 in riddles.php is
Code:
if (strlen($filtstr1) > strlen($filterpost1))
(note the '1' in 'filtstr1').

Huh.
I never messed with the code on riddles.

I will try it.
4  Coding Support / Coding Support Desk / Re: How To Convert Array Into String?? on: November 04, 2017, 09:11:20 AM
Do try to keep your drama to a minimum here, nobody here appreciates it. Nor did we ask for your life story.

I wasn't born into it, I self-taught myself at 16, started learning how to code properly in Uni at 18, and have only been decent at it for five years. Don't assume.

Shall we get back on topic?

Please.

The original topic was me asking for help.

You have chosen to belittle and shame me instead of HELPING.

I would love to get back to the original topic.
5  Coding Support / Coding Support Desk / Re: How To Convert Array Into String?? on: November 04, 2017, 06:27:03 AM
I really only know enough about coding to be dangerous.

I'm sure that's meant to sound cool, but I recommend actually taking a full PHP course online before going further. How can you run a site when you don't know how to run it?

I have managed for over eleven years.

I didn't know squat about it when I got started with my site.

I self-taught myself what coding I know.

The problem here is...as soon as you learn how to do things, they change the damn rules.

Things need to STAY THE SAME.

And it is not meant to sound cool.  It means what it means.  I know enough to be truly dangerous...meaning that I could just as easily create something masterful...as royally screw something up.

I do know just enough to be truly dangerous in every sense of the word.  This is me recognizing my own limitations.

Sorry, but we can't all be Aeolus....and be born knowing how to do this stuff.

I am in the process, literally, of saving everything that is currently on my site.  I am TRYING to learn some OOP and I find it a very daunting prospect.  Quite frankly it scares the hell out of me, because it is SO DIFFERENT frm anything I have learned t ths point.

My plan here...is t take a module or two I have currently...and try to rework it in OOP.  See if I can make it work.

THEN I have some idea if I am actually doing it right!

THEN...I can rework all my stuff for it and be ready for it when it DOES happen...because unfortunately, yes, it will happen.


Now...in my day to day life, I am a medical biller/coder.  What this means is that I read the cryptic papers you get back from your insurance company to find out what sorry excuse they have for not paying your claim and try to get them to pay it.

A few years back, my industry went through a major overhaul from the ICD-9 nomenclature to the ICD-10 nomenclature.
This was, unlike previous upgrades...a major overhaul.  Previous permutations of upgrades had just been tweaks to what had already existed...the last, ICD-8 to ICD-9 had been 33 years previous...thus I never worked with ICD-8 and had always worked with ICD-9.

There were a lot of people fighting the change to ICD-10...and I was one who kept telling people that ICD-10 was the Borg...and that resistance was futile.  It was coming...and nothing was gonna stop it.  I was right, of course, though it did get delayed two years.

Seems to me PHP 7 and OOP is the same thing.  The Borg.  Resistance is futile.  But I have to take my time to learn it and learn it right.  And you harping on me and belittling me IS NOT HELPING.

Like I said we can't all be Mighty Aeolus, born knowing how to do this stuff.

I am proceeding about learning...in my own way and at my own pace.  You want to help or not?

It may make you feel good to knock me down and belittle me...which is all you seem to want to do...or you could actually help me in this process.  I'd really rather you helped me.  But it DOES NOT HELP...to have you constantly putting me down.

Could you just TRY to be a little more sensitive to other people's feelings...especially when they are NOT terribly confident of their abilities here?

You could try encouraging me and building me up instead of discouraging me, belittling me and knocking me down.  Try it, it isn't so hard, yaknow??
6  Coding Support / Coding Support Desk / Re: How To Convert Array Into String?? on: November 03, 2017, 01:16:24 PM
OK.  But see why I ask questions?

In either case, my temp workaround basically does what you suggested, it basically causes it to skip that debug function...which I did not think was actually necessary anyway.

I really only know enough about coding to be dangerous.
7  Coding Support / Coding Support Desk / Re: How To Convert Array Into String?? on: November 02, 2017, 08:02:59 PM
Now...in PHP 5.3 and lower...when an array was passed to something that called for a string, it quietly put a zero in there and just kept going...so you never knew there was a problem.

NOW...you actually get the unsightly call stack!

No, that's just bad coding. If it calls for a string, you give it a string. If it calls for an array, you give it an array. You don't pass something to it incorrectly and just hope for the best.

You can check if something's an array by using is_array in a if-statement. If it calls for an array, and what is passed is not an array, you need to exit the function and not continue with it. If it calls for a string, and what is passed is not a string, you need to exit the function and not continue with it.

OK...I am TRYIMG to correct;y re=code...what someone else coded...and which actually worked until the upgrade...

Or at least I thought it did since I never got the call stack, right?

The two modules in question....one was coded by Iori, the other, part of core distribution.

I am trying to FIX them...to get them right.

Seems to me the easiest fix...for the moment...would be to convert the existing string into an array and vice versa...just to get things working for now...

THEN...maybe go back an recode them so that the correct thing is called for in the first place,  I guess I am just looking for the quick fix for the moment, so that I can reactivate modules that are currently deactivated.

The one by Iori, for example, is using a debug function that seems to want an array but is getting a string.  I did not code it.
From Iori's module:

Code:
$drop = get_module_objpref("creatures",$args['creatureid'],"drop");

Code:
debug($drop['name']);



Seems the debug function wants an array...but $drop is expressed as a string here.

So I want to take and explode $drop into an array...which ought to clear up the call stack.

now...the older versions of PHP (5.3 and lower) would simply replace with a NULL when passed a string instead of an array.
Thus this was always a problem...but one which you never got alerted to.  The newer version of PHP does alert you by giving the call stack.

This is what I found i my own research on the matter.  (See, I do try to help myself!!)

SO...in the interim, I did a workaround like this:

Code:
if (is_array($drop)){
   
debug($drop['name']);

} else {}

I did that to see if it took care of the call stack and it did.
The thing now functions correctly in that it adds the item for you and does not give you the call stack...like older versions of PHP.

BUT...this is NOT the correct fix and I know it.
I am using a temporary workaround...and trying to understand the function better so that I can code properly...and explode the given string into an array....

Understand now?


Now the other module...I have the reverse problem...it is looking for a string, but being passed an array.
So I want to implode that one into a string.

But neother of them are my original coding...i am trying to fix someone else's improper coding in this case.
8  Coding Support / Coding Support Desk / Question About Item System on: November 02, 2017, 06:49:43 PM
ok, you probably don't need to really know the Item System to do this...

There are settings that allow certain items to be destroyed on a dragon kill.  You have to set the chances for each item.

BUT...the hook for dragonkill looks like this
Code:
<?php
require_once(
"lib/itemhandler.php");
$inventory get_inventory();
$count=0;
while ($item db_fetch_assoc($inventory)) {
$destroyed 0;
for($c=0;$c<$item['quantity'];$c++) {
if($item['dkloosechance'] >= e_rand(1,100)) $destroyed++;

}
if ($destroyedremove_item((int)$item['itemid'], $destroyed);
$count+=$destroyed;
}
if ($count == 1) {
output("`n`2Shattered around you lie the remains of a once mighty item destroyed by the power of the dragon's flames. ");
} else if ($count 1) {
output("`n`2Shattered around you lie the remains of once mighty items destroyed by the power of the dragon's flames. ");
output("It seems `^%s items`2 have been destroyed."$count);
}
?>


Now...what I'd LIKE to do is make it so that ONLY if you are over 100 dragon kills could you have items destoryed.

SO....

If I wrapped an If around the entire thing...would that prevent those under 100 from having anything detroyed...like this...
Code:
<?php


if ($session['user']['dragonkills'] >= 100) {


require_once("lib/itemhandler.php");
$inventory get_inventory();
$count=0;
while ($item db_fetch_assoc($inventory)) {
$destroyed 0;
for($c=0;$c<$item['quantity'];$c++) {
if($item['dkloosechance'] >= e_rand(1,100)) $destroyed++;

}
if ($destroyedremove_item((int)$item['itemid'], $destroyed);
$count+=$destroyed;
}
if ($count == 1) {
output("`n`2Shattered around you lie the remains of a once mighty item destroyed by the power of the dragon's flames. ");
} else if ($count 1) {
output("`n`2Shattered around you lie the remains of once mighty items destroyed by the power of the dragon's flames. ");
output("It seems `^%s items`2 have been destroyed."$count);
}

} else {}


?>

Would that achieve what I am after...so that ONLY after 100 dragonkills...could items be destroyed by the dragon?
9  Coding Support / Coding Support Desk / Re: How To Convert Array Into String?? on: November 02, 2017, 06:11:07 PM
Little confused at what you're trying to go for here. Upgrading PHP versions shouldn't have broken things to do with arrays, but for your learning, I'll try to explain implode and explode. This probably wont be valid PHP, but it'll give you an idea on what each function does.

Consider this array: $toImplode = ['a, 'b', 'c'] and this string $toExplode = "a quick brown fox"

Now, explode converts a string to an array, whereas implode converts an array to a string. Horrible naming, in my opinion, these commands are better known as string.Split or array.join in many different languages.

If I called explode on $toExplode

Code:
<?php $exploded explode(" "$toExplode); ?>

then explode will look at $toExplode, then every time it sees a " " (a space) in the string, it'll split the string, and put each item into seperate indexes of an array. Thus:

Code:
$exploded == ["a", "quick", "brown", "fox"]

So, if explode 'explodes' a string into an array, what do you think implode does? If you answered turns an array into a string, you're the winner of a brand new caaaar! right!

So, lets take $toImplode, our array with three values, and use implode on it

Code:
<?php $imploded implode(", "$toImplode); ?>

Here, implode will join each element in our list up with whatever string we put, in this case ", ". Therefore the output will be:

Code:
$imploded == "a, b, c"

Hopefully that makes sense!


Actually it does make sense.
My mind wraps better around the concept the way you stated it.

Now if only I can determine the correct parsing of implode and explode.  So I can make valid code.

I have two modules...one that needs an array and calls a string...and the other...vice versa...needs a string and calls an array.

See, i went all the way from PHP 5.3 to 5.7 not by my choice, my hosting company did it to me.

Now...in PHP 5.3 and lower...when an array was passed to something that called for a string, it quietly put a zero in there and just kept going...so you never knew there was a problem.

NOW...you actually get the unsightly call stack!

Anyway...one of the modules is creaturedrop.php (part of the item system)
the other is
riddles.php - the riddling gnome.

Without looking right at them...
I think riddles is the one that wants an array and is being passed a string.
But it could be the other way 'round.

At any rate...I need to convert the one into the other, before it is ever called for in the module, in order to get rid of the horrible call stack.
10  Coding Support / Coding Support Desk / Re: Serious Call Stack Issues With Forums on: October 30, 2017, 03:01:05 PM
You're welcome.
Much thanks.

My apologies for not saying so...it was pretty late at night and I was half asleep.
11  Coding Support / Coding Support Desk / How To Convert Array Into String?? on: October 30, 2017, 02:39:44 PM
OK, I looked this up in a PHP manual and it is not terribly helpful.

I found the use of the implode function, but not sure how to express it in the code.

I am having trouble since my PHP version updated, in the riddles module.

So here is original coding
Code:
//split into array of words
$filtstr = explode(" ", trim($string));
foreach ($filtstr as $key => $filtstr1)
$filtstr[$key] = trim($filtstr1);

This is lines 71-74
The call stack happens at line 85
Code:
if (strlen($filtstr) > strlen($filterpost1))

So I need something between line 74 and line 85 that converts the array to a string.

The PHP manual shows this

Code:
$string_version = implode(',', $original_array)

but what do I replace the comma in the ' ' marks with, if anything...
and what do I replace $original_array with?

Am thinking $originalarray gets replaced with $filtstr


Looks to me like I may need to do it in more than one place to change $filtstr, $filtpost nd $fitpre into sttrings instead of arrays.

But not sure.

I have a very basic grasp of what I want to do.

here is a whole code block that is right now problematic. 

I just need to know exactly how to express this within the "implode" function and I am not sure how to do it.  Never used this before.



Code:
//Words to remove
$filterpre = array ( "a", "an", "and", "the", "my", "your", "someones",
"someone's", "someone", "his", "her", "s");
//Letters to take off the end
$filterpost = array ( "s", "ing", "ed");

//split into array of words
$filtstr = explode(" ", trim($string));
foreach ($filtstr as $key => $filtstr1)
$filtstr[$key] = trim($filtstr1);

//pop off word if found in $filterpre
foreach ($filtstr as $key => $filtstr1)
foreach ($filterpre as $filterpre1)
if (!strcasecmp($filtstr1, $filterpre1))
$filtstr[$key] = "";

//trim off common word endings
foreach ($filtstr as $key => $filtstr1)
foreach ($filterpost as $filterpost1)
if (strlen($filtstr) > strlen($filterpost1))
if (!strcasecmp(substr($filtstr1,
-1*strlen($filterpost1)), $filterpost1))
$filtstr[$key] =
substr($filtstr1, 0,
strlen($filterstr)-strlen($filterpost1));





12  Game Administration, Installation and Configuration / Installation and Configuration Assistance / Re: HELP!! PHP 5.5 on: October 30, 2017, 02:02:35 PM
Need to look into this stuff.

I got a call stack problem with creaturedrop now...apparently...

Code:
debug($drop['name']);
ths is on line 41 of creaturedrop.php and seems to be causing a call stack, listed below:


PHP Warning: "Illegal string offset 'name'"
in /home/savmor/public_html/modules/creaturedrop.php at 41.
Call Stack:
2: creaturedrop_dohook("battle-victory", Array(
"creatureid"=>"333", "creaturename"=>"Deadly Master Dragon Symp...", "creaturelevel"=>"7", "creatureweapon"=>"Razor Sharp Dagger", "creaturelose"=>"I will be avenged. You ha...", "creaturewin"=>NULL, "creaturegold"=>423, "creatureexp"=>129, "creaturehealth"=>-4, "creatureattack"=>24, "creaturedefense"=>15, "oldcreatureexp"=>NULL, "createdby"=>"DaveS", "forest"=>"1", "graveyard"=>"0", "playerstarthp"=>"169", "diddamage"=>0, "type"=>"forest", "didsurprise"=>1, "fightoutput"=>"<!-- AllowAnonymous: Fals..."
)) called from /home/savmor/public_html/lib/modules.php on line 512
3: modulehook("battle-victory", Array(
"creatureid"=>"333", "creaturename"=>"Deadly Master Dragon Symp...", "creaturelevel"=>"7", "creatureweapon"=>"Razor Sharp Dagger", "creaturelose"=>"I will be avenged. You ha...", "creaturewin"=>NULL, "creaturegold"=>423, "creatureexp"=>129, "creaturehealth"=>-4, "creatureattack"=>24, "creaturedefense"=>15, "oldcreatureexp"=>NULL, "createdby"=>"DaveS", "forest"=>"1", "graveyard"=>"0", "playerstarthp"=>"169", "diddamage"=>0, "type"=>"forest", "didsurprise"=>1, "fightoutput"=>"<!-- AllowAnonymous: Fals..."
)) called from /home/savmor/public_html/battle.php on line 277
4: require_once("/home/savmor/public_html/...") called from /home/savmor/public_html/forest.php on line 188

For now, i just commented out line 41 to see what happens, is there a known fix?


UDATE:  Further investigation is telling me that the fuction s expectng an array and it is getting a strng.

Does that seem right?

If so...what code can I use above the call....too explode it into an array instead f a string?

And then, should I implode it back into a string or leave it an array?
13  Game Administration, Installation and Configuration / Installation and Configuration Assistance / Re: HELP!! PHP 5.5 on: October 29, 2017, 08:21:11 AM
OK, might have just solved my own problem...

Code:
session_start();
function session_register($name){
    if(isset($GLOBALS[$name])) $_SESSION[$name] = $GLOBALS[$name];
    $GLOBALS[$name] = &$_SESSION[$name];
}

//session_register("session");
$session =& $_SESSION['session'];

replaced


Code:
session_register("session");
$session =& $_SESSION['session'];

in common.php

I am in my site now where I could not log in before.

Now the test of time to make sure nothing else got broken.


Some other peeps might make use of this little fix....since Versions 1.1.1 and 1.1.2 BOTH contain the offending line at or near line 87 in common.php


I will update later if anything else breaks because of this.

UPDATE: So far nothing else I can see has broken.
14  Game Administration, Installation and Configuration / Installation and Configuration Assistance / HELP!! PHP 5.5 on: October 29, 2017, 06:40:33 AM
My darn server company upped me without telling me and now I have a fatal error...

[29-Oct-2017 13:06:44 UTC] PHP Fatal error: Call to undefined function session_register() in /home/xxx-redacted-xxx/public_html/common.php on line 87

This means that function in question is no longer supported starting from PHP 5.4, while minor available PHP version is 5.5.


How do I fix this??

I found an "answer" on Google...

$_SESSION['myusername']="something";

But what do I put in the "something" parts??
What do I put in 'myuserame' or does that stay the same??

UPDATE:  Looked into the core code for Version 1.1.1 and Version 1.1.2 - I currently run 1.1.0
Both Version 1.1.1 and Version 1.1.2 contain the same offending line at or near line 87 in common.php

So a core upgrade will not fix my problem.

15  Coding Support / Coding Support Desk / Re: Serious Call Stack Issues With Forums on: October 29, 2017, 06:39:05 AM
When I told you how to fix it before, it seems that you didn't get the general point of it. The fix given here applies everywhere.

That means you need to change Type= to Engine= in the forum module as well. Which I can tell that you didn't do, because in this callstack, you still have "TYPE=MyISAM" at the end.

CREATE TABLE logdforum (`id` int(11) NOT NULL auto_increment,`postdate` datetime NOT NULL default '0000-00-00 00:00:00',`newpostdate` datetime NOT NULL default '0000-00-00 00:00:00',`author` text NOT NULL,`parent` int(11) NOT NULL default '0',`replies` int(11) NOT NULL default '0',`userid` int(11) NOT NULL default '0',`title` varchar(100) NOT NULL default '',`category` int(11) NOT NULL default '0',`content` text NOT NULL,PRIMARY KEY  (`id`)) TYPE=MyISAM;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 1
Call Stack:
1: db_query("CREATE TABLE logdforum (`...") called from /home/savmor/public_html/modules/forum.php on line 56
2: forum_install() called from /home/savmor/public_html/lib/modules.php on line 1327
3: install_module("forum") called from /home/savmor/public_html/modules.php on line 42


Well, LOL nobody said to do that.

This fixed the problem.
I have it installed and working now.
Pages: [1] 2 3 ... 11

*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

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