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

Solved Wrong convar.IntValue with AutoExecConfig


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 02-12-2017 , 21:37   Wrong convar.IntValue with AutoExecConfig
Reply With Quote #1

solved: https://forums.alliedmods.net/showpo...8&postcount=17

TL;DR When using AutoExecConfig the IntValue of a Integer-ConVar with 8 digits returns a wrong value. (7 digits are ok)

I use two plugins for my testing. The first return the correct value without using AutoExecConfig
PHP Code:
ConVar gc_iTest1;
ConVar gc_iTest2;
ConVar gc_iTest3;
ConVar gc_iTest4;

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

    
gc_iTest1 CreateConVar("sm_test1""27803359""ID");
    
gc_iTest2 CreateConVar("sm_test2""26552625""ID");
    
gc_iTest3 CreateConVar("sm_test3""54901310""ID");
    
gc_iTest4 CreateConVar("sm_test4""69529540""ID");
}

public 
Action Command_Test(int clientint args)
{
    
ReplyToCommand(client"%i"gc_iTest1.IntValue);
    
ReplyToCommand(client"%i"gc_iTest2.IntValue);
    
ReplyToCommand(client"%i"gc_iTest3.IntValue);
    
ReplyToCommand(client"%i"gc_iTest4.IntValue);

This return:
Code:
sm_itest
27803359
26552625
54901310
69529540
The second plugin using AutoExecConfig return a wrong value
PHP Code:
ConVar gc_iTest1;
ConVar gc_iTest2;
ConVar gc_iTest3;
ConVar gc_iTest4;

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

    
AutoExecConfig(true"test2"//only extra line on this plugin
    
gc_iTest1 CreateConVar("sm_2test1""27803359""ID");
    
gc_iTest2 CreateConVar("sm_2test2""26552625""ID");
    
gc_iTest3 CreateConVar("sm_2test3""54901310""ID");
    
gc_iTest4 CreateConVar("sm_2test4""69529540""ID");
}

public 
Action Command_Test(int clientint args)
{
    
ReplyToCommand(client"%i"gc_iTest1.IntValue);
    
ReplyToCommand(client"%i"gc_iTest2.IntValue);
    
ReplyToCommand(client"%i"gc_iTest3.IntValue);
    
ReplyToCommand(client"%i"gc_iTest4.IntValue);

return:
Code:
sm_itest2
27803360
26552624
54901312
69529536
This only happens when the ConVars contains 8 digits, when it has only 7 digits the return is correct.

Also when I type a ConVar of the second plugin e.g. "sm_2test1" in console, it return the correct value "27803359".

I tested both with latest sm1.8 & sm1.9.
Do you have any idea?
__________________
coding & free software

Last edited by shanapu; 02-13-2017 at 22:17. Reason: typo
shanapu is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 02-12-2017 , 21:56   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #2

i think i had same problem before when trying to get steamid64 from KV
if i store SteamID64 in KV and try to retrive it i always get wrong result
but when i store AuthId_Steam2 in KV and retrive it its fine...
8guawong is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 02-12-2017 , 22:40   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #3

Not a solution...

Dynamic would work using KeyValues.
__________________
Neuro Toxin is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-12-2017 , 22:49   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #4

This is pretty interesting.
Also on the keyvalue question, you store it as a string and retrieve it as a string and it's still wrong?
Mitchell is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 02-13-2017 , 01:40   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #5

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.
Fyren is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 02-13-2017 , 03:00   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #6

Wouldn't SM store these numbers as int as their is no .xxxx?
__________________
Neuro Toxin is offline
psychonic

BAFFLED
Join Date: May 2008
Old 02-13-2017 , 08:07   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #7

@shanapu, what game is this on? The ConVar value handling is not directly in SM, but instead in tier1 from the SDK.
psychonic is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 02-13-2017 , 09:27   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #8

snippet from my plugin
if i use my steamid64 in kv will get the wrong result

PHP Code:
public OnPluginStart()
{    
    new 
String:logPath[PLATFORM_MAX_PATH], String:steamid[64];
    
BuildPath(Path_SMlogPathPLATFORM_MAX_PATH"/logs/nominated_map.txt");
    
decl String:map_name[64];
    
GetCurrentMap(map_namesizeof(map_name));
    new 
Handle:kv CreateKeyValues("MapWon");
    if (!
FileToKeyValues(kvlogPath))
        return;
    if (!
KvJumpToKey(kvmap_name))
        return;
    
KvGetString(kv"steamid"steamidsizeof(steamid));
    
PrintToServer(steamid);
    
CloseHandle(kv);

example kv

Code:
"MapWon"
{
	"ze_Halloween_House_b4"
	{
		"steamid"		"76561197993901726"
	}
}
Result
Code:
2147483647
sm 1.8.0.5963
mm 1.10.6
windows

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

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

Quote:
Originally Posted by 8guawong View Post
sm 1.8.0.5963
mm 1.10.6
windows
Again, what game? The ConVar code isn't all tied directly to SM, but is instead in the per-engine SDKs.
psychonic is offline
Caaine
Member
Join Date: Oct 2013
Old 02-13-2017 , 10:27   Re: Wrong convar.IntValue with AutoExecConfig
Reply With Quote #10

The Game is CSGO
Caaine 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 08:31.


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