nb Core Community
February 07, 2012, 11:12:17 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: Battle avatars  (Read 3596 times)
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #15 on: September 15, 2008, 11:55:42 am »

Okay, you still don't understand what you are doing =)

Sorry, but there is a limit to what I am willing to do.

You ask me "how do I get what I want out of my copy+paste skills" ... and I tell you "you sometimes to do real programming - real thinking - real understanding to  get something done".

Helping you get a fish will bring you through a day, then the next day you go for more fish... it's no sense.

You have placed the debug() output before any display can happen. That's why you get nothing.

Place them AFTER the code has assembled the $image variable. Outputting an unset/empty variable will do no good.

You need to understand what you do, really. Sad


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: September 15, 2008, 01:14:27 pm »

before posting the previous message and the pre-previous one, i have placed the debug also after the images were rawoutput, exactly like you logicly and sensely draw attention upon, but...

(for me) the debug message was identical...

so, i decided to let them up in the code, since there was NO difference in the effect nor the debug message...

i have aligned the images and also a lot of prethought copy/pasting... some of the play got well some didn't...

i am not asking you for anything you are not willing to offer... please, note that, before posting here, I AM AWARE of your time, I AM ASSUMING the risk of not getting any help and I HAVE DONE the posting AFTER testing different and MANY logical coding tests...

i will keep trying playing with this hobby... though it is out of my specialty (law) and I am not always understanding what I am really doing...

grateful for your support so far,

standing by with news on the matter...
Logged
Alchemion
Guest
« Reply #17 on: September 15, 2008, 11:55:18 pm »

I have done it  - parallel testing in macromedia dreamweaver and notepad ++ Smiley

Cleaned the code, put into the same avatar.php module...

The code works fine: it shows the avatar vs. creature images in battles (not tested yet with the dragon, masters and special forest events...)

but, for now, WORKS and will be keep on testing and expanding...

Code:
case "battle":
if (get_module_pref("validated")==1 && get_module_pref("user_seeavatar")==1) {
$image="<img src='".get_module_pref("avatar")."' ALT='You' width='100%'>";
                       
} else {
$image=translate_inline("Avatar not validated yet");
}
$pics='';
foreach ($args as $creature) {
if ($creature['image']!='') {
$name=$creature['image'];
$pic=true;
} else {
$name="modules/addmonsterpics/".$creature['creaturename']." Lv".$creature['creaturelevel'].".jpg";
$pic=file_exists($name);
}
if ($pic==true) $pics.="<IMG SRC=\"$name\" ALT='$creature' width='100%'>";
}

rawoutput("
<table width='330' height='150' border='4' align='center'>
  <tr align='center'>
    <td width='150'>$image</td>
    <td width='30'>VS.</td>
    <td width='150'>$pics</td>
  </tr>
</table>
");

break;

Thank you for your help and patience.
« Last Edit: September 15, 2008, 11:56:55 pm by Alchemion » Logged
Alchemion
Guest
« Reply #18 on: September 16, 2008, 01:18:43 pm »

I have tested with the masters names and works fine, too...

The addmonsterpic module code seem not to show the dragon image...

Is it a special scheme to set the image name/path on the server, for the dragon ?

I have tested with the "The Green Dragon Lv.17", I have also excluded the Lv. from the syntax, and tested only with ""The Green Dragon", but it does not show the dragon image (the extension was correctly set)...

Is it supposed to not showing it ?...

Thank you.
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #19 on: September 16, 2008, 01:50:07 pm »

Code:
$name="modules/addmonsterpics/".$creature['creaturename']." Lv".$creature['creaturelevel'].".jpg";
$pic=file_exists($name);


It should work.

if you get only the name outputted, then the image is not there.

Make sure you have a picture with that name in the folder.

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: September 16, 2008, 02:41:00 pm »

if the code should show the dragon, what should be the name for the dragon (working) image ?... cause "The Green Dragon Lv.17.jpg" still does not work...

when i have outputed the images only by the name, i have also modified the images names on the server (e.g. "The Green Dragon.jpg")....... for the rest of the creatures works the code only by the  name, for the dragon image seems to not work nor with level, neither only by name, no way...

i am at "work" now, i will give it a new shot this evening... but i have the images on the server and i have changed to different "suitable" names... with no good result...

Edit: it occured to me: i have around 3 modules installed in the game, and all want to show the dragon image... it may raise a conflict... i will "clean" them and expect for the better ... Cheesy
« Last Edit: September 16, 2008, 02:51:52 pm by Alchemion » Logged
Alchemion
Guest
« Reply #21 on: September 16, 2008, 09:26:06 pm »

I have uninstalled battlepics, addimages and addmonsterpics modules...

I only have now the following code within the avatar.php module :

Code:
case "battle":
if (get_module_pref("validated")==1 && get_module_pref("user_seeavatar")==1) {
$image="<img src='".get_module_pref("avatar")."' ALT='You' width='100%'>";
                       
} else {
$image=translate_inline("Avatar not validated yet");
}
$pics='';
foreach ($args as $creature) {
if ($creature['image']!='') {
$name=$creature['image'];
$pic=true;
} else {
$name="modules/addmonsterpics/".$creature['creaturename'].".jpg";
$pic=file_exists($name);
}
if ($pic==true) $pics.="<IMG SRC=\"$name\" ALT='$creature' width='100%'>";
}
rawoutput("
<table width='330' height='150' border='4' align='center'>
  <tr align='center'>
    <td width='150'>$image</td>
    <td width='30'>VS.</td>
    <td width='150'>$pics</td>
  </tr>
</table>
");
break;

On server I placed the right images names...

As you can see from attachments, the creatures do show images, the dragon does not...

What is wrong with the code or what lacks to it ?

please help, i cannot find a solution, since i have copy/pasted the code integrally from addmonsterpics module......


Edit: seems that the code does not work also with creatures from special forest events, using their names for images.... is it a possibility and easier to use the forest special events modules names for their images names, so that they show the creatures ??

if it is no problem, i would use the dragon.jpg as image for the dragon... but how ?! Cheesy
« Last Edit: September 16, 2008, 10:28:24 pm by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #22 on: September 17, 2008, 07:21:19 am »

Code:
if ($creature['image']!='') {
$name=$creature['image'];
$pic=true;
} else {
$name="modules/addmonsterpics/".$creature['creaturename'].".jpg";
$pic=file_exists($name);
}

put it into verbal:

if the $creature array has no image attached (which I did, because *I* put the image files for special event creatures or such into the $creature array so this module can display them) do:
   set image to that one

if not
  assign a filename like "modules/addmonsters/" + name of the creature according to $creature array including all spaces AND COLOURS + ".jpg" and see if that file exists. does it not exist -> no display =)


that's the only thing I see here.

example of "gosh what is wrong with the code! I cannot guess where it breaks!" debugging

Code:
if ($creature['image']!='') {
$name=$creature['image'];
$pic=true;
} else {
$name="modules/addmonsterpics/".$creature['creaturename'].".jpg";
                                                        debug("assigned name $name to the creature pic");
$pic=file_exists($name);
                                                        debug("is the picture file there: ".$pic);
}

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 #23 on: September 18, 2008, 09:09:19 am »

Thank you very much for the enlighting...

Indeed, the debug output in accordance with the colours added to the name did the job ....

It is extraordinary and I admit I am amased how you succeeded in obtaining the same effect (battle pics) as the similar module that exists on dragonprime, only with a couple of lines of code... far smaller than the battlepics.php... very ingenious....

Now, the cherry on the cake: Smiley when i fight in pvp, i got also the other players name and the script allows for showing their images too.... veeeery nice.... how do i get their personal avatar to be shown, if they have it validated ?... what would be their avatar setting associated with the creature or so... so i can try testing by myself... the good code, also, would come in handy Cheesy

Gratefully  ....
« Last Edit: September 18, 2008, 09:22:55 am by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #24 on: September 18, 2008, 09:33:18 am »

It's too much to explain how you extract the pvp information.

Attached is my pvp avatar module that does exactly that -> display the enemies avatar if he got one.

It's not nice looking code, though, but you'll manage =)

And I really should to the proper sizing :-/

@same effect with smaller code
well, it was a lonny module... you can shorten any of his modules by 20-50% or more, because he writes like a poet writer - he re-iterates himself (same code) and has tons of "freedoms" (=settings) in his modules.
See the large list of hooks and so on. I slit it up and made a new one, with fewer code, but only for ONE location.
That's all I did, and in fact, if you want to output one picture, all you need is a line with <img ...> Wink that's it.
The rest is just idle hooking.
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: September 19, 2008, 11:47:24 am »

Thank you very much, for sharing the pvpavatar module here...

I have tested it last night, works exactly as I needed... much like the addmonsterpics....

Now, I have to rearange the output (in the same and only avatar.php i use...) to show the pvp avatar (the attacked player's image) in battle, exactly in the same position as it now shows the creature pics... (user avatar vs pvpavatar, in a row, resized an so on...)

I got some conflicts last night, cause of the pvpattacked "image" name which is exactly like attacker's name... of course, i have to do some renaming...

can't wait to test some more...

nightborn, i remain in debt to you...
« Last Edit: September 19, 2008, 11:51:40 am by Alchemion » Logged
Alchemion
Guest
« Reply #26 on: September 23, 2008, 11:57:49 am »

News:

after all these days past in exausting testing (... when knowledge lacks, the efforts are greater...) i eventually got to a still not working compromise :

this is the added code to avatar.php module, from addmonsterpics.php and pvpavatars.php :

when install :

Code:
module_addhook("battle");
    module_addhook("header-pvp");

when dohook:

Code:
case "battle":       
                if (get_module_pref("validated")==1 && get_module_pref("user_seeavatar")==1) {
                $image="<img src='".get_module_pref("avatar")."' ALT='You' width='100%'>";
                                               
            } else {
            $image=translate_inline("Avatar not validated yet");
        }                               
                    $pics='';
                    foreach ($args as $creature) {
                            if ($creature['image']!='') {
                            $name=$creature['image'];
                            $pic=true;
                        } else {
                            $name="modules/addmonsterpics/".$creature['creaturename'].".jpg";
                                                        debug("assigned name $name to the creature pic");
                            $pic=file_exists($name);                       
                                                        debug("is the picture file there: ".$pic);   
                        }
                        if ($pic==true)    $pics.="<IMG SRC=\"$name\" ALT='$name' width='100%'>";
                    }                   
rawoutput("                   
<table width='330' height='150' border='4' align='center'>
  <tr align='center'>
    <td width='150'>$image</td>
    <td width='30'>VS.</td>
    <td width='150'>$pics</td>
  </tr>
</table>
");
        break;   
       
        case "header-pvp":       
        if (get_module_pref("validated")==1 && get_module_pref("user_seeavatar")==1) {
                $image="<img src='".get_module_pref("avatar")."' ALT='You' width='100%'>";                                               
            } else {
            $image=translate_inline("Avatar not validated yet");
        }           
       
            if (httpget('act')!='attack' && httpget('op')!='fight') break;
            $badguy = unserialize($session['user']['badguy']);
            if ($badguy===false) break;
            if (!array_key_exists('enemies',$badguy)) {
                $acctid=$badguy['acctid'];
            } else { //v 1.1.1 and up
                $enemy=array_shift($badguy['enemies']);
                $acctid=$enemy['acctid'];
            }
            $pics=avatar_picture($acctid);
           
            rawoutput("                   
<table width='330' height='150' border='4' align='center'>
  <tr align='center'>
    <td width='150'>$image</td>
    <td width='30'>VS.</td>
    <td width='150'>$pics</td>
  </tr>
</table>
");
            break;



when functions :

Code:
function avatar_picture($user) {
    if (get_module_pref("validated","avatar",$user) && get_module_pref("avatar","avatar",$user)!='') {
        $pics="<img align='center' src='".get_module_pref("avatar","avatar",$user)."' ";
        if (get_module_setting("restrictsize","avatar")) {
            //stripped lines from Anpera's avatar module =)
            $maxwidth = get_module_setting("maxwidth","avatar");
            $maxheight = get_module_setting("maxheight","avatar");
            $pic_size = @getimagesize(get_module_pref("avatar","avatar",$user)); // GD2 required here - else size always is recognized as 0
            $pic_width = $pic_size[0];
            $pic_height = $pic_size[1];
            if ($pic_width > $maxwidth) $pics.=" width=\"$maxwidth\" ";
            if ($pic_height > $maxheight) $pics.=" height=\"$maxheight\" ";
        }
        $pics.=">";
        return $pics;
    } else return '';
}


The result: it does show user avatar vs monster pics, but when showing the pvpavatar (attacked player's avatar) it calls for the image name set by the addmonsterpics code... (see the attachement).. also doubles the images tables...

Obviously the "battle" hook intersects with the "header-pvp" hook, for that reason, i used also a different hook for monsterpics, instead of "battle", "header-forest", but then it didn't show any monsterpics, nor user avatar...   Embarrassed

Please, help... i am willing to use the separate addmonsterpics and pvpavatars modules, but i don't know how to call for the user's avatar settings within these modules so that his/her avatar shows also in battle, vs the foe's image ...

I embraced the actual solution : 1 file, but if advised, i am willing to use any better solution with same effect  Tongue

The pvp avatars testing it's a hell... how do i limit the pvptimeout to 1 second so that I (admin) can reatack (test pvp avatars) without having to wait for every 10 minutes ??...

thank you very much.
« Last Edit: September 23, 2008, 12:19:15 pm by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #27 on: September 23, 2008, 12:31:46 pm »

in case battle add a:
Code:
if ($args['type']=='pvp') break;

which should skip the battle part if you already execute at header-pvp.

or you can simply save yourself the header-pvp and just use the battle hook.

simply set
Code:
$badguy['image']="mypath/myimage.jpg";
when you setup the pvp.... much easier=)
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 #28 on: September 23, 2008, 12:48:43 pm »

i also wanted to have only one hook, the "battle"... but i got the errors i mentioned above...

Code:
$badguy['image']="mypath/myimage.jpg";

between which lines do i insert this code and, especially, do i just copy/paste it  or what does that mean ?...

it might be piece of cake to you, for me is matrix code...  Tongue



Logged
Alchemion
Guest
« Reply #29 on: September 23, 2008, 11:59:18 pm »

the
Quote
if ($args['type']=='pvp') break;
seems to not work...

after doing more testing i have replaced some terms in the code and got all the images i needed.... except i got them a lot.... Smiley

this is the code updated and inserted into avatar php:

when install:

Code:
module_addhook("battle");
module_addhook("header-pvp");

updated  hooks:

Code:
case "battle":
if ($args['type']=='pvp') break;
if (get_module_pref("validated")==1 && get_module_pref("user_seeavatar")==1) {
$image="<img src='".get_module_pref("avatar")."' ALT='You!' width='100%'>";                        
} else {
$image=translate_inline("Avatar not validated yet");
}
foreach ($args as $creature) {
if ($creature['image']!='') {
$name=$creature['image'];
$pic=true;
} else {
$name="modules/addmonsterpics/".$creature['creaturename'].".jpg";
                                                        debug("assigned name $name to the creature pic");
$pic=file_exists($name);
                                                        debug("is the picture file there: ".$pic);
}
if ($pic==true) $pics.="<IMG SRC=\"$name\" ALT='$name' width='100%'>";
}
rawoutput("
<table width='330' height='150' border='4' align='center'>
  <tr align='center'>
    <td width='150'>$image</td>
    <td width='30'>VS.</td>
    <td width='150'>$pics</td>
  </tr>
</table>
");
break;

case "header-pvp":
if (httpget('act')!='attack' && httpget('op')!='fight') break;
$badguy = unserialize($session['user']['badguy']);
if ($badguy===false) break;
if (!array_key_exists('enemies',$badguy)) {
$acctid=$badguy['acctid'];
} else { //v 1.1.1 and up
$enemy=array_shift($badguy['enemies']);
$acctid=$enemy['acctid'];
}
$pics=avatar_picture($acctid);

if (get_module_pref("validated")==1 && get_module_pref("user_seeavatar")==1) {
$image="<img src='".get_module_pref("avatar")."' ALT='You!' width='100%'>";                        
} else {
$image=translate_inline("Avatar not validated yet");
}
rawoutput("
<table width='330' height='150' border='4' align='center'>
  <tr align='center'>
    <td width='150'>$image</td>
    <td width='30'>VS.</td>
    <td width='150'>$pics</td>
  </tr>
</table>
");
break;


updated function:

Code:
function avatar_picture($acctid) {
if (get_module_pref("validated","avatar",$acctid) && get_module_pref("avatar","avatar",$acctid)!='') {
$pics="<img src='".get_module_pref("avatar","avatar",$acctid)."' ALT='Your foe!' width='100%'>";
return $pics;
} else {
$pics=translate_inline("Avatar not validated yet");
return $pics;
}
}

attached, i have a screenshot which shows a lot of avatars, not good... the tuareg would be me, the cat would be the attacked player...

please, help....

Thank you.
« Last Edit: September 24, 2008, 12:12:21 am 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!