Raised This Month: $ Target: $400
 0% 

StripAndChangeServerConVarBool?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
high6
Member
Join Date: Feb 2009
Old 02-02-2009 , 05:40   StripAndChangeServerConVarBool?
Reply With Quote #1

I noticed All4Dead uses this command, but where is it documented? I didn't see it on google or in http://docs.sourcemod.net/api/
high6 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-02-2009 , 11:14   Re: StripAndChangeServerConVarBool?
Reply With Quote #2

It isn't documented because it's a local function in All4dead plugin:

Code:
/* Strip and change a ConVar to the value specified */
StripAndChangeServerConVarBool(String:command[], bool:value) {
    new flags = GetCommandFlags(command);
    SetCommandFlags(command, flags & ~FCVAR_CHEAT);
    SetConVarBool(FindConVar(command), value, false, false);
    SetCommandFlags(command, flags);
}
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
high6
Member
Join Date: Feb 2009
Old 02-02-2009 , 14:00   Re: StripAndChangeServerConVarBool?
Reply With Quote #3

O okay, I didn't see it in there, thanks.
high6 is offline
high6
Member
Join Date: Feb 2009
Old 02-02-2009 , 15:20   Re: StripAndChangeServerConVarBool?
Reply With Quote #4

quick question, can you get around sv_cheats to set convars? I tried the following but it doesn't work.

Code:
public CServerCommand(String:args[])
{
    decl String:arg[255];
    GetCmdArg(1, arg, 255);
    new handle = FindConVar(arg);
    if (handle != INVALID_HANDLE)
    {
        new flags = GetConVarFlags(handle);
        SetConVarFlags(handle, flags & ~FCVAR_CHEAT);
        ServerCommand("%s",args);
        SetConVarFlags(handle, flags);
    }
}
high6 is offline
grandwazir
Senior Member
Join Date: Jan 2009
Old 02-02-2009 , 16:25   Re: StripAndChangeServerConVarBool?
Reply With Quote #5

Quote:
quick question, can you get around sv_cheats to set convars? I tried the following but it doesn't work.
Yeah you can and it is exactly what my function in All4Dead does. Step by step what it does is:
  1. Gets the current command flags required to run the specified command and save them.
  2. Sets the command flags so they are exactly the same only do not require FCVAR_CHEAT anymore.
  3. Change whatever you need to do.
  4. Set the command flags back to what they were before.
It is basically the same as what is on the wiki here although the example there uses GetConVarFlags and SetConVarFlags instead of GetCommandFlags and SetCommandFlags.

Where is your command falling down? You can check your sourcemod logs to find out what bit it is getting stuck on.

Last edited by grandwazir; 02-02-2009 at 16:28.
grandwazir is offline
high6
Member
Join Date: Feb 2009
Old 02-02-2009 , 16:36   Re: StripAndChangeServerConVarBool?
Reply With Quote #6

Quote:
Originally Posted by grandwazir View Post
Yeah you can and it is exactly what my function in All4Dead does. Step by step what it does is:
  1. Gets the current command flags required to run the specified command and save them.
  2. Sets the command flags so they are exactly the same only do not require FCVAR_CHEAT anymore.
  3. Change whatever you need to do.
  4. Set the command flags back to what they were before.
It is basically the same as what is on the wiki here although the example there uses GetConVarFlags and SetConVarFlags instead of GetCommandFlags and SetCommandFlags.

Where is your command falling down? You can check your sourcemod logs to find out what bit it is getting stuck on.
When I pass, for example, "z_speed 1000" it just says that sv_cheats needs to be enabled.
high6 is offline
grandwazir
Senior Member
Join Date: Jan 2009
Old 02-02-2009 , 16:50   Re: StripAndChangeServerConVarBool?
Reply With Quote #7

I'm out of my knowledge area here but I think z_speed is a ConVar not a command. Have you tried using SetConVarInt instead of ServerCommand?
grandwazir is offline
high6
Member
Join Date: Feb 2009
Old 02-03-2009 , 06:32   Re: StripAndChangeServerConVarBool?
Reply With Quote #8

Quote:
Originally Posted by grandwazir View Post
I'm out of my knowledge area here but I think z_speed is a ConVar not a command. Have you tried using SetConVarInt instead of ServerCommand?
I doubt it is that because it gives the warning that sv_cheats is disabled.
high6 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-03-2009 , 06:40   Re: StripAndChangeServerConVarBool?
Reply With Quote #9

Quote:
Originally Posted by high6 View Post
I doubt it is that because it gives the warning that sv_cheats is disabled.
And who says that ConVar's can't have a cheat flag ?
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
high6
Member
Join Date: Feb 2009
Old 02-03-2009 , 06:46   Re: StripAndChangeServerConVarBool?
Reply With Quote #10

Quote:
Originally Posted by berni View Post
And who says that ConVar's can't have a cheat flag ?
But if that was the trouble wouldn't it say nothing at all?
high6 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 06:10.


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