CLEO Help Printing the gametext message.

CLEO related
Status
Not open for further replies.

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
53
Location
LongForgotten <-> 0x32789
I'm trying to take the raw text out of game text using RPCs, I've readed all of the parameters (D[font=arial, sans, sans-serif]WORD style, DWORD time, DWORD strLen, char[] msg) as shown here: https://docs.google.com/spreadsheets/d/1iIxEk7yR8r7ZLGiSAL4ndtz_N1k0p3Wt7TE5bei6ztU/[/font]
Now I think my problem is with the char[] msg param, I'm trying to read an array as its a char array and then removing the null character at the end of the message but when I try to print it as 0AF8: it gives nothing, Its like:
"GameText: "
Its just a space, I tried to go in different server with different gametext, same thing. I wonder whats wrong?
This is my code, I took some help from SF tutorials and examples.
Code:
:IncomingRPC
0BE5: raknet 0@ = get_hook_param PARAM_PACKETID
if and
0@ == RPC_SCRDISPLAYGAMETEXT // GameText
31@ == 1
then
   0BE5: raknet 1@ = get_hook_param PARAM_BITSTREAM 
   0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
   0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
   0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_BYTE
   0AC8: 3@ = allocate_memory_size 32
   0BE8: raknet bit_stream 1@ read_array 3@ size 2@ 
   0C1E: array 3@ element 2@ el_size 1 = 0
   0AF8: samp add_message_to_chat "GameText Got: %s" color -1 params 3@
   0AC9: free_allocated_memory 3@ 
end
0BE0: raknet hook_ret true
@springfield 
@0x688
@and all the other pros
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
Why would you delete null terminate character if you will print it as a string? And perhaps shouldn't you read all parameters and store them to the vars since it is causing problems for no reason?
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
53
Location
LongForgotten <-> 0x32789
supahdupahnubah said:
Why would you delete null terminate character if you will print it as a string? And perhaps shouldn't you read all parameters and store them to the vars since it is causing problems for no reason?

I wouldnt want to waste vars but I'll try. Thanks for the info though.
EDIT: I commented the " delete null terminate character" line and stored the parameters as variables, still it doesn't print anything.
Code:
    0BE5: raknet 1@ = get_hook_param PARAM_BITSTREAM 
    0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_INT
    0BE7: raknet 3@ = bit_stream_read 1@ type BS_TYPE_INT
    0BE7: raknet 4@ = bit_stream_read 1@ type BS_TYPE_BYTE
    0AC8: 5@ = allocate_memory_size 32
    0BE8: raknet bit_stream 1@ read_array 5@ size 4@ 
    //0C1E: array 5@ element 4@ el_size 1 = 0
    0AF8: samp add_message_to_chat "GameText Got: %s" color -1 params 5@
    0AC9: free_allocated_memory 5@
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
273
0x32789 said:
I've readed all of the parameters DWORD style, DWORD time, DWORD strLen, char[] msg)
<snip>
0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_BYTE

You've said it yourself, it's DWORD, DWORD, DWORD, but then you proceed to read DOWRD, DWORD, BYTE, this alone would cause problems.

0x32789 said:
Now I think my problem is with the char[] msg param, I'm trying to read an array as its a char array and then removing the null character at the end of the message

Well, bitstreams don't have a string type, you only have an array of bytes. That means there is no null terminating char, or the array itself might not be a string, so using string funcs. like strlen/strcpy etc. would fail. That's why the length is embedded in the stream before the array, so you know exactly how much to read.

[shcode=cpp]
IF 0@ == RPC_SCRDISPLAYGAMETEXT
THEN
   0BE5: raknet 1@ = get_hook_param PARAM_BITSTREAM
   //ignore gamtext style and time (8bytes = 64bits)
   0BEB: raknet bit_stream 1@ ignore_bits 64
   //read text length                                    
   0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_INT
   //allocate text length + 1 for null terminating char  
   0A8E: 3@ = 2@ + 1
   alloc 4@ = 3@
   //clear buffer, make sure last char is 0
   0C11: memset 4@ value 0 size 3@
   //read to buffer with size
   0BE8: raknet bit_stream 1@ read_array 4@ size 2@
   chatmsg "GameText: %s" -1 4@
   free 4@
END
[/shcode]
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
53
Location
LongForgotten <-> 0x32789
springfield said:
0x32789 said:
I've readed all of the parameters DWORD style, DWORD time, DWORD strLen, char[] msg)
<snip>
0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_BYTE

You've said it yourself, it's DWORD, DWORD, DWORD, but then you proceed to read DOWRD, DWORD, BYTE, this alone would cause problems.

0x32789 said:
Now I think my problem is with the char[] msg param, I'm trying to read an array as its a char array and then removing the null character at the end of the message

Well, bitstreams don't have a string type, you only have an array of bytes. That means there is no null terminating char, or the array itself might not be a string, so using string funcs. like strlen/strcpy etc. would fail. That's why the length is embedded in the stream before the array, so you know exactly how much to read.

[shcode=cpp]
IF 0@ == RPC_SCRDISPLAYGAMETEXT
THEN
   0BE5: raknet 1@ = get_hook_param PARAM_BITSTREAM
   //ignore gamtext style and time (8bytes = 64bits)
   0BEB: raknet bit_stream 1@ ignore_bits 64
   //read text length                                    
   0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_INT
   //allocate text length + 1 for null terminating char  
   0A8E: 3@ = 2@ + 1
   alloc 4@ = 3@
   //clear buffer, make sure last char is 0
   0C11: memset 4@ value 0 size 3@
   //read to buffer with size
   0BE8: raknet bit_stream 1@ read_array 4@ size 2@
   chatmsg "GameText: %s" -1 4@
   free 4@
END
[/shcode]
Thanks as always, Next time I'll be more careful.
 

ParkCant

Member
Joined
Jul 2, 2017
Messages
8
Reaction score
0
0x32789 said:
springfield said:
0x32789 said:
I've readed all of the parameters DWORD style, DWORD time, DWORD strLen, char[] msg)
<snip>
0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_BYTE

You've said it yourself, it's DWORD, DWORD, DWORD, but then you proceed to read DOWRD, DWORD, BYTE, this alone would cause problems.

0x32789 said:
Now I think my problem is with the char[] msg param, I'm trying to read an array as its a char array and then removing the null character at the end of the message

Well, bitstreams don't have a string type, you only have an array of bytes. That means there is no null terminating char, or the array itself might not be a string, so using string funcs. like strlen/strcpy etc. would fail. That's why the length is embedded in the stream before the array, so you know exactly how much to read.

[shcode=cpp]
IF 0@ == RPC_SCRDISPLAYGAMETEXT
THEN
   0BE5: raknet 1@ = get_hook_param PARAM_BITSTREAM
   //ignore gamtext style and time (8bytes = 64bits)
   0BEB: raknet bit_stream 1@ ignore_bits 64
   //read text length                                    
   0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_INT
   //allocate text length + 1 for null terminating char  
   0A8E: 3@ = 2@ + 1
   alloc 4@ = 3@
   //clear buffer, make sure last char is 0
   0C11: memset 4@ value 0 size 3@
   //read to buffer with size
   0BE8: raknet bit_stream 1@ read_array 4@ size 2@
   chatmsg "GameText: %s" -1 4@
   free 4@
END
[/shcode]
Thanks as always, Next time I'll be more careful.

What this code do? send messenger to another computer use cleo?
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
53
Location
LongForgotten <-> 0x32789
ParkCant said:
0x32789 said:
springfield said:
0x32789 said:
I've readed all of the parameters DWORD style, DWORD time, DWORD strLen, char[] msg)
<snip>
0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
0BE7: raknet -1 = bit_stream_read 1@ type BS_TYPE_INT
0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_BYTE

You've said it yourself, it's DWORD, DWORD, DWORD, but then you proceed to read DOWRD, DWORD, BYTE, this alone would cause problems.

0x32789 said:
Now I think my problem is with the char[] msg param, I'm trying to read an array as its a char array and then removing the null character at the end of the message

Well, bitstreams don't have a string type, you only have an array of bytes. That means there is no null terminating char, or the array itself might not be a string, so using string funcs. like strlen/strcpy etc. would fail. That's why the length is embedded in the stream before the array, so you know exactly how much to read.

[shcode=cpp]
IF 0@ == RPC_SCRDISPLAYGAMETEXT
THEN
   0BE5: raknet 1@ = get_hook_param PARAM_BITSTREAM
   //ignore gamtext style and time (8bytes = 64bits)
   0BEB: raknet bit_stream 1@ ignore_bits 64
   //read text length                                    
   0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_INT
   //allocate text length + 1 for null terminating char  
   0A8E: 3@ = 2@ + 1
   alloc 4@ = 3@
   //clear buffer, make sure last char is 0
   0C11: memset 4@ value 0 size 3@
   //read to buffer with size
   0BE8: raknet bit_stream 1@ read_array 4@ size 2@
   chatmsg "GameText: %s" -1 4@
   free 4@
END
[/shcode]
Thanks as always, Next time I'll be more careful.

What this code do? send messenger to another computer use cleo?
Nah, first you need to learn about raknet, its the networking system SA-MP client and server uses for players to connect to them and other players use to connect to server and retrieve/send information.
This code just checks if there is a gametext RPC (REMOTE PROCEDURE CALL) and if it is, it will print me back what is actual gametext (the raw gametext with the colors)
 
Status
Not open for further replies.
Top