Raised This Month: $32 Target: $400
 8% 

Solved Wrong convar.IntValue with AutoExecConfig


Post New Thread Reply   
 
Thread Tools Display Modes
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 02-13-2017 , 10:27   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #11

sorry csgo
8guawong is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 02-13-2017 , 11:32   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #12

Quote:
Originally Posted by Fyren View Post
Can you post the content of the config file SM created?

I don't know if the bug is SM's fault or not since I haven't looked into it, but what seems to be happening is 69529540 can't be represented by a float. The closest a float can hold is 69529536.
Spoiler


Quote:
Originally Posted by psychonic View Post
@shanapu, what game is this on? The ConVar value handling is not directly in SM, but instead in tier1 from the SDK.
I tested/get this bug on csgo & tf2.
__________________
coding & free software
shanapu is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 02-13-2017 , 13:36   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #13

Iv dealt with this before.. just use smaller values, it isnt very hard.
Why would you need a cvar that large?
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
psychonic

BAFFLED
Join Date: May 2008
Old 02-13-2017 , 15:55   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #14

Fyren is correct that it's occurring because it's using the float value as an int. While this could technically be fixed for SM, it would mean that SM would be treating convars differently than the game does. The best workaround for larger numbers like that would be to read as string and then convert to int.

CS:GO does internally use a double instead of a float to gain a little more precision, and we could/should mirror that for CS:GO. It would probably fix the issue there, but the cross-game solution is still to use the string and convert on your own.

Last edited by psychonic; 02-13-2017 at 15:57.
psychonic is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 02-13-2017 , 19:21   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #15

Quote:
Originally Posted by psychonic View Post
Fyren is correct that it's occurring because it's using the float value as an int. While this could technically be fixed for SM, it would mean that SM would be treating convars differently than the game does. The best workaround for larger numbers like that would be to read as string and then convert to int.

CS:GO does internally use a double instead of a float to gain a little more precision, and we could/should mirror that for CS:GO. It would probably fix the issue there, but the cross-game solution is still to use the string and convert on your own.
but my problem isn't related to convar
or was
Quote:
CS:GO does internally use a double instead of a float to gain a little more precision, and we could/should mirror that for CS:GO. It would probably fix the issue there, but the cross-game solution is still to use the string and convert on your own
meant for me?

but i'm already using string

Last edited by 8guawong; 02-13-2017 at 19:22.
8guawong is offline
psychonic

BAFFLED
Join Date: May 2008
Old 02-13-2017 , 20:22   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #16

Quote:
Originally Posted by 8guawong View Post
but my problem isn't related to convar
or was
meant for me?

but i'm already using string
The thread started about convar values. Any issue with KVs is unrelated.
psychonic is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 02-13-2017 , 22:03   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #17

Quote:
Originally Posted by friagram View Post
Iv dealt with this before.. just use smaller values, it isnt very hard.
Why would you need a cvar that large?
at least the first two numbers are steam group IDs to use with SteamWorks. So smaller values won't work.

Quote:
Originally Posted by psychonic View Post
Fyren is correct that it's occurring because it's using the float value as an int. While this could technically be fixed for SM, it would mean that SM would be treating convars differently than the game does. The best workaround for larger numbers like that would be to read as string and then convert to int.

CS:GO does internally use a double instead of a float to gain a little more precision, and we could/should mirror that for CS:GO. It would probably fix the issue there, but the cross-game solution is still to use the string and convert on your own.
ok, the workaround with stringtoint works! Much Thanks!

PHP Code:
ConVar gc_sTest1;
ConVar gc_sTest2;
ConVar gc_sTest3;
ConVar gc_sTest4;

char g_sTest1[12];
char g_sTest2[12];
char g_sTest3[12];
char g_sTest4[12];

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_itest2"Command_Test)

    
AutoExecConfig(true"test2");
    
gc_sTest1 CreateConVar("sm_2test1""27803359""ID");
    
gc_sTest2 CreateConVar("sm_2test2""26552625""ID");
    
gc_sTest3 CreateConVar("sm_2test3""54901310""ID");
    
gc_sTest4 CreateConVar("sm_2test4""69529540""ID");

    
gc_sTest1.GetString(g_sTest1sizeof(g_sTest1));
    
gc_sTest2.GetString(g_sTest2sizeof(g_sTest2));
    
gc_sTest3.GetString(g_sTest3sizeof(g_sTest3));
    
gc_sTest4.GetString(g_sTest4sizeof(g_sTest4));
}

public 
Action Command_Test(int clientint args)
{
    
ReplyToCommand(client"%i"StringToInt(g_sTest1));
    
ReplyToCommand(client"%i"StringToInt(g_sTest2));
    
ReplyToCommand(client"%i"StringToInt(g_sTest3));
    
ReplyToCommand(client"%i"StringToInt(g_sTest4));

correct value!
__________________
coding & free software
shanapu 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 22:23.


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