PenUltima Online

It is currently Sat Sep 06, 2008 1:21 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Itemdesc Hook
PostPosted: Sat Sep 01, 2007 1:26 am 
Offline

Joined: Mon Jun 11, 2007 1:35 pm
Posts: 38
it is possible to change color of displayed text over item when i 1xClick Left mouse button ? ( without tooltip)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 01, 2007 2:15 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 217
You can use singleclick packethook.

http://packets.polserver.com/index.php?op=showpacket&packet=0x09.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 01, 2007 4:36 am 
Offline

Joined: Mon Jun 11, 2007 1:35 pm
Posts: 38
but there is nothing about item color...could u show me some example of it?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 01, 2007 6:20 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 217
Yessir.

You are right, I explained poorly.

We are using method where we first hook the singleclick and collect some data from object the player clicked. After that we send player a PrintTextAbovePrivate() with modified content. More optimal way would be creating and sending text packet instead of making core do it, but that's not part of this tuto.

Example of uopacket.cfg and singleclick.src below.

:singleclick:uopacket (.cfg)
Code:
Packet 0x09
{
  Length            5
  ReceiveFunction   singleclick:singleclickhook
}



:singleclick:singleclick (.src)
Code:
use uo;

program singleclick ( )
   print("Hooking singleclickpacket");
   return 1;
endprogram

exported function singleclickhook( who, byref packet )
    // Packet contains only the serial
    var object := SystemFindObjectBySerial(packet.GetInt32(1));
   
    if (object.isa(POLCLASS_ITEM))
        // So player clicked an item. Change text color to item's color.
        // Of course color can be anything, this is just an example.

        var color := object.color;
       
        PrintTextAbovePrivate(object, object.desc, who, _DEFAULT_TEXT_FONT, color);

        // --> player clicks green axe, he/she will get 'an axe' with green color.
       
        // Return 1 so core won't react.
        return 1;
    endif

    // If it was not an item, core will do.
    return 0;

endfunction


Code is mostly pseudo, but should give you the idea.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 01, 2007 6:58 am 
Offline

Joined: Sat Feb 04, 2006 6:26 pm
Posts: 547
This sound like a different way to handle tooltips.
See the megacliloc packethook. Since it's in html format, you can change the colour of the text.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 01, 2007 11:13 am 
Offline

Joined: Mon Jun 11, 2007 1:35 pm
Posts: 38
thx this is exactly what i want


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 01, 2007 6:58 pm 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 748
Location: Chicago, IL USA
You can also change color displaying above things in the "send speech" packet. http://packets.polserver.com/index.php? ... acket=0x1C


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 7:17 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
POL is soooo versatile!!!

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl