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

How can I make a plugin run only for me?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
denkoludiq
New Member
Join Date: Sep 2017
Old 09-10-2017 , 05:54   How can I make a plugin run only for me?
Reply With Quote #1

Hey, I was wondering if I can make a plugin run only for my SteamID/Name for example.
denkoludiq is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 09-10-2017 , 06:20   Re: How can I make a plugin run only for me?
Reply With Quote #2

Here's an example that allows a command to be only ran by either a specific SteamID or the server itself (RCON also works).
Note that it still requires ROOT access because of RegAdminCmd.

Code:
#include <sourcemod>

public void OnPluginStart()
{
	RegAdminCmd("sm_crash", Command_Crash, ADMFLAG_ROOT);

	LoadTranslations("common.phrases");
}

public Action Command_Crash(int client, int args)
{
	char[] sAuth = new char[32];

	if(client != 0 && !(GetClientAuthId(client, AuthId_Steam3, sAuth, 32) && StrEqual(sAuth, "[U:1:204506329]")))
	{
		return Plugin_Continue;
	}

	if(args < 1)
	{
		ReplyToCommand(client, "sm_crash <target>");

		return Plugin_Handled;
	}

	char[] sArgs = new char[MAX_TARGET_LENGTH];
	GetCmdArgString(sArgs, MAX_TARGET_LENGTH);

	int target = FindTarget(client, sArgs, true, false);

	if(target == -1)
	{
		return Plugin_Handled;
	}

	Handle hSayText2 = StartMessageOne("SayText2", target);

	if(hSayText2 != null)
	{
		PbSetInt(hSayText2, "ent_idx", target);
		PbSetBool(hSayText2, "chat", false);
		PbSetString(hSayText2, "msg_name", "rip");
		EndMessage();
	}

	return Plugin_Handled;
}
__________________
retired

Last edited by shavit; 09-10-2017 at 06:22.
shavit is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 09-10-2017 , 08:12   Re: How can I make a plugin run only for me?
Reply With Quote #3

If your planning on implementing something like that, you must NEVER distribute the plugin, otherwise it can and will be blacklisted from being loaded by EVERY installation of SourceMod (by hash)
__________________
WildCard65 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 01:13.


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