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

Solved [L4D2]How can I use a cheat command?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Morning
Member
Join Date: May 2021
Old 03-28-2023 , 07:12   [L4D2]How can I use a cheat command?
Reply With Quote #1

To change a "cheat" convar, from within a sourcemod plugin, I can easily use the "sm_cvar". Is there a command which will let me use a "cheat" command?

The specific command I want to use is "nb_delete_all" (to remove all infected from the game). What is the simplest way to do this? I did search for a way to do this, but all I could find were plugins for users to control cheats in-game.

Thanks!

Last edited by Morning; 03-30-2023 at 06:48.
Morning is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 03-28-2023 , 08:31   Re: [L4D2]How can I use a cheat command?
Reply With Quote #2

You can try [ANY] Dev Cmds

PHP Code:
sm_e <command> [args// Executes a cheat command.
<command> [args// Executes a cheat command. 
E.g: "sm_e nb_delete_all"

If "e" is already in use because csm plugin (Ellis character) just rename it.
__________________

Last edited by Marttt; 03-28-2023 at 08:32.
Marttt is offline
Morning
Member
Join Date: May 2021
Old 03-28-2023 , 09:48   Re: [L4D2]How can I use a cheat command?
Reply With Quote #3

Holy crap these tools look amazing! Yeah it looks like I will need to rename a few but that's cool. Thanks a lot!

edit: "sm_e nb_delete_all" prints "Command can only be used in game on a dedicated server." To be clear I am looking to run the "cheat" command from within a sourcemod plugin, not as a player in game.

Last edited by Morning; 03-28-2023 at 11:11.
Morning is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 03-28-2023 , 12:29   Re: [L4D2]How can I use a cheat command?
Reply With Quote #4

If you are running a listen server you should bind as a say command

"say /sm_e nb_delete_all"

otherwise, will need a few edits in the plugin
__________________

Last edited by Marttt; 03-28-2023 at 12:31.
Marttt is offline
Morning
Member
Join Date: May 2021
Old 03-28-2023 , 12:46   Re: [L4D2]How can I use a cheat command?
Reply With Quote #5

No I have a dedicated server which is running SourceMod. I want to the run the command using a function like ServerCommand or something similar.

I would do the edits to my plugin rather than editing someone else's and having dependency if that is possible. So yes I was asking about editing my own code to achieve this.
Morning is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 03-28-2023 , 17:17   Re: [L4D2]How can I use a cheat command?
Reply With Quote #6

The code for the CheatCommand() function or whatever name you want to call it is in Dev Cmds and plenty of other plugins.
__________________
Silvers is offline
Morning
Member
Join Date: May 2021
Old 03-30-2023 , 06:47   Re: [L4D2]How can I use a cheat command?
Reply With Quote #7

Ahh yes I found the function there, thanks a lot!

Code:
void ExecuteCheatCommand(const char[] command, const char[] value = "")
{
	int flags = GetCommandFlags(command);
	SetCommandFlags(command, flags & ~FCVAR_CHEAT); // Remove cheat flag
	ServerCommand("%s %s", command, value);
	ServerExecute();
	SetCommandFlags(command, flags);
}
Morning 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 17:32.


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