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

Solved [CSGO] Enable sv_cheats 1 but only for certain players?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 05-01-2023 , 20:16   [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #1

Is there any way to enable sv_cheats 1
but only for certain players?

Last edited by Austin; 05-12-2023 at 14:46.
Austin is offline
L4D2Noob
AlliedModders Donor
Join Date: Mar 2020
Location: Moscow
Old 05-02-2023 , 00:40   Re: [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #2

For Admin
Code:
#include <sourcemod>

Handle sv_cheats = null;

public void OnPluginStart()
{
	sv_cheats = FindConVar("sv_cheats");
	
	HookEvent("player_spawn", Event_Player_Spawn, EventHookMode_Post);
	for(int i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && !IsFakeClient(i) && GetUserFlagBits(i) & (ADMFLAG_ROOT))
		{
			SendConVarValue(i, sv_cheats, "1");
		}
	}
}

public void OnClientPutInServer(int client)
{
	if(!IsFakeClient(client) && GetUserFlagBits(client) & (ADMFLAG_ROOT))
	{
		SendConVarValue(client, sv_cheats, "1");
	}
}

public void Event_Player_Spawn(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if(!IsFakeClient(client) && GetUserFlagBits(client) & (ADMFLAG_ROOT))
	{
		SendConVarValue(client, sv_cheats, "1");
	}
}
__________________
L4D2Noob is offline
Send a message via ICQ to L4D2Noob Send a message via Skype™ to L4D2Noob
Austin
Senior Member
Join Date: Oct 2005
Old 05-02-2023 , 03:37   Re: [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #3

Thanks for the reply.

I built the plugin
I see it running.
I set sv_cheats 0 on the server

I have my correct steam id set up in admins_simple.ini
"STEAM_1:0:123456789" "99:z"

I can use this command and see the sm admin menu
sm_admin

But my key binds that depend on sv_cheats 1
do not work.

What am I doing wrong?
Austin is offline
Austin
Senior Member
Join Date: Oct 2005
Old 05-02-2023 , 05:04   Re: [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #4

For testing I built a version that doesn't use the sm admin flags and gives cheats to all human players
but it doesn't work either.

What is SendConVarValue() supposed to do?
At least for csgo and setting sv_cheat 1 for a player it doesn't work.

PHP Code:
#include <sourcemod>
Handle sv_cheats null;

public 
void OnPluginStart()
{
    
sv_cheats FindConVar("sv_cheats");
    
HookEvent("player_spawn"Event_Player_SpawnEventHookMode_Post);
    for(
int i 1<= MaxClientsi++)
        if(
IsClientInGame(i) && !IsFakeClient(i))
            
SendConVarValue(isv_cheats"1");
}

public 
void OnClientPutInServer(int client)
{
    if(!
IsFakeClient(client))
        
SendConVarValue(clientsv_cheats"1");
}

public 
void Event_Player_Spawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if(!
IsFakeClient(client))
        
SendConVarValue(clientsv_cheats"1");


Last edited by Austin; 05-02-2023 at 05:05.
Austin is offline
L4D2Noob
AlliedModders Donor
Join Date: Mar 2020
Location: Moscow
Old 05-02-2023 , 14:06   Re: [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #5

Quote:
Originally Posted by Austin View Post
For testing I built a version that doesn't use the sm admin flags and gives cheats to all human players
but it doesn't work either.

What is SendConVarValue() supposed to do?
At least for csgo and setting sv_cheat 1 for a player it doesn't work.

PHP Code:
#include <sourcemod>
Handle sv_cheats null;

public 
void OnPluginStart()
{
    
sv_cheats FindConVar("sv_cheats");
    
HookEvent("player_spawn"Event_Player_SpawnEventHookMode_Post);
    for(
int i 1<= MaxClientsi++)
        if(
IsClientInGame(i) && !IsFakeClient(i))
            
SendConVarValue(isv_cheats"1");
}

public 
void OnClientPutInServer(int client)
{
    if(!
IsFakeClient(client))
        
SendConVarValue(clientsv_cheats"1");
}

public 
void Event_Player_Spawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if(!
IsFakeClient(client))
        
SendConVarValue(clientsv_cheats"1");

Well, in Counter-Strike: Source this code works.
__________________
L4D2Noob is offline
Send a message via ICQ to L4D2Noob Send a message via Skype™ to L4D2Noob
Austin
Senior Member
Join Date: Oct 2005
Old 05-02-2023 , 17:24   Re: [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #6

Quote:
Originally Posted by L4D2Noob View Post
Well, in Counter-Strike: Source this code works.
It was a nice try, thanks.

Another CSGO weirdness......
Austin is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 05-02-2023 , 19:42   Re: [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #7

It does work for CS:GO, just make sure you do so correctly -
PHP Code:
#pragma newdecls required

ConVar sv_cheats;

public 
void OnPluginStart()
{
    
sv_cheats FindConVar("sv_cheats");
    
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post);
    for (
int i 1<= MaxClientsi++)
    {
        
OnClientPutInServer(i);
    }
}

public 
void OnClientPutInServer(int client)
{
    if (
IsClientInGame(client) && !IsFakeClient(client))
    {
        
sv_cheats.ReplicateToClient(client"1");
    }
}

public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
IsClientInGame(client) && !IsFakeClient(client))
    {
        
sv_cheats.ReplicateToClient(client"1");
    }

Maxximou5 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 05-03-2023 , 02:55   Re: [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #8

Quote:
Originally Posted by Maxximou5 View Post
It does work for CS:GO, just make sure you do so correctly -
1) I built the plugin exactly with the source code as shown.
2) I made sure the plugin in was running.
3) And nothing was reported in the sm error logs
4) I set sv_cheats 0 on the server
5) when I join the server and try to issue a command that needs sv_cheat 1 it still doesn't let me.

] rcon sm plugins list
[SM] Listing 40 plugins:
...
...
40 "ABS_CSGO_Cheats.smx"

] rcon bot_stop 1
Can't use cheat cvar bot_stop in multiplayer, unless the server has sv_cheats set to 1.

What could it be?

Last edited by Austin; 05-03-2023 at 02:56.
Austin is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 05-03-2023 , 03:05   Re: [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #9

bot_stop is an rcon command or listen server command, not a player command. You would need to use rcon bot_stop to be able to use it.

If you want to test sv_cheats is working, just join with the code I provided and try the command in console - thirdperson

If you are unable to go thirdperson, most likely you have a plugin that is blocking.
Maxximou5 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 05-04-2023 , 03:29   Re: [CSGO] Enable sv_cheats 1 but only for certain players?
Reply With Quote #10

Quote:
Originally Posted by Maxximou5 View Post
bot_stop is an rcon command or listen server command, not a player command. You would need to use rcon bot_stop to be able to use it.

If you want to test sv_cheats is working, just join with the code I provided and try the command in console - thirdperson

If you are unable to go thirdperson, most likely you have a plugin that is blocking.
I found a work around for now but still would like to get this working.

I think the problem is I don't understand what this
SendConVarValue() is supposed to do.

I am thinking it enables the ability for the specified player to use any server command that needs to have
sv_cheats 1

The code as shown doesn't work that way.

And I don't understand the answer since I am not sure of what you mean by "player commands"

For what I know there are only two types of csgo commands
1) Commands for the server
You can enter them right at the server console
or
you can enter them from rcon
There is no difference using rcon.
It is exactly like you issued the server command at the server console.

2) The only other csgo commands I know of are client commands
These are entered at the game's player's console.

What are "player commands"?
What do you mean by 2rd person?

For now I have an OK workaround where I enable sv_cheats 1 only when I am on the server.

Thanks to everyone for the replies.

PHP Code:
#pragma newdecls required
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
    
HookEvent("player_connect_full"Event_PlayerConnectFull);
    
HookEvent("player_disconnect",        Event_PlayerDisconnect);

    
PrintToServer("ABS_CSGO_Cheats Loaded");
    
PrintToChatAll("ABS_CSGO_Cheats Loaded");
}

public 
void Event_PlayerConnectFull(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
CheckForAustinclienttrue);
}

public 
Action Event_PlayerDisconnect(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
CheckForAustinclientfalse);
}

public 
void CheckForAustin(int clientbool connecting)
{
    
char steamId[64];
    if (
<= client <= MaxClients)
    {
        
GetClientAuthId(clientAuthId_Steam2steamId128);
        
// Austin - Server Owner
        
if (strcmp(steamId"STEAM_1:0:1234567890")    == 0)
            if (
connecting)
                
ServerCommand("sv_cheats 1");
            else
                
ServerCommand("sv_cheats 0");
    }
}

public 
void OnPluginEnd()
{
    
ServerCommand("sv_cheats 0");


Last edited by Austin; 05-04-2023 at 03:46.
Austin 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:58.


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