GetConsoleVarAsString float Server Crash
#1

So, I created this thread in the Scripting Help forums. I'll post the contents of my first post again:
Quote:
Originally Posted by Freaksken
View Post
So I wanted the get the stream_distance set in server.cfg, which is a float value.
Since there is no GetConsoleVarAsFloat function, I've tried the approach found in this thread: click.
Code:
stock Float:GetConsoleVarAsFloat(var[]) {
     new string[30];
     GetConsoleVarAsString(var, string, sizeof(string)); //Crash happens here
     return floatstr(string);
}
But whenever I execute GetConsoleVarAsFloat("stream_distance"); the server crashes immediately.
GetConsoleVarAsInt and GetConsoleVarAsBool don't return the correct value obviously.
I have this line in my server.cfg file:
Code:
stream_distance 300.0
Does anyone know a solution?
Misiur replied this:
Quote:
Originally Posted by Misiur
View Post
You've found a bug: using GetConsoleVarAsString on anything other than string (integers, floats), causes segfault. Please report it, and nice find!
So, here I am reporting the problem.

EDIT:
See also this post in the Useful Functions thread.

EDIT 2:
The server also crashes if a nonexistent console variable is used.
I've updated the wiki page to show that this is a known bug.
Reply


Messages In This Thread
GetConsoleVarAsString float Server Crash - by Freaksken - 29.07.2016, 20:18
Re: GetConsoleVarAsString float Server Crash - by jlalt - 04.08.2016, 09:22
Re: GetConsoleVarAsString float Server Crash - by Freaksken - 06.08.2016, 20:49
Re: GetConsoleVarAsString float Server Crash - by LolerotehC - 14.08.2016, 03:36
Re: GetConsoleVarAsString float Server Crash - by Sew_Sumi - 17.08.2016, 04:10

Forum Jump:


Users browsing this thread: 1 Guest(s)