Raised This Month: $319 Target: $400
 79%   Almost there!

[CS:GO] Getting data from the netprop "m_szCrosshairCodes"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 10-01-2020 , 13:32   [CS:GO] Getting data from the netprop "m_szCrosshairCodes"
Reply With Quote #1

I don't know what I'm doing wrong here but when I dump the netprops it says that "m_szCrosshairCodes" is a string but when I try to get it through sourcemod it doesn't work.

PHP Code:
char szCrosshair[64];
    
GetEntPropString(GetPlayerResourceEntity(), Prop_Send"m_szCrosshairCodes"szCrosshairsizeof(szCrosshair), client);

PrintToServer("Crosshair Code: %s"szCrosshair); 
This is the error that happens:
Code:
L 10/01/2020 - 18:28:23: [SM] Exception reported: SendProp m_szCrosshairCodes is not a string (6 != 4)
L 10/01/2020 - 18:28:23: [SM] Blaming: bot_stuff.smx
L 10/01/2020 - 18:28:23: [SM] Call stack trace:
L 10/01/2020 - 18:28:23: [SM]   [0] GetEntPropString
L 10/01/2020 - 18:28:23: [SM]   [1] Line 6317, bot_stuff.sp::OnPlayerRunCmd
What exactly am I doing wrong here?
__________________
manicogaming is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-01-2020 , 17:21   Re: [CS:GO] Getting data from the netprop "m_szCrosshairCodes"
Reply With Quote #2

PHP Code:
#include <sdktools>


char CrosshairCode[MAXPLAYERS+1][MAX_NAME_LENGTH];

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_test"test);
}

public 
Action test(int clientint args)
{
    for(
int x 1<= MaxClientsx++)
    {
        if(!
IsClientInGame(x) || IsFakeClient(x)) continue;
        
        
PrintToChat(client"%N CrosshairCode %s"xCrosshairCode[x]);
    }
    return 
Plugin_Handled;
}


public 
void OnClientCommandKeyValues_Post(int clientKeyValues kv)
{
    
char buffer[100];
    if(!
kv.GetSectionName(buffersizeof(buffer))) return;

    if(!
StrEqual(buffer"CrosshairCode"false)) return;

    
kv.GetString("code"CrosshairCode[client], sizeof(CrosshairCode[]), "");

    
PrintToChatAll("%N CrosshairCode %s"clientCrosshairCode[client]);
}

/*
"CrosshairCode"
{
        "code"          "CSGO-m9FPN-ZHep5-OUAV7-qMUyG-xJ8nM"
}
*/ 
__________________
Do not Private Message @me
Bacardi is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 10-01-2020 , 17:49   Re: [CS:GO] Getting data from the netprop "m_szCrosshairCodes"
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
PHP Code:
#include <sdktools>


char CrosshairCode[MAXPLAYERS+1][MAX_NAME_LENGTH];

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_test"test);
}

public 
Action test(int clientint args)
{
    for(
int x 1<= MaxClientsx++)
    {
        if(!
IsClientInGame(x) || IsFakeClient(x)) continue;
        
        
PrintToChat(client"%N CrosshairCode %s"xCrosshairCode[x]);
    }
    return 
Plugin_Handled;
}


public 
void OnClientCommandKeyValues_Post(int clientKeyValues kv)
{
    
char buffer[100];
    if(!
kv.GetSectionName(buffersizeof(buffer))) return;

    if(!
StrEqual(buffer"CrosshairCode"false)) return;

    
kv.GetString("code"CrosshairCode[client], sizeof(CrosshairCode[]), "");

    
PrintToChatAll("%N CrosshairCode %s"clientCrosshairCode[client]);
}

/*
"CrosshairCode"
{
        "code"          "CSGO-m9FPN-ZHep5-OUAV7-qMUyG-xJ8nM"
}
*/ 
So the "m_szCrosshairCodes" netprop doesn't work? Also this way if I want to change a crosshair code instead of doing kv.GetString I can do kv.SetString right?
__________________
manicogaming is offline
psychonic

BAFFLED
Join Date: May 2008
Old 10-23-2020 , 01:06   Re: [CS:GO] Getting data from the netprop "m_szCrosshairCodes"
Reply With Quote #4

Quote:
Originally Posted by manicogaming View Post
What exactly am I doing wrong here?
Nothing. It's a bug. I've posted a fix here, https://github.com/alliedmodders/sourcemod/pull/1372

Quote:
Originally Posted by manicogaming View Post
So the "m_szCrosshairCodes" netprop doesn't work? Also this way if I want to change a crosshair code instead of doing kv.GetString I can do kv.SetString right?
That should work, or you can also manually call ClientCommandKeyValues to simulate a player sending it with the value you want.
psychonic is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 01-14-2021 , 02:46   Re: [CS:GO] Getting data from the netprop "m_szCrosshairCodes"
Reply With Quote #5

Since there's currently a bug with setting the crosshair netprop, what other way is there to change the crosshair code (for bots in this case)?
__________________
manicogaming is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-16-2021 , 07:19   Re: [CS:GO] Getting data from the netprop "m_szCrosshairCodes"
Reply With Quote #6

Did you try FakeClientCommandKeyValues?
__________________
asherkin is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 01-16-2021 , 09:14   Re: [CS:GO] Getting data from the netprop "m_szCrosshairCodes"
Reply With Quote #7

Quote:
Originally Posted by asherkin View Post
Did you try FakeClientCommandKeyValues?
I don't think I'm setting up the KeyValues for the FakeClientCommandKeyValues correctly.
__________________
manicogaming is offline
Reply


Thread Tools
Display Modes

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 17:43.


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