AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [CSGO] Enable sv_cheats 1 but only for certain players? (https://forums.alliedmods.net/showthread.php?t=342643)

Austin 05-01-2023 20:16

[CSGO] Enable sv_cheats 1 but only for certain players?
 
Is there any way to enable sv_cheats 1
but only for certain players?

L4D2Noob 05-02-2023 00:40

Re: [CSGO] Enable sv_cheats 1 but only for certain players?
 
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");
        }
}


Austin 05-02-2023 03:37

Re: [CSGO] Enable sv_cheats 1 but only for certain players?
 
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 05-02-2023 05:04

Re: [CSGO] Enable sv_cheats 1 but only for certain players?
 
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");



L4D2Noob 05-02-2023 14:06

Re: [CSGO] Enable sv_cheats 1 but only for certain players?
 
Quote:

Originally Posted by Austin (Post 2803783)
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.

Austin 05-02-2023 17:24

Re: [CSGO] Enable sv_cheats 1 but only for certain players?
 
Quote:

Originally Posted by L4D2Noob (Post 2803819)
Well, in Counter-Strike: Source this code works.

It was a nice try, thanks.

Another CSGO weirdness......

Maxximou5 05-02-2023 19:42

Re: [CSGO] Enable sv_cheats 1 but only for certain players?
 
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");
    }



Austin 05-03-2023 02:55

Re: [CSGO] Enable sv_cheats 1 but only for certain players?
 
Quote:

Originally Posted by Maxximou5 (Post 2803833)
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?

Maxximou5 05-03-2023 03:05

Re: [CSGO] Enable sv_cheats 1 but only for certain players?
 
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.

Austin 05-04-2023 03:29

Re: [CSGO] Enable sv_cheats 1 but only for certain players?
 
Quote:

Originally Posted by Maxximou5 (Post 2803844)
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");




All times are GMT -4. The time now is 17:57.

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