Comments (1)
It's quite easy to do, you can use PR_BITS to get an arbitrary amount of bits and then format them as hex in a loop.
Note that raknet bitstreams are neither aligned nor padded. Meaning single bits (ie. bool) will cause the rest of the data to no longer be aligned with the half-byte or byte boundaries of the displayed hex (one single digit in hex represents 4 bits of data).
Without knowing the parameter list you cannot meaningfully format it, so keep that in mind.
I made this some time ago, you can use it if you still need it.
The code can be heavily simplified, but I wanted to add some readability in the output (and a simple display if the end if there are for example 3 bits leftover).
static hex_data[2048];
hex_data = "";
new hex_len = 0,
tmp_text[6],
total_bits,
bits_left,
character_count = 0;
BS_GetNumberOfBitsAllocated(bs, total_bits); // Use BS_GetNumberOfUnreadBits if you want to BS_IgnoreBits before this
bits_left = total_bits;
while(bits_left > 0)
{
new read_len = bits_left > 4 ? 4 : bits_left,
value;
BS_ReadValue(bs, PR_BITS, value, read_len);
bits_left -= read_len;
if(read_len == 4)
format(tmp_text, sizeof(tmp_text), "%x", value);
else
format(tmp_text, sizeof(tmp_text), "%x{%i}", value, read_len); // If not a full half-byte, display the number of bits (this only happens on the last chunk)
if((++character_count) % 2 == 0) // Spacing, optional
strcat(tmp_text, " ");
if(hex_len + strlen(tmp_text) >= sizeof(hex_data) - sizeof(tmp_text)) // Cannot append more
{
strcat(hex_data, "...");
break;
}
hex_len += strcat(hex_data, tmp_text);
}
BS_ResetReadPointer(bs); // Only required if you want to do something else with this bs handle.
printf("rpc %i [%i]: %s", rpcid, total_bits, hex_data);
from pawn.raknet.
Related Issues (20)
- How can i detect fake SendClientCheck? HOT 1
- crash server HOT 1
- Pawn.Raknet's giving too many errors
- Pawn.RakNet crashing with sampvoice HOT 1
- someone please help me HOT 1
- edit
- open.mp build 11 update
- Exception At Address: 0x7084DE82 Module: (pawnraknet.DLL) HOT 1
- Server crashed due to an unknown error HOT 1
- [1.5.1-omp] Long callback execution
- Question about OPacket HOT 1
- About IRawPacket HOT 2
- Пакеты не приходят HOT 6
- Crash
- Run time error 19: "File or function is not found
- Attempted to read/write array element at negative index -1 on OnIncomingRPC HOT 1
- La vida real versión all Countries HOT 1
- server crashed
- PR_STRING32 Read
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pawn.raknet.