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

SetConVarString Crashing Server?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
QOOOOOOOOQ
Senior Member
Join Date: Dec 2012
Old 11-27-2014 , 03:47   SetConVarString Crashing Server?
Reply With Quote #1

PHP Code:
public Action:EC_Command_LockConvar(iClientiArgs)
{
    
/*
     *    Get all the command information in one lump sum, along with making sure the command was given correct params.
     */
    
decl String:sConVarActions[8];
    
GetCmdArg(1sConVarActionssizeof(sConVarActions));
    
decl String:sConVar[32];
    
GetCmdArg(2sConVarsizeof(sConVar));
    
decl String:sValue[32];
    
GetCmdArg(3sValuesizeof(sValue));

    
/*
     *    Make sure the command is actually valid before commiting to any actions hereafter.
     */
    
new Handle:hConVar FindConVar(sConVar);
    if(
hConVar == INVALID_HANDLE)
        return 
Plugin_Handled;

    
/*
     *    We must first check if the convar is already in the trie before we possibly add multiple HookConVarChange
     *        functions in a row (todo).
     */
    
HookConVarChange(hConVarEC_ConVarChanged_GenericConVar);

    if(
IsClientAndInGame(iClient)) Client_PrintToConsole(iClient"[SC] The convar '%s' is now hooked."sConVar);
}

public 
EC_ConVarChanged_GenericConVar(Handle:hConvar, const String:sOldValue[], const String:sNewValue[])
{
    
/*
     *    No need for checks, sOldValue and sNewValue are guaranteed to be different.
     */
    
SetConVarString(hConvarsOldValue);


No errors logged within SourceMod logs, so I can only assume this is what is causing it. It 'hooks' fine, but when I use sm_cvar to change the command, server instantly goes down if it's 'hooked'.
QOOOOOOOOQ is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 11-27-2014 , 03:56   Re: SetConVarString Crashing Server?
Reply With Quote #2

  1. cvar is set to "butts"
  2. cvar gets hooked
  3. someone sets it to "lolno"
  4. the hook causes it to be set to it's old value, "butts"
  5. the cvar has been changed, to "butts". the hook causes it to be reset to its old value of "lolno"
  6. the cvar has been changed, to "lolno". the hook causes it to be reset to its old value of "butts"
  7. the cvar has been changed, to "butts". the hook causes it to be reset to its old value of "lolno"
  8. repeat this infinite loop over and over
__________________

Last edited by ddhoward; 11-27-2014 at 04:27.
ddhoward is offline
QOOOOOOOOQ
Senior Member
Join Date: Dec 2012
Old 11-27-2014 , 04:53   Re: SetConVarString Crashing Server?
Reply With Quote #3

Damn, completely forgot about that, looks like I'll have to look up the trie value string for the convar, then check for consistency before I alter the convar then. Thanks. (Storing the convar value when it's 'locked' and placing into a trie should prove efficient, I think.)

Last edited by QOOOOOOOOQ; 11-27-2014 at 04:54.
QOOOOOOOOQ is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 11-27-2014 , 08:04   Re: SetConVarString Crashing Server?
Reply With Quote #4

damn those lolnoes and butts
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 11-27-2014 , 14:55   Re: SetConVarString Crashing Server?
Reply With Quote #5

Quote:
Originally Posted by QOOOOOOOOQ View Post
Damn, completely forgot about that, looks like I'll have to look up the trie value string for the convar, then check for consistency before I alter the convar then. Thanks. (Storing the convar value when it's 'locked' and placing into a trie should prove efficient, I think.)
Welcome to the wonders of a single-threaded execution environment.
Code:
public EC_ConVarChanged_GenericConVar(Handle:hConvar, const String:sOldValue[], const String:sNewValue[])
{
    static bool:inHook = false;
    if (inHook) return;
    inHook = true;
    SetConVarString(hConvar, sOldValue);
    inHook = false;
}
__________________
asherkin 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 15:33.


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