Raised This Month: $ Target: $400
 0% 

[CS:GO] Dynamic permissions with convar


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
JoaoRodrigoGamer
Junior Member
Join Date: Jul 2019
Location: Portugal
Old 08-24-2019 , 06:17   [CS:GO] Dynamic permissions with convar
Reply With Quote #1

So, I was trying to make a "modular" plugin on which you could go to the config file on /cfg/sourcemod/MoreVIPFeatures.cfg and change the flag needed to execute certain commands. I came up with this code:

PHP Code:
ConVar c_VIPflag;
char s_VIPflag[30];

public 
void OnPluginStart()
{
    
c_VIPflag CreateConVar("MorevipFeatures_flag""o""The VIP flag needed to get the VIP Features");
    
AutoExecConfig(true"MoreVIPFeatures");

    
GetConVarString(c_VIPflags_VIPflagsizeof(s_VIPflag));

    if(
StrEqual(s_VIPflag"a"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_RESERVATION);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_RESERVATION);
    }
    else if (
StrEqual(s_VIPflag"b"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_GENERIC);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_GENERIC);
    }
    else if (
StrEqual(s_VIPflag"c"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_KICK);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_KICK);
    }
    else if (
StrEqual(s_VIPflag"d"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_BAN);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_BAN);
    }
    else if (
StrEqual(s_VIPflag"e"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_UNBAN);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_UNBAN);
    }
    else if (
StrEqual(s_VIPflag"f"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_SLAY);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_SLAY);
    }
    else if (
StrEqual(s_VIPflag"g"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CHANGEMAP);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CHANGEMAP);
    }
    else if (
StrEqual(s_VIPflag"h"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CONVARS);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CONVARS);
    }
    else if (
StrEqual(s_VIPflag"i"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CONFIG);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CONFIG);
    }
    else if (
StrEqual(s_VIPflag"j"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CHAT);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CHAT);
    }
    else if (
StrEqual(s_VIPflag"k"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_VOTE);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_VOTE);
    }
    else if (
StrEqual(s_VIPflag"l"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_PASSWORD);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_PASSWORD);
    }
    else if (
StrEqual(s_VIPflag"m"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_RCON);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_RCON);
    }
    else if (
StrEqual(s_VIPflag"n"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CHEATS);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CHEATS);
    }
    else if (
StrEqual(s_VIPflag"z"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_ROOT);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_ROOT);
    }
    else if (
StrEqual(s_VIPflag"o"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CUSTOM1);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CUSTOM1);
    }
    else if (
StrEqual(s_VIPflag"p"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CUSTOM2);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CUSTOM2);
    }
    else if (
StrEqual(s_VIPflag"q"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CUSTOM3);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CUSTOM3);
    }
    else if (
StrEqual(s_VIPflag"r"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CUSTOM4);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CUSTOM4);
    }
    else if (
StrEqual(s_VIPflag"s"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CUSTOM5);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CUSTOM5);
    }
    else if (
StrEqual(s_VIPflag"t"true))
    {
        
RegAdminCmd("sm_vipmenu"VipMenuADMFLAG_CUSTOM6);
        
RegAdminCmd("sm_vipspawn"vipSpawnADMFLAG_CUSTOM6);
    }
    else
    {
        
SetFailState("[MoreVIPFeatures] %t""Could not get flag");
    }

I thought it was all working but when I got to test the code and change the flag needed on the config file to "b", it would still use the default flag "o".
Can anyone help me understand and try to fix this issue?
JoaoRodrigoGamer is offline
 



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 09:48.


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