Raised This Month: $32 Target: $400
 8% 

Set convar based on flag.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Terminatorr
Member
Join Date: Dec 2018
Old 12-13-2018 , 07:49   Set convar based on flag.
Reply With Quote #1

Hello guys, i do not know if what am doing is right, basically here is the story; i am new into sourcemod and paw, i have a server with vip plugin say of flag 'o', and i wish to enable certain vars to that flag only, say wanted to enable bunnyhop for everyone i would put it inside server.cf sv_enablebunnyhopping 1, i was googling for hours did not find a way to do an override for that, so i thought maybe i do a plugin that execute the cvar for that flag, unfortunatley my knowledge did not help to a working overcome.
PHP Code:
#include <sourcemod>
#include <colors> /* COLORS INCLUDE FOR COLORED MESSAGE */
#include <sdktools> /* SDK TOOLS INCLUDE (NEDDED FOR PLUGIN TO WORK) */

/**
 * Plugin public information.
 */
 
public Plugin myinfo =
 {
     
name "My First Plugin",
     
author "Me",
     
description "My first plugin ever",
     
version "1.0",
     
url "http://www.sourcemod.net/"
 
};

//ConVar g_cvEnabled;
//int IsEnabled;
//bool RoundStarted;
int maxclients;
public 
void OnPluginStart()
{
 
//    g_cvEnabled = CreateConVar("myplugin_enabled", "1", "Sets whether my plugin is enabled");

  
RegAdminCmd("sm_enablebunny"cmd_customvipADMFLAG_CUSTOM1"VIPMenu Command"); /* client needs flag "o" */
//  HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}

public 
OnMapStart ()
{
  
maxclients GetMaxClients();
  
//RoundStarted = true;
  //IsEnabled = GetConVarInt(g_cvEnabled);
}

public 
Action cmd_enablebunny(int clientint args)
{

for(new 
i=1<= maxclientsi++)
{
     if( 
IsClientInGame(i) && IsPlayerAlive(i))
     {
  
SetFakeClientConVar(client"sv_enablebunnyhopping","1");
  
CPrintToChat(client"BunnyHopping is enabled");
     }
 }


Terminatorr is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 12-13-2018 , 08:30   Re: Set convar based on flag.
Reply With Quote #2

SetFakeClientConVar looks like it would only affect bots in most cases or things the server can simulate. Try using SendConVarValue in it's place.
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Terminatorr
Member
Join Date: Dec 2018
Old 12-13-2018 , 08:34   Re: Set convar based on flag.
Reply With Quote #3

Quote:
Originally Posted by 1337norway View Post
SetFakeClientConVar looks like it would only affect bots in most cases or things the server can simulate. Try using SendConVarValue in it's place.
Hi, SendConVarValue seems to be a bool, https://sm.alliedmods.net/new-api/co...endConVarValue , plus there a handle i have no idea what to do with it.
Terminatorr is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 12-13-2018 , 08:45   Re: Set convar based on flag.
Reply With Quote #4

The return value is irreverent for your use case, you don't have to track it or do anything with it. The handle is the ConVar pointer or you can use FindConvar command.

SendConVarValue(client, FindConVar("sv_enablebunnyhopping"), "1");

I believe the convar you are looking for is sv_autobunnyhopping though? enablebunnybopping wouldn't be affected client side, it would just create prediction errors for the client as it reduces velocity serverside based on your speed when friction is applied. clients wouldn't be able to counter this based on a convar
__________________
I highly recommend joining the SourceMod Discord Server for real time support.

Last edited by backwards; 12-13-2018 at 08:48.
backwards is offline
Terminatorr
Member
Join Date: Dec 2018
Old 12-13-2018 , 08:54   Re: Set convar based on flag.
Reply With Quote #5

Quote:
Originally Posted by 1337norway View Post
The return value is irreverent for your use case, you don't have to track it or do anything with it. The handle is the ConVar pointer or you can use FindConvar command.

SendConVarValue(client, FindConVar("sv_enablebunnyhopping"), "1");

I believe the convar you are looking for is sv_autobunnyhopping though? enablebunnybopping wouldn't be affected client side, it would just create prediction errors for the client as it reduces velocity serverside based on your speed when friction is applied. clients wouldn't be able to counter this based on a convar
I find strange from JAVA background here, however i guise you'r right after test i just get the print out on screen like 10 times with no bunnyhopping, what would be the way to enable such convar only for a flag?
Terminatorr is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-13-2018 , 08:55   Re: Set convar based on flag.
Reply With Quote #6

sm_enablebunny 1
sm_enablebunny 0

PHP Code:
public void OnPluginStart()
{
    
RegAdminCmd("sm_enablebunny"testADMFLAG_CUSTOM1);
}

public 
Action test(int clientint args)
{
    
char text[5];
    
GetCmdArgString(textsizeof(text));

    
bool value StringToInt(text) != 0;

    
ConVar bunny FindConVar("sv_enablebunnyhopping");
    
bunny.SetBool(valuetruetrue); // Change server Convar sv_enablebunnyhopping
    
delete bunny

    PrintToChatAll
("[SM] sv_enablebunnyhopping %i"value);

    return 
Plugin_Handled;

__________________
Do not Private Message @me

Last edited by Bacardi; 12-13-2018 at 08:55.
Bacardi is offline
Terminatorr
Member
Join Date: Dec 2018
Old 12-13-2018 , 09:13   Re: Set convar based on flag.
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
sm_enablebunny 1
sm_enablebunny 0

PHP Code:
public void OnPluginStart()
{
    
RegAdminCmd("sm_enablebunny"testADMFLAG_CUSTOM1);
}

public 
Action test(int clientint args)
{
    
char text[5];
    
GetCmdArgString(textsizeof(text));

    
bool value StringToInt(text) != 0;

    
ConVar bunny FindConVar("sv_enablebunnyhopping");
    
bunny.SetBool(valuetruetrue); // Change server Convar sv_enablebunnyhopping
    
delete bunny

    PrintToChatAll
("[SM] sv_enablebunnyhopping %i"value);

    return 
Plugin_Handled;

Thanks Bacardi, it works perfectly
#1 I am trying to learn here, so doing such plugin is the only way to override a convar for a flag right?
#2 if wanted to add another command like "sv_autobunnyhopping" i would do another plugin for it right?
#3 if wanted to make it permanently active on 1 for that flag what would i do?
Terminatorr is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-13-2018 , 10:28   Re: Set convar based on flag.
Reply With Quote #8

...I quite didn't follow.
Do you want bunnyhop cvars enabled on admins only, not whole server ?

Have you tested it will work ?

Change these first
sm_cvar sv_autobunnyhopping 0
sm_cvar sv_enablebunnyhopping 0


PHP Code:
public void OnPluginStart()
{
    
HookEventEx("player_spawn"player_spawn);

}


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

    if(
GetClientTeam(client) < 2) return;

    if(!
CheckCommandAccess(client""ADMFLAG_CUSTOM1)) return;

    
ConVar console_variable FindConVar("sv_enablebunnyhopping");
    
SendConVarValue(clientconsole_variable"1");

    
console_variable FindConVar("sv_autobunnyhopping");
    
SendConVarValue(clientconsole_variable"1");

    
delete console_variable;
    
PrintToChat(client"[SM] You have bunnyhop enabled");

*edit
admins who have flag "o", when they spawn it will change those cvars (client side)

*edit edit
I don't think this will work, then you need find proper bunnyhop plugin.
__________________
Do not Private Message @me

Last edited by Bacardi; 12-13-2018 at 10:29.
Bacardi is offline
Terminatorr
Member
Join Date: Dec 2018
Old 12-13-2018 , 10:37   Re: Set convar based on flag.
Reply With Quote #9

With last code you sent, the screen flickers too much its not like bunnyhopping`i do have good hardware`.
Bare with me please. i am trying to understand it, cvars override is only done by plugins, right?
Terminatorr is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-13-2018 , 10:44   Re: Set convar based on flag.
Reply With Quote #10

You can change cvars from config file, rcon, console input and by SourceMod plugins.

Such as admin commands, sm_rcon, sm_cvar

If you like vip's to change few server cvars, you can do this by plugins and either Admin Menu Custom.
Bacardi 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 12:03.


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