Raised This Month: $51 Target: $400
 12% 

[Solved] UpdateRadar usermessage structure reading/writing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 05-15-2011 , 14:47   [Solved] UpdateRadar usermessage structure reading/writing
Reply With Quote #1

I'm trying to figure out how to read/write the UpdateRadar usermessage in CS:S.
Due to my lack of assembly understanding asherkin were kind enough to narrow down the structure of the usermessage:

Quote:
Originally Posted by asherkin
(17:54:43) (asherkin) it's a loop from 0 to 65
(17:54:54) (asherkin) checks some player stuff to make sure they are valid
(17:55:13) (asherkin) WRITE_BYTE player entity index
(17:556) (asherkin) WRITE_SBITLONG(pPlayer->GetAbsOrigin().x/4, 13);
(17:55:43) (asherkin) then y, then z
(17:56:03) (asherkin) then pPlayer->GetAbsAngles().y, which is normalized
(17:56:16) (asherkin) then written with a byte count of 9
(17:561) (Peace-Maker) byte count?
(17:565) (Peace-Maker) bit*?
(17:567) (asherkin) then WRITE_BYTE of 0 at the end of the message
(17:56:49) (asherkin) *bit count
(17:56:52) (asherkin) yeah
Now the question raising: How would i read 13 bits of a float in sourcepawn?

I've tried using BfReadBool(bf) as psychonic suggested, bit-shifted to assemble it again and added the Float: tag, but the results are far too high or just 0.0.
PHP Code:
iBuf2 0;
for(new 
i=0;i<13;i++)
{
    
iBuf BfReadBool(bf);
    
iBuf2 = (iBuf2<<1);
    
iBuf2 |= iBuf;
}
iBuf2 = (iBuf2<<19);
PrintToServer("x %f"Float:fBuf*4.0); 
How would i go to get the proper float value off that 13 bits?

Some example output of the attached plugin with 4 bots playing:
Code:
Message length: 15.
1: Steve (1)
2: x 0.000000
3: y -906694364710971900000000.000000
4: z -507904.000000
5: ang y norm -0.000000
Position: 352.182159 2462.959472 -116.450592
Y angle: 358.204223
6: Xavier (3)
7: x 0.000000
8: y 0.000000
9: z 507904.000000
10: ang y norm -0.000000
Position: 160.000000 2464.000000 -120.489982
Y angle: 358.183074
11: Console (0)
12: 0
Message length: 15.
1: Troy (2)
2: x 0.000000
3: y 34084860461056.000000
4: z 0.000000
5: ang y norm -0.000000
Position: -831.998535 -856.001770 128.666870
Y angle: 358.274139
6: Ian (4)
7: x 0.000000
8: y 520093696.000000
9: z -0.000000
10: ang y norm -0.000000
Position: -736.172302 -824.172424 133.405746
Y angle: 358.299560
11: Console (0)
12: 0
Message length: 15.
1: Steve (1)
2: x 0.000000
3: y -906694364710971900000000.000000
4: z -507904.000000
5: ang y norm -0.000000
Position: 352.182159 2462.959472 -116.450592
Y angle: 358.204223
6: Xavier (3)
7: x 0.000000
8: y 0.000000
9: z 507904.000000
10: ang y norm -0.000000
Position: 160.000000 2464.000000 -120.489982
Y angle: 358.183074
11: Console (0)
12: 0
Message length: 15.
1: Troy (2)
2: x 0.000000
3: y 34084860461056.000000
4: z 0.000000
5: ang y norm -0.000000
Position: -831.998535 -856.001770 128.666870
Y angle: 358.274139
6: Ian (4)
7: x 0.000000
8: y 520093696.000000
9: z -0.000000
10: ang y norm -0.000000
Position: -736.172302 -824.172424 133.405746
Y angle: 358.299560
11: Console (0)
12: 0
Attached is the current testing code.

PHP Code:
#pragma semicolon 1
#include <sourcemod>

new bool:g_bPrint true;

public 
OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("UpdateRadar"), MsgHook_UpdateRadarfalse);
    
RegConsoleCmd("usrmsg_s"Cmd_Stop);
}

public 
Action:Cmd_Stop(clientargs)
{
    
g_bPrint = !g_bPrint;
    return 
Plugin_Handled;
}

public 
Action:MsgHook_UpdateRadar(UserMsg:msg_idHandle:bf, const players[], playersNumbool:reliablebool:init)
{
    if(!
g_bPrint)
        return;
    
    new 
iLength BfGetNumBytesLeft(bf);
    
PrintToServer("Message length: %d."iLength);
    
    if(
iLength <= 1)
        return;
    
    new 
iBuf;
    new 
idx 0;
    while(
BfGetNumBytesLeft(bf) > 0)
    {
        
// Player index
        
iBuf BfReadByte(bf);
        
PrintToServer("%d: %N (%d)", ++idxiBufiBuf);
        
        
PrintClientInfo(bfidxiBuf);
        
        
iBuf BfReadByte(bf);
        if(
iBuf 0)
        {
            
PrintToServer("%d: %N (%d)", ++idxiBufiBuf);
            
PrintClientInfo(bfidxiBuf);
        }
        else
            
PrintToServer("%d: %d", ++idxiBuf);
    }
}

PrintClientInfo(Handle:bf, &idxclient)
{
    if(
client == 0)
        return;
    
    new 
iBufFloat:fBufFloat:vBuf[3];
    
    new 
iBuf2;
    
    
//PrintToServer("%d%d%d%d%d%d%d%d%d%d%d%d%d", BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf));
    //PrintToServer("%d%d%d%d%d%d%d%d%d%d%d%d%d", BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf));
    //PrintToServer("%d%d%d%d%d%d%d%d%d%d%d%d%d", BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf));
    
    
iBuf2 0;
    for(new 
i=0;i<13;i++)
    {
        
iBuf BfReadBool(bf);
        
iBuf2 = (iBuf2<<1);
        
iBuf2 |= iBuf;
    }
    
iBuf2 = (iBuf2<<19);
    
PrintToServer("%d: x %f", ++idxFloat:fBuf*4.0);
    
    
iBuf2 0;
    for(new 
i=0;i<13;i++)
    {
        
iBuf BfReadBool(bf);
        
iBuf2 = (iBuf2<<1);
        
iBuf2 |= iBuf;
    }
    
iBuf2 = (iBuf2<<19);
    
PrintToServer("%d: y %f", ++idxFloat:iBuf2*4.0);
    
    
iBuf2 0;
    for(new 
i=0;i<13;i++)
    {
        
iBuf BfReadBool(bf);
        
iBuf2 = (iBuf2<<1);
        
iBuf2 |= iBuf;
    }
    
iBuf2 = (iBuf2<<19);
    
PrintToServer("%d: z %f", ++idxFloat:iBuf2*4.0);
    
    
// normalized y angle
    //PrintToServer("%d%d%d%d%d%d%d%d%d", BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf));
    
    
iBuf2 0;
    for(new 
i=0;i<9;i++)
    {
        
iBuf BfReadBool(bf);
        
iBuf2 = (iBuf2<<1);
        
iBuf2 |= iBuf;
    }
    
iBuf2 = (iBuf2<<23);
    
PrintToServer("%d: ang y norm %f", ++idxFloat:iBuf2);
    
    
GetClientAbsOrigin(clientvBuf);
    
PrintToServer("Position: %f %f %f"vBuf[0], vBuf[1], vBuf[2]);
    
    
GetClientAbsAngles(clientvBuf);
    
PrintToServer("Y angle: %f"normalizeAngle(vBuf[1]));
}

stock Float:normalizeAngle(Float:angle)
{
    new 
Float:ret angle;
    while(
ret 360.0 || ret 0.0)
    {
        if(
angle 360.0)
            
ret 360.0 angle;
        else if(
angle 0.0)
            
ret angle 360.0;
    }
    
    return 
ret;

I'm aiming to send my own custom UpdateRadar usermessages to display random points on the radar for all players.
Attached Files
File Type: sp Get Plugin or Get Source (updateradar.sp - 461 views - 3.2 KB)
__________________

Last edited by Peace-Maker; 07-11-2011 at 09:13.
Peace-Maker is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 05-15-2011 , 16:16   Re: UpdateRadar usermessage structure reading/writing
Reply With Quote #2

Looks like the coordinates are rounded 13 bit ints, but it still doesn't return the same values..
__________________
Peace-Maker is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 05-15-2011 , 18:42   Re: UpdateRadar usermessage structure reading/writing
Reply With Quote #3

What were the results when the PrintToServer lines with the individual bits were on instead of the for loops?
__________________
databomb is offline
Sagenth
Member
Join Date: Aug 2010
Old 05-15-2011 , 20:26   Re: UpdateRadar usermessage structure reading/writing
Reply With Quote #4

You are displaying players on each other's radars?
Sagenth is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 05-16-2011 , 18:16   Re: UpdateRadar usermessage structure reading/writing
Reply With Quote #5

Quote:
Originally Posted by Sagenth View Post
You are displaying players on each other's radars?
I'm trying to display some spot where ever i want on the radar. The players are shown anyway

I've managed to parse the UpdateRadar message completely. Don't know if there are more elegant ways to solve this, but it's enough for me

Structure:
1 byte: client index
13 bit in reversed order: playerabsoluteposition x coordinate rounded and divided by 4
13 bit in reversed order: ---"--- y coordinate
13 bit in reversed order: ---"--- z coordinate
9 bit reversed: y playerangle rounded. You need to normalize the angle to get the matching one.

Due to the rounding and dividing by 4 without remainder the values aren't accurate, but enough for the radar it seems.

Next step -> Send own UpdateRadar message :B

PHP Code:
#pragma semicolon 1
#include <sourcemod>

//#define _DEBUG 1

new bool:g_bPrint true;

public 
OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("UpdateRadar"), MsgHook_UpdateRadarfalse);
    
RegConsoleCmd("usrmsg_s"Cmd_Stop);
}

public 
Action:Cmd_Stop(clientargs)
{
    
g_bPrint = !g_bPrint;
    return 
Plugin_Handled;
}

public 
Action:MsgHook_UpdateRadar(UserMsg:msg_idHandle:bf, const players[], playersNumbool:reliablebool:init)
{
    if(!
g_bPrint)
        return;
    
    new 
iLength BfGetNumBytesLeft(bf);
    
PrintToServer("Message length: %d."iLength);
    
    if(
iLength <= 1)
        return;
    
    new 
iBuf;
    new 
idx 0;
    while(
BfGetNumBytesLeft(bf) > 0)
    {
        
// Player index
        
iBuf BfReadByte(bf);
        
PrintToServer("%d: %N (%d)", ++idxiBufiBuf);
        
        
PrintClientInfo(bfidxiBuf);
        
        
iBuf BfReadByte(bf);
        if(
iBuf 0)
        {
            
PrintToServer("%d: %N (%d)", ++idxiBufiBuf);
            
PrintClientInfo(bfidxiBuf);
        }
        else
            
PrintToServer("%d: %d", ++idxiBuf);
    }
}

PrintClientInfo(Handle:bf, &idxclient)
{
    if(
client == 0)
        return;
    
    new 
Float:vBuf[3];
#if defined _DEBUG
    
new String:sBuf[20];
#endif
    
    //PrintToServer("%d%d%d%d%d%d%d%d%d%d%d%d%d", BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf));
    //PrintToServer("%d%d%d%d%d%d%d%d%d%d%d%d%d", BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf));
    //PrintToServer("%d%d%d%d%d%d%d%d%d%d%d%d%d", BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf));
    
    
new iBuf 0;
    new 
aBuf[13];
    for(new 
i=0;i<13;i++)
    {
        
aBuf[i] = BfReadBool(bf);
    }
    
    if(
aBuf[12] == 1)
        
iBuf = -1;
    
    for(new 
i=12;i>=0;i--)
    {
        
#if defined _DEBUG
        
Format(sBufsizeof(sBuf), "%s%d"sBufaBuf[i]);
        
#endif
        
iBuf = (iBuf<<1);
        
iBuf |= aBuf[i];
    }
    
    
#if defined _DEBUG
    
PrintToServer("Input: %s"sBuf);
    
PrintToServer("%b = %d"iBufiBuf);
    
#endif
    
PrintToServer("%d: x %d", ++idxiBuf*4);
    
    
iBuf 0;
    
#if defined _DEBUG
    
Format(sBufsizeof(sBuf), "");
    
#endif
    
for(new i=0;i<13;i++)
    {
        
aBuf[i] = BfReadBool(bf);
    }
    
    
// first bit 1? that's a negative number.
    
if(aBuf[12] == 1)
        
iBuf = -1;
    
    for(new 
i=12;i>=0;i--)
    {
        
#if defined _DEBUG
        
Format(sBufsizeof(sBuf), "%s%d"sBufaBuf[i]);
        
#endif
        
iBuf = (iBuf<<1);
        
iBuf |= aBuf[i];
    }
    
    
#if defined _DEBUG
    
PrintToServer("Input: %s"sBuf);
    
PrintToServer("%b = %d"iBufiBuf);
    
#endif
    
PrintToServer("%d: y %d", ++idxiBuf*4);
    
    
iBuf 0;
    
#if defined _DEBUG
    
Format(sBufsizeof(sBuf), "");
    
#endif
    
for(new i=0;i<13;i++)
    {
        
aBuf[i] = BfReadBool(bf);
    }
    
    if(
aBuf[12] == 1)
        
iBuf = -1;
    
    for(new 
i=12;i>=0;i--)
    {
        
#if defined _DEBUG
        
Format(sBufsizeof(sBuf), "%s%d"sBufaBuf[i]);
        
#endif
        
iBuf = (iBuf<<1);
        
iBuf |= aBuf[i];
    }
    
    
#if defined _DEBUG
    
PrintToServer("Input: %s"sBuf);
    
PrintToServer("%b = %d"iBufiBuf);
    
#endif
    
PrintToServer("%d: z %d", ++idxiBuf*4);
    
    
// normalized y angle
    //PrintToServer("%d%d%d%d%d%d%d%d%d", BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf), BfReadBool(bf));
    
    
iBuf 0;
    
#if defined _DEBUG
    
Format(sBufsizeof(sBuf), "");
    
#endif
    
for(new i=0;i<9;i++)
    {
        
aBuf[i] = BfReadBool(bf);
    }
    
    for(new 
i=8;i>=0;i--)
    {
        
#if defined _DEBUG
        
Format(sBufsizeof(sBuf), "%s%d"sBufaBuf[i]);
        
#endif
        
iBuf = (iBuf<<1);
        
iBuf |= aBuf[i];
    }
    
    
#if defined _DEBUG
    
PrintToServer("Input: %s"sBuf);
    
PrintToServer("%b = %d"iBufiBuf);
    
PrintToServer("%d: ang y %d", ++idxiBuf);
    
#endif
    
PrintToServer("%d: ang y norm %f", ++idxnormalizeAngle(float(iBuf)));
    
    
GetClientAbsOrigin(clientvBuf);
    
PrintToServer("Position: %f %f %f"vBuf[0], vBuf[1], vBuf[2]);
    
    
GetClientAbsAngles(clientvBuf);
    
PrintToServer("Y angle: %f"normalizeAngle(vBuf[1]));
}

stock Float:normalizeAngle(Float:angle)
{
    while(
angle 360.0 || angle 0.0)
    {
        if(
angle 360.0)
            
angle 360.0 angle;
        else if(
angle 0.0)
            
angle angle 360.0;
    }
    
    return 
angle;

Code:
Message length: 8.
1: Xavier (3)
2: x 376
3: y 216
4: z 8
5: ang y norm 169.000000
Position: 379.909454 216.196884 8.651735
Y angle: 169.383392
6: 0
Message length: 15.
1: Steve (1)
2: x -272
3: y 2088
4: z -124
5: ang y norm 319.000000
Position: -274.753204 2088.041015 -127.497108
Y angle: 248.123626
6: Xavier (3)
7: x 328
8: y 224
9: z 4
10: ang y norm 169.000000
Position: 328.383941 224.777191 5.466873
Y angle: 169.959716
11: Console (0)
12: 0
Message length: 15.
1: Steve (1)
2: x -276
3: y 2088
4: z -124
5: ang y norm 319.000000
Position: -278.498260 2088.379882 -127.466316
Y angle: 248.578903
6: Xavier (3)
7: x 320
8: y 224
9: z 4
10: ang y norm 170.000000
Position: 321.521057 225.957290 5.092897
Y angle: 170.175720
11: Console (0)
12: 0
Attached Files
File Type: sp Get Plugin or Get Source (updateradar.sp - 449 views - 4.5 KB)
__________________
Peace-Maker is offline
Sagenth
Member
Join Date: Aug 2010
Old 05-16-2011 , 19:53   Re: UpdateRadar usermessage structure reading/writing
Reply With Quote #6

Light spots on the radar up as if they were players? Sorry I am just trying to understand. If it is actually possible to manipulate the radar in the way i think you are, it gives me an idea.
Sagenth is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 05-17-2011 , 08:06   Re: UpdateRadar usermessage structure reading/writing
Reply With Quote #7

I'm currently only parsing the usermessage locally. I'm not sending custom ones yet, so don't know if it will work with showing own points like players.
__________________
Peace-Maker is offline
klausenbusk
AlliedModders Donor
Join Date: Jan 2011
Old 07-03-2011 , 09:37   Re: UpdateRadar usermessage structure reading/writing
Reply With Quote #8

Some update on this?
klausenbusk is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-11-2011 , 09:07   Re: UpdateRadar usermessage structure reading/writing
Reply With Quote #9

I was unable to get the points show up ingame.

It's possible to send your own UpdateRadar messages, but they are discarded by the client.

I've tried sending them for unused player slots > MaxClients and setting m_bAlive, m_iTeam, m_bConnected, m_bPlayerSpotted for that indexes, but all i got were some ghosts showing up in a team on the scoreboard :/

Also using dead players indexes to show points had no effects.

Looks like it's not possible to show custom points on the radar using the UpdateRadar message.

PHP Code:
/**
 * Sends UpdateRadar usermessage
 *
 * @param sendToClients    An array of clients to send the message to.
 * @param numClients    Number of players in the array.
 * @param points        multidimensional array of points to show. points[] = {fOrigin[0], fOrigin[1], fOrigin[2], fAngles[1]}
 * @param numPoints        Number of different points in array.
 * @noreturn
 */
stock SendUpdateRadarUsrMsg(sendToClients[], numClientsFloat:points[][4], numPoints)
{
    if(
numClients == 0)
        return;
    
    new 
Handle:hBf StartMessage("UpdateRadar"sendToClientsnumClients);
    
    
// start our dummy client index at the first unused index
    
new client MaxClients+1;
    
    new 
iOrigin[3], iBufiBytes[13];
    new 
iAngleY;
    for(new 
i=0;i<numPoints;i++)
    {
        
// Can't do more players than there are slots (65)
        
if(client MAXPLAYERS+1)
            break;
        
        
// First write the client
        
BfWriteByte(hBfclient);
        
        
// Round and divide by 4 
        
iOrigin[0] = RoundToNearest(points[i][0]);
        
iOrigin[1] = RoundToNearest(points[i][1]);
        
iOrigin[2] = RoundToNearest(points[i][2]);
        
iOrigin[0] = iOrigin[0] / 4;
        
iOrigin[1] = iOrigin[1] / 4;
        
iOrigin[2] = iOrigin[2] / 4;
        
        
// Normalize the angle and round
        
points[i][3] = normalizeAngle(points[i][3]);
        
iAngleY RoundToNearest(points[i][3]);
        
        
// Reverse the bits and write them into the bitsteam
        
iBuf 0;
        
// Prepare the 3 origin coordiantes
        
for(new c=0;c<3;c++)
        {
            
iBuf 1;
            
// Write the first 13 bits into the stream in reversed order
            
for(new b=0;b<13;b++)
            {
                
iBytes[b] = (iBuf iOrigin[c]?1:0);
                
iBuf = (iBuf<<1);
                
BfWriteBool(hBf, (iBytes[b]==1?true:false));
            }
        }
        
        
iBuf 1;
        
// Write the first 9 bits into the stream in reversed order
        
for(new b=0;b<9;b++)
        {
            
iBytes[b] = (iBuf iAngleY?1:0);
            
iBuf = (iBuf<<1);
            
BfWriteBool(hBf, (iBytes[b]==1?true:false));
        }
        
        
// Increase the dummy clientindex
        
client++;
    }
    
    
// Write he end byte of 0
    
BfWriteByte(hBf0);
    
    
// Send the message
    
EndMessage();
}

stock Float:normalizeAngle(Float:angle)
{
    while(
angle 360.0 || angle 0.0)
    {
        if(
angle 360.0)
            
angle 360.0 angle;
        else if(
angle 0.0)
            
angle angle 360.0;
    }
    
    return 
angle;

Edit: Thinking of it. Maybe setting m_iHostageY, m_iHostageX, m_iHostageZ on CCSPlayerResource to the point we want and switching m_bHostageAlive on and off continuely would create those yellow crosses on the radar where we want them?
Attached Files
File Type: sp Get Plugin or Get Source (updateradarsend.sp - 368 views - 4.8 KB)
__________________

Last edited by Peace-Maker; 07-11-2011 at 09:10.
Peace-Maker is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 12-05-2011 , 10:44   Re: [Solved] UpdateRadar usermessage structure reading/writing
Reply With Quote #10

Thanks for the research you've done. I've been messing around with this UserMessage and have a few more details.

Here are some useful stocks based on your code. They could easily be made into natives since the real functions are in the SDK.
PHP Code:
stock BfWriteSBitLong(Handle:bfdatanumBits)
{
    
decl bool:bit;
    
    for (new 
0numBitsi++)
    {
        
bit = !!(data & (<< i));
        
BfWriteBool(bfbit);
    }
}

stock BfReadSBitLong(Handle:bfnumBits)
{
    
decl bool:bits[numBits], reti;
    
    for (
0numBitsi++)
    {
        
bits[i] = BfReadBool(bf);
    }
    
    
ret bits[numBits-1] ? -0;
    
    for (
numBits-1>= 0i--)
    {
        
ret <<= 1;
        
ret |= bits[i];
    }
    
    return 
ret;

Usage example:
PHP Code:
// Reading
decl clientiOrigin[3], iAngle;

client BfReadByte(bf);
iOrigin[0] = BfReadSBitLong(bf13) * 4;
iOrigin[1] = BfReadSBitLong(bf13) * 4;
iOrigin[2] = BfReadSBitLong(bf13) * 4;
iAngle BfReadSBitLong(bf9);

// Writing
decl Float:vOrigin[3], Float:vAngles[3];

GetClientAbsOrigin(clientvOrigin);
GetClientAbsAngles(clientvAngles);

BfWriteByte(bfclient);
BfWriteSBitLong(bfRoundToNearest(vOrigin[0] / 4.0), 13);
BfWriteSBitLong(bfRoundToNearest(vOrigin[1] / 4.0), 13);
BfWriteSBitLong(bfRoundToNearest(vOrigin[2] / 4.0), 13);
BfWriteSBitLong(bfRoundToNearest(vAngles[1]), 9); 
Quote:
Originally Posted by Peace-Maker View Post
I was unable to get the points show up ingame.

It's possible to send your own UpdateRadar messages, but they are discarded by the client.
That's because the radar is done half server-side, half client-side. A few conditions apply:

- If a player comes within transmitting distance of the client, then the client will manage the radar point for that player and ignore what the server tells it.
- The client will only show a point on the radar for a player that is InGame (and alive?).
- The client will only show one point per client index, and never one for itself.
- Sending a second radar point for the same client index will overwrite the previous one.

In theory you could create your own points by spawning a FakeClient far away and sending your own radar data. You would also have to set CCSPlayerResource::m_bPlayerSpotted to true for that index.
__________________

Last edited by GoD-Tony; 12-05-2011 at 11:03.
GoD-Tony is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode