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

Return command value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 07-10-2020 , 23:04   Return command value
Reply With Quote #1

What function should i use to return the command value? such as return if server_cvar is 0, it will allow test1 text to go trough and if server_cvar is 1, it will allow test2 text to go trough.
__________________
Teamkiller324 is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 07-11-2020 , 05:51   Re: Return command value
Reply With Quote #2

Take a look at: https://sm.alliedmods.net/new-api/convars/FindConVar & https://sm.alliedmods.net/new-api/convars/GetConVarInt
__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:
SSheriFF is offline
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 07-11-2020 , 21:04   Re: Return command value
Reply With Quote #3

Thanks, got it working with something like this:

Code:
#pragma		semicolon 1
#include	<sourcemod>
#include	<multicolors>

new		Handle:TestCmd = INVALID_HANDLE;

public	OnPluginStart()
{
	TestCmd	=	FindConVar("bot_forceattack");
	RegAdminCmd("sm_testing",	CommandTesting, ADMFLAG_ROOT);
}

public Action:CommandTesting(client, args)
{
	ServerCommand("toggle bot_forceattack");
	{
		if (GetConVarInt(TestCmd) == 1)
		{
			CPrintToChat(client, "bot_forceattack value turned off"); // If 0, print turned off
		}
		else if (GetConVarInt(TestCmd) == 0)
		{
			CPrintToChat(client, "bot_forceattack value turned on"); // If 1, print turned on
		}
	}
	return Plugin_Handled;
}
Inverted 0 and 1 for getting the ConVarInt for TestCmd is working correctly for some reason. doing vice versa will make it do bot_forceattack 1 when "off" and bot_forceattack 0 when "on"
__________________

Last edited by Teamkiller324; 07-12-2020 at 08:51.
Teamkiller324 is offline
Reply


Thread Tools
Display Modes

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 11:11.


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