AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   StripAndChangeServerConVarBool? (https://forums.alliedmods.net/showthread.php?t=84867)

high6 02-02-2009 05:40

StripAndChangeServerConVarBool?
 
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/

berni 02-02-2009 11:14

Re: StripAndChangeServerConVarBool?
 
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);
}


high6 02-02-2009 14:00

Re: StripAndChangeServerConVarBool?
 
O okay, I didn't see it in there, thanks.

high6 02-02-2009 15:20

Re: StripAndChangeServerConVarBool?
 
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);
    }
}


grandwazir 02-02-2009 16:25

Re: StripAndChangeServerConVarBool?
 
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.

high6 02-02-2009 16:36

Re: StripAndChangeServerConVarBool?
 
Quote:

Originally Posted by grandwazir (Post 754553)
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.

grandwazir 02-02-2009 16:50

Re: StripAndChangeServerConVarBool?
 
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?

high6 02-03-2009 06:32

Re: StripAndChangeServerConVarBool?
 
Quote:

Originally Posted by grandwazir (Post 754567)
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.

berni 02-03-2009 06:40

Re: StripAndChangeServerConVarBool?
 
Quote:

Originally Posted by high6 (Post 754838)
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 ?

high6 02-03-2009 06:46

Re: StripAndChangeServerConVarBool?
 
Quote:

Originally Posted by berni (Post 754840)
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?


All times are GMT -4. The time now is 05:24.

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