whats this strange problem with rpc

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
hai, im trying to read a GiveTakeDamage RPC and whenever I read I can ONLY read the first parameter, (id)
and after that insane values like -10102501290581205829058190285 or 1290581258129056923906 starts coming
I dont know even what parameter is the bodypart and I have like tried in all..
ID works but b1, etc all of em returning senseless values.
my code
Code:
if (uniqueID == RPC_GiveTakeDamage && set.autoheadshot == true)
	{
		short id;
		short body;
		UINT b2;
		UINT16 b3;
		uint16_t b4;
		UINT32 b5;
		int b6;
		parameters->SetReadOffset(1);
		parameters->Read(id);
		parameters->SetReadOffset(2);
		parameters->Read(body);
		parameters->SetReadOffset(2);
		parameters->Read(b2);
		parameters->SetReadOffset(2);
		parameters->Read(b3);
		parameters->SetReadOffset(2);
		parameters->Read(b4);
		parameters->SetReadOffset(2);
		parameters->Read(b5);
		parameters->SetReadOffset(2);
		parameters->Read(b6);
		addMessageToChatWindow("ID: %d - B1: %d - B2: %d - B3: %d - B4: %d - B5: %d - B6: %d", id, body, b2, b3, b4, b5, b6);
		parameters->SetReadOffset(3);
		parameters->Read(body);
		parameters->SetReadOffset(3);
		parameters->Read(b2);
		parameters->SetReadOffset(3);
		parameters->Read(b3);
		parameters->SetReadOffset(3);
		parameters->Read(b4);
		parameters->SetReadOffset(3);
		parameters->Read(b5);
		parameters->SetReadOffset(3);
		parameters->Read(b6);
		addMessageToChatWindow("ID: %d - B1: %d - B2: %d - B3: %d - B4: %d - B5: %d - B6: %d", id, body, b2, b3, b4, b5, b6);
		parameters->SetReadOffset(4);
		parameters->Read(body);
		parameters->SetReadOffset(4);
		parameters->Read(b2);
		parameters->SetReadOffset(4);
		parameters->Read(b3);
		parameters->SetReadOffset(4);
		parameters->Read(b4);
		parameters->SetReadOffset(4);
		parameters->Read(b5);
		parameters->SetReadOffset(4);
		parameters->Read(b6);
		addMessageToChatWindow("ID: %d - B1: %d - B2: %d - B3: %d - B4: %d - B5: %d - B6: %d", id, body, b2, b3, b4, b5, b6);
	}
this code is in my outcoming rpc's and if I just write offset 1 to like number of head = 9, so if I do it parameters->Write(9); after doing parameters->SetWriteOffset(...)
it will put sense less values in all of them
I tested using showcallbacks and this is what I got
ID: 32728 pos NaN and bodypart -1205912 bla bla 
Am I doing something wrong? Can someone explain that to me?
 

.silent

Well-known member
Joined
Apr 14, 2013
Messages
339
Reaction score
13
These SetReadOffsets aren't needed, in fact they are probably corrupting your data. They are BIT offsets, after reading "id" which is 2 bytes from offset 1, you set the offset to the second bit, it just reads incorrect data. BitStreams' Read() method moves the offset automatically, try reading without any SetReadOffset() call, it's mainly used to skip some parts of data in the bit stream.
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Those 'insane' values could also be floats that you display as ints.
But like silent said, reading random data types from a random offset of a bit set should output random values.

If i remember right, the rpc struct is as follows;
byte - give/take
word - player id
float - damage
int - weapon
int - bodypart

Could be wrong, idk.
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
springfield said:
Those 'insane' values could also be floats that you display as ints.
But like silent said, reading random data types from a random offset of a bit set should output random values.

If i remember right, the rpc struct is as follows;
byte - give/take
word - player id
float - damage
int - weapon
int - bodypart

Could be wrong, idk.
I tried something like this right now
parameters->ResetReadPointer();
parameters->Read(gtd);
bla bla and in the order
still wrong values but I used short for player ID i think.
 

AR3S

Active member
Joined
Apr 7, 2016
Messages
41
Reaction score
0
Code:
bool bGiveOrTake;
short int iPlayerID;
float fAmmount;
int iWeaponID, iBodyPart;
 
parameters->ResetReadPointer();
parameters->Read(bGiveOrTake);
parameters->Read(iPlayerID);
parameters->Read(fAmmount);
parameters->Read(iWeaponID);
parameters->Read(iBodyPart);

worked for me
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
AR3S said:
Code:
bool bGiveOrTake;
short int iPlayerID;
float fAmmount;
int iWeaponID, iBodyPart;
 
parameters->ResetReadPointer();
parameters->Read(bGiveOrTake);
parameters->Read(iPlayerID);
parameters->Read(fAmmount);
parameters->Read(iWeaponID);
parameters->Read(iBodyPart);

worked for me
oh lol I mistakely added float into iBodyPart in my code
working now thanks you all for helping me with my codenz
 
Top