Page 1 of 1
name hook
Posted: Fri Dec 05, 2008 9:41 am
by coltain
I hooked a packed:
Code: Select all
Packet 0x1C
{
Length variable
SendFunction main/name_hooks:HandleUCNOutgoing
}
Code: Select all
program name_hooks()
Print( "Podlaczam wychodzace imiona..." );
return 1;
endprogram
exported function HandleUCNOutgoing(cel, byref packet )
//here i change existing packet
return 0;
endfunction
but if I set:
Code: Select all
program name_hooks()
Print( "Podlaczam wychodzace imiona..." );
return 1;
endprogram
exported function HandleUCNOutgoing(cel, byref packet )
//here i change existing packet
printtextabove(cel,"testing");
return 0;
endfunction
I get a spam of message testing when a name of a mobile shown (first spam, later 1 name)
Why this is happening???
How to change a packet.GetString(14,30) ??? <- aka name
Re: name hook
Posted: Sat Dec 06, 2008 11:36 am
by coltain
As I see, this causes lag when a player enters a location filled with mobiles.
Any response?
Re: name hook
Posted: Sat Dec 06, 2008 11:54 am
by CWO
Depending on how much code you have in it, you would get lag because packethooks are run critical.
Re: name hook
Posted: Sat Dec 06, 2008 11:59 am
by Pierce
The 0x1C packet sends ASCII text to the client, e.g. normal speech, system messages,
appearing names and a lot more.
By using PrintTextAbove(cel,"testing"); inside the exported function you also send
another new 0x1c packet and that packet again also sends a PrintTextAbove which causes
another new 0x1c packet.............
I think it's better you use a Print("Testing"); and watch the console in this special case

Re: name hook
Posted: Sat Dec 06, 2008 2:08 pm
by coltain
Thx Pierce
I thought that Printtextabove is send by using "send unicode message packet". I`ll chack it again.
CWO no more code is in it that I presented (reduced all for tests).
Re: name hook
Posted: Sat Dec 06, 2008 2:24 pm
by coltain
Pierce was right, it was my mistake.
I can change a font and color of the string by using packet.SetInt16(offset,value) but can anyone give me an example how to use packet.SetString(offset, string)???
to get a string I use packet.GetString(14,30) but using packet.SetString(14, "Test") doesn`t do anything. Do I have to enlarge the string I want to "put" in to 30 bytes???
I`m kind of new in packets so please... help me...

Re: name hook
Posted: Sun Dec 07, 2008 5:26 am
by Pierce
May i ask for which purpose you want to change the name in that packet?
You may need to null terminate the string, cause the 30 bytes of the name are
always null terminated to the end of the 30 bytes, as you can see in this example
of a system Message, where the name is "System":
Code: Select all
0000: 1C 4E 00 01 01 01 01 01 01 00 03 B2 00 03 53 79 ->.N............Sy
0010: 73 74 65 6D 00 00 00 00 00 00 00 00 00 00 00 00 ->stem............
0020: 00 00 00 00 00 00 00 00 00 00 00 00 59 6F 75 20 ->............You
0030: 68 61 76 65 20 65 6E 74 65 72 65 64 20 74 68 65 ->have entered the
0040: 20 41 72 65 61 20 42 42 42 42 42 42 42 00 -> Area BBBBBBB.
You could try a
which set a null terminator after the last "t". I don't know if that works if the
name before your change was quite longer. I think you need to test how the client
reacts on that.
Re: name hook
Posted: Sun Dec 07, 2008 10:24 pm
by CWO
Likely you need to set all 30 bytes in the name to 00 first then packet.setstring()...
Re: name hook
Posted: Mon Dec 08, 2008 2:09 pm
by Nando
What do you intend to do? Wouldn't it be better to hook the Single Click packet?
Re: name hook
Posted: Mon Dec 08, 2008 10:50 pm
by coltain
I hooked a single click packet and it worked fine untill.. I noticed some side effects.
Players began to loose their backpacks - it simply dissapired from the gump. I presumed that is connected with some core function (open.... or sendview...) to use a container or... some conflict with other packets (eg. packet that blocks removing a backpack)
I want to add something to the character name when its shown, one char "!" or "&" depending on a race.
Or.. When a name is shown - print a char "!" under it (in the next line)
Re: name hook
Posted: Tue Dec 09, 2008 7:46 am
by Pierce
I've just tested a quick and dirty solution of what you wanted.
Because it was on a test server, i did not change player names.
Instead i change the appearing npc names with that script.
So everything like "Bodo the guard" or "a cow" now appears as "PP"
Ah and you need to set the string on position 44 not 14 as you can see.
Code: Select all
program name_hooks()
Print( "Podlaczam wychodzace imiona..." );
return 1;
endprogram
exported function HandleUCNOutgoing(cel, byref packet )
var player;
var objserial := packet.GetInt32(3);
if(objserial != 16843009) // 01 01 01 01 System Messages
player := SystemFindObjectBySerial(objserial, SYSFIND_SEARCH_OFFLINE_MOBILES); //in case char is disconnected
if(player)
if(player.acctname)
else
packet.SetString(44, "PP", 1);
endif
endif
endif
return 0;
endfunction
Re: name hook
Posted: Tue Dec 09, 2008 8:26 am
by coltain
BYTE[1] cmd
BYTE[2] Packet len
BYTE[4] itemID (FF FF FF FF = system)
BYTE[2] model (item # - FF FF = system)
BYTE[1] Type of Text
BYTE[2] Text Color
BYTE[2] Font
BYTE[30] Name
BYTE[?] Null-Terminated Msg (? = Packet length - 44)
bleh,
*his head hits keyboard*
I took "BYTE[30] Name" for a name of a mobile, not a Name of sender (as I preasume - System in this case)
Didn`t noticed "Null-Terminated Msg" grr - taken it for a null sign to end a message
Thx
Re: name hook
Posted: Fri Dec 19, 2008 5:54 am
by coltain
This is not good
Well, it works but when somebody says something the thing I added is shown either.
Pol uses this packet to send other messages too so...
Re: name hook
Posted: Fri Dec 19, 2008 6:13 am
by Pierce
What is the value of "Type of Text" if somebody says something?
Is it also zero or different from that?
Re: name hook
Posted: Fri Dec 19, 2008 8:51 am
by coltain
POL uses printtextabove function to show the names of incoming creatures...
So If I use this function in any of the script i will show an added thind too.
I think I have to use a cliloc to show it (but the core doesn`t send this packet everytime a mobile enters but only once - with some delay as I preasume).
Btw
Is there a way to enable a ENTEREDAREA event to a player? I tried to do this in a logon.src by starting a script with this code.
Code: Select all
while(kto.ip)
var ev := os::wait_for_event(10);
Printtextabove(kto,"Czekam");
if(ev)
case(ev.type)
EVID_ENTEREDAREA:
Printtextabove(kto,"Kogos widze");
endcase
endif
endwhile
but it doesn`t react on events...
Re: name hook
Posted: Fri Dec 19, 2008 12:20 pm
by ncrsn
coltain wrote:POL uses printtextabove function to show the names of incoming creatures...
You DO know that POL doesn't really show names of incoming creatures, it just reacts to client's singleclick packet WHICH is send when new creature appears on the screen IF player has this option turned on?
Re: name hook
Posted: Fri Dec 19, 2008 12:29 pm
by coltain
Yes, POL uses singleclick packet, after clicking a printtextabove function is called (if I`m wrong, tell me), I tried to use singleclick packet but strange things occure. I wrote about it earlier.
Re: name hook
Posted: Fri Dec 19, 2008 12:45 pm
by Pierce
You don't need the single click packet.
Try this one and check if it helps in your case:
Code: Select all
exported function HandleUCNOutgoing(cel, byref packet )
var player;
var objserial := packet.GetInt32(3);
var model := packet.GetInt16(7);
var type := packet.GetInt8(9);
var mtype := {400, 401,605,606};
if(objserial != 16843009) // 01 01 01 01 System Messages
if(!(model in mtype))
player := SystemFindObjectBySerial(objserial, SYSFIND_SEARCH_OFFLINE_MOBILES); //in case char is disconnected
if(player)
if(player.acctname)
packet.SetString(44, "Whatever", 1);
else
// packet.SetString(44, "PP", 1);
endif
endif
endif
endif
return 0;
endfunction