karma   
		
			Moderator 
			     
			
			
 
 
			
	Posts: 178 
	Likes Given: 17
 
Likes Received: 32 in 29 posts 
	Joined: Jul 2012
	
 Reputation: 3
  
			
 ![]()  
		
	 | 
	
		
			
Custom sysmessage function 
			 
			
				Given the Uncode Text Packet AE: 
Code: 
 byte ID (AE) 
word Packet Size 
dword Serial 
word Graphic 
byte 
Mode (0x00 = say, 0x01 = system, 0x02 = emote, 0x06 = label, 0x07 = focus, 0x08 = whipser, 0x09 = yell, 0x10 = spell, 0x13 = guild, 0x14 = alliance, 0x15 = GM, 0xC0 = encoded commands) 
word Text Color 
word Font 
char[4] Language 
char[30] Name 
uchar[*] Text
  
I want to write a function for sending sysmessages (or other text types/talkmodes), which also enables me to specify the fields: Serial, Mode and Name. 
Each letter in Language, Name and Text is sent not as plain text obviously, but as a number, which is the ASCII or Unicode(?) value for the letter itself. 
Is there an automatic way to obtain the numeric value for each letter? I thought something like <hval "blabla">, but as i expected it did not work.
			  
			
			
			
		 |  
	 
 | 
	| 04-22-2014 08:33 AM | 
	
		
	 | 
	
	
		   
		 
		
	 | 
	
		
		darksun84   
		
			Sir Spamalot 
			     
			
			
 
 
			
	Posts: 1,687 
	Likes Given: 245
 
Likes Received: 162 in 151 posts 
	Joined: Mar 2012
	
 Reputation: 35
  
			
 ![]()  
		
	 | 
	
		
			
RE: Custom sysmessage function 
			 
			
				you can try with the ASC or ASCPAD function  
PHP Code: 
 ASC text     R     Converts text into a series of ASCII values. ASCPAD size,text     R     Converts text into a series of ASCII values, padded with 0s untill size is reached. Will also truncate the text if longer then size 
 
  
the ascii values returned are in hex format, so you'll have to eval them.
 
You can also use CHR for retrieving the character
 PHP Code: 
 CHR ascii_code     R     Returns the character represented by the given ASCII code. 
 
  
			 
			
			
			
		 |  
	 
 | 
	| 04-22-2014 08:52 AM | 
	
		
	 | 
	
	
		   
		 
		
	 | 
	
		
		karma   
		
			Moderator 
			     
			
			
 
 
			
	Posts: 178 
	Likes Given: 17
 
Likes Received: 32 in 29 posts 
	Joined: Jul 2012
	
 Reputation: 3
  
			
 ![]()  
		
	 | 
	
		
			
Custom sysmessage function 
			 
			
				Thanks darksun, that was exactly what i needed! 
NTH EDIT: the newer version of this function is here:  http://forum.spherecommunity.net/Thread-...h-function
Here's the function, maybe it will be useful to someone.
 
Code: 
 [FUNCTION UTEXT] 
//sends unicode text packet to client and allows to specify useful data, which usually is automatic 
//SYNTAX: UTEXT serial, talkmode, name, color, text 
 
//serial: UID of the char speaking or receiving text (like sysmessage) 
//name: who is speaking/sending text 
 
//Packet structure: 
//byte ID (AE) 
//word Packet Size //length in bytes 
//dword Serial 
//word Graphic 
//byte Mode (0x00 = say, 0x01 = system, 0x02 = emote, 0x06 = label, 0x07 = focus, 
//  0x08 = whisper, 0x09 = yell, 0x10 = spell, 0x13 = guild, 0x14 = alliance, 0x15 = 
//  GM, 0xC0 = encoded commands) (reported talkmodes may not be correct) 
//word Text Color 
//word Font 
//char[4] Language 
//char[30] Name 
//uchar[*] Text  //no fixed dimension 
 
IF (<ARGV> < 5) 
    RETURN 0 
ENDIF 
 
LOCAL.SERIAL=0<ARGV[0]> 
IF !(<LOCAL.SERIAL>) 
    LOCAL.SERIAL=<UID> 
ENDIF 
LOCAL.TALKMODE=0<ARGV[1]> 
LOCAL.NAME=<ARGV[2]> 
IF (<ISNUM <LOCAL.NAME>>) 
    IF !(<LOCAL.NAME>) 
        LOCAL.NAME=<NAME> 
    ENDIF 
ENDIF 
LOCAL.COLOR=0<ARGV[3]> 
LOCAL._TEXT=<ARGV[4]> 
LOCAL._TEXTLEN=<HVAL STRLEN(<LOCAL._TEXT>)> 
LOCAL.GRAPHIC=01 090 
LOCAL.FONT=00 03 
LOCAL.LANGUAGE=00 00 00 00 //no localization 
//LOCAL.LANGUAGE=045 04E 055 00 //ENU 
LOCAL.NAME=<ASCPAD 30, <LOCAL.NAME>> 
LOCAL._TEXT=<ASC <LOCAL._TEXT>> 
 
LOCAL.TEXT=00 <STRARG <LOCAL._TEXT>> 
LOCAL._TEXT=<STREAT <LOCAL._TEXT>> 
FOR 2 <LOCAL._TEXTLEN> 
    LOCAL.TEXT=<LOCAL.TEXT> 00 <STRARG <LOCAL._TEXT>> 
    LOCAL._TEXT=<STREAT <LOCAL._TEXT>> 
ENDFOR 
LOCAL.TEXT=<LOCAL.TEXT> 00 00 
LOCAL._TEXTLEN += 1 
LOCAL.LEN=( (<LOCAL._TEXTLEN>*2)+1+2+4+2+1+2+2+4+30 ) 
 
SENDPACKET 0AE W(<LOCAL.LEN>) D(<LOCAL.SERIAL>) <LOCAL.GRAPHIC> B(<LOCAL.TALKMODE>) W(<LOCAL.COLOR>) <LOCAL.FONT> <LOCAL.LANGUAGE> <LOCAL.NAME> <LOCAL.TEXT> 
RETURN 1
  
EDIT: if this function is used to make char SAY something, you may want to put SENDPACKET inside a FORCLIENTS 16, otherwise it will works as a MESSAGE, showing the text only to you 
EDIT 2: lol, wrote ENDWHILE instead of ENDFOR
			  
			
			
			
				
(This post was last modified: 05-04-2014 09:59 AM by karma.)
 
				
			 
		 |  
	 
 | 
	| 04-22-2014 10:02 PM | 
	
		
	 | 
	
	
		   
		The following 1 user Likes karma's post:1 user Likes karma's post 
		darksun84 (04-22-2014)
	 |