Raised This Month: $ Target: $400
 0% 

StripAndChangeServerConVarBool?


Post New Thread Reply   
 
Thread Tools Display Modes
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-03-2009 , 06:54   Re: StripAndChangeServerConVarBool?
Reply With Quote #11

Code:
new z_speed = FindConVar("z_speed");
new flags_z_speed = GetConVarFlags(z_speed);
flags_z_speed |= FCVAR_CHEAT;
SetConVarFlags(z_speed, flags_z_speed);
SetConVarInt(z_speed, 1000);
__________________
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:56   Re: StripAndChangeServerConVarBool?
Reply With Quote #12

Quote:
Originally Posted by berni View Post
Code:
new z_speed = FindConVar("z_speed");
new flags_z_speed = GetConVarFlags(z_speed);
flags_z_speed |= FCVAR_CHEAT;
SetConVarFlags(z_speed, flags_z_speed);
SetConVarInt(z_speed, 1000);
Wouldn't that add the cheat flag?

Anyways, I will try SetConVarInt.
high6 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-03-2009 , 07:00   Re: StripAndChangeServerConVarBool?
Reply With Quote #13

sorry, flags_z_speed &= ~FCVAR_CHEAT
__________________
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

Last edited by berni; 02-03-2009 at 07:02.
berni is offline
high6
Member
Join Date: Feb 2009
Old 02-03-2009 , 07:09   Re: StripAndChangeServerConVarBool?
Reply With Quote #14

Okay, SetConVarInt works, but why does it work and ServerCommand doesn't?
high6 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-03-2009 , 07:20   Re: StripAndChangeServerConVarBool?
Reply With Quote #15

I'm sure ServerCommand works too once you have stripped the cheatflag, but you shouldn't use ServerCommand, as the command line parsing costs performance.
__________________
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 , 07:29   Re: StripAndChangeServerConVarBool?
Reply With Quote #16

Quote:
Originally Posted by berni View Post
I'm sure ServerCommand works too once you have stripped the cheatflag, but you shouldn't use ServerCommand, as the command line parsing costs performance.
Well I would rather just use ServerCommand for simplicity.

Code:
public CServerCommand(String:args[])
{
    decl String:arg[255];
    GetCmdArg(1, arg, 255);
    
    decl String:arg2[255];
    GetCmdArg(2, arg2, 255);
    
    new Handle:handle = FindConVar(arg);
    if (handle != INVALID_HANDLE)
    {
        new flags = GetConVarFlags(handle);
        SetConVarFlags(handle, flags & ~FCVAR_CHEAT);
        ServerCommand("%s",args); //Doesn't work
        //SetConVarInt(handle,StringToInt(arg2)); //Does work
        SetConVarFlags(handle, flags);
    }
}
ServerCommand always gives the cheats must be enabled.

Code:
] CServerCommand z_speed 1000
L 02/03/2009 - 07:27:20: [fun.smx] "Console<0><Console><Console>" console command (cmdline "z_speed 1000")
Can't use cheat cvar z_speed in multiplayer, unless the server has sv_cheats set to 1.
high6 is offline
BAILOPAN
Join Date: Jan 2004
Old 02-03-2009 , 09:05   Re: StripAndChangeServerConVarBool?
Reply With Quote #17

ServerCommand is not immediate, the string is inserted into a buffer. The buffer is parsed incrementally such that one command is tokenized and run each frame.

This indeed means performance cost, but more importantly, you don't know when the command will actually run, and by the time it does the cheat flag has been re-added.
__________________
egg
BAILOPAN is offline
high6
Member
Join Date: Feb 2009
Old 02-03-2009 , 09:11   Re: StripAndChangeServerConVarBool?
Reply With Quote #18

Okay, thanks.
high6 is offline
high6
Member
Join Date: Feb 2009
Old 02-03-2009 , 11:39   Re: StripAndChangeServerConVarBool?
Reply With Quote #19

If I don't use ServerCommand, how do I tell how to handle what the user entered?
high6 is offline
Kigen
BANNED
Join Date: Feb 2008
Old 02-03-2009 , 22:36   Re: StripAndChangeServerConVarBool?
Reply With Quote #20

native SetConVarString(Handle:convar, const String:value[], bool:replicate=false, bool:notify=false);
Kigen 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 14:25.


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