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

[ANY] Bring/GoTo [UPDATED 2/6/2017]


Post New Thread Reply   
 
Thread Tools Display Modes
headline
SourceMod Moderator
Join Date: Mar 2015
Old 01-30-2017 , 15:45   Re: [ANY] Bring/GoTo [UPDATED 8/4/15]
Reply With Quote #21

Version 1.7
  • Added cvar to disable immunity
  • Added more SourceMod "classes"
  • Removed unnecessary dependency
  • Cleaned code up

Due to the fact that I removed autoexecconfig.inc, the .cfg file in cfg/sourcemod/hl_goto.cfg no longer serves a purpose. Setting vars there will have no effect. This is so the plugin can compile on the forums.

hl_goto_ignore_immunity is a new cvar which is disabled by default. By enabling it, immunity will be ignored
headline is offline
africanspacejesus
Senior Member
Join Date: Nov 2016
Location: Bay Area, CA
Old 02-06-2017 , 19:56   Re: [ANY] Bring/GoTo [UPDATED 1/30/2017]
Reply With Quote #22

Is there a cvar for which groups can use the commands?
__________________
Taking paid plugin requests
africanspacejesus is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 02-06-2017 , 20:43   Re: [ANY] Bring/GoTo [UPDATED 1/30/2017]
Reply With Quote #23

Quote:
Originally Posted by africanspacejesus View Post
Is there a cvar for which groups can use the commands?
Now there is! Add hl_goto_flags and then just specify what flags the person needs!

For example
Code:
hl_goto_flags "abc"
headline is offline
good_live
AlliedModders Donor
Join Date: Oct 2013
Old 02-07-2017 , 01:08   Re: [ANY] Bring/GoTo [UPDATED 1/30/2017]
Reply With Quote #24

Quote:
Originally Posted by Headline View Post
Now there is! Add hl_goto_flags and then just specify what flags the person needs!

For example
Code:
hl_goto_flags "abc"
Why is a flag needed for that? Sourcemod has a Override system, which works very well (and allows you to assign access to a group as requested)

Last edited by good_live; 02-07-2017 at 01:09.
good_live is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 02-07-2017 , 19:56   Re: [ANY] Bring/GoTo [UPDATED 1/30/2017]
Reply With Quote #25

Quote:
Originally Posted by good_live View Post
Why is a flag needed for that? Sourcemod has a Override system, which works very well (and allows you to assign access to a group as requested)
Im aware. SourceMod access overrides dont allow flag combinations ("abc;f") and I thought it'd be cool to support that.
headline is offline
generals
Senior Member
Join Date: Aug 2018
Old 02-13-2021 , 08:55   Re: [ANY] Bring/GoTo [UPDATED 2/6/2017]
Reply With Quote #26

Hi

Can It be done by all players

Even non-admins?
generals is offline
`666
AlliedModders Donor
Join Date: Jan 2006
Old 02-14-2021 , 06:52   Re: [ANY] Bring/GoTo [UPDATED 2/6/2017]
Reply With Quote #27

Quote:
Originally Posted by generals View Post
Hi

Can It be done by all players

Even non-admins?
Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.8"

ConVar gcv_bPluginEnabled;
ConVar gcv_bBotsEnabled;
ConVar gcv_bIgnoreImmunity;

public Plugin myinfo =
{
	name = "Teleport Player",
	author = "Headline, Original: HyperKiLLeR",
	description = "Teleport players!",
	version = PLUGIN_VERSION,
	url = "http://www.michaelwflaherty.com"
};

public void OnPluginStart()
{
	LoadTranslations("common.phrases");
	
	gcv_bPluginEnabled = CreateConVar("hl_goto_enabled", "1", "Enables and disables the goto plugin", FCVAR_NOTIFY, true, 0.0, true, 1.0);
	
	gcv_bBotsEnabled = CreateConVar("hl_goto_allow_bots", "1", "Enables and disables the ability to move bots", FCVAR_NOTIFY, true, 0.0, true, 1.0);
	
	gcv_bIgnoreImmunity = CreateConVar("hl_goto_ignore_immunity", "0", "Enable to ignore immunity permissions", FCVAR_NOTIFY, true, 0.0, true, 1.0);

	RegConsoleCmd("sm_goto", Command_Goto, "Go to a player");
	RegConsoleCmd("sm_bring", Command_Bring, "Teleport a player to you");
	RegConsoleCmd("sm_telemenu", Command_TeleMenu, "Opens the Teleport Menu");
}

public Action Command_Bring(int client, int args)
{
	if (!gcv_bPluginEnabled.BoolValue)
	{
		ReplyToCommand(client, "The goto plugin is disabled!");
		return Plugin_Handled;
	}
	
	if (args != 1)
	{
		ReplyToCommand(client, "[SM] Usage  bring <target>");
		return Plugin_Handled;
	}
	
	float fTeleportOrigin[3];
	float fPlayerOrigin[3];
	
	char sTarget[65];
	GetCmdArg(1, sTarget, sizeof(sTarget));

	char sTargetName[MAX_TARGET_LENGTH];
	int a_iTargets[MAXPLAYERS];
	int iTargetCount;
	bool bTN_ML;

	if((iTargetCount = ProcessTargetString(sTarget, client, a_iTargets, MAXPLAYERS, (gcv_bIgnoreImmunity.BoolValue)?(COMMAND_FILTER_NO_IMMUNITY|COMMAND_FILTER_ALIVE):(COMMAND_FILTER_ALIVE), sTargetName, sizeof(sTargetName), bTN_ML)) <= 0)
	{
		PrintToConsole(client, "Not found or invalid parameter.");
		return Plugin_Handled;
	}

	for (int i = 0; i < iTargetCount; i++)
	{
		int target = a_iTargets[i];
		if(IsValidClient(target, gcv_bBotsEnabled.BoolValue?true:false))
		{
			GetCollisionPoint(client, fPlayerOrigin);

			fTeleportOrigin[0] = fPlayerOrigin[0];
			fTeleportOrigin[1] = fPlayerOrigin[1];
			fTeleportOrigin[2] = (fPlayerOrigin[2] + 4);
			
			TeleportEntity(target, fTeleportOrigin, NULL_VECTOR, NULL_VECTOR);
			ReplyToCommand(client, "[SM] Player(s) have been teleported!");
			PrintToChat(target, "[SM] You have been brought to %N!", client);
		}
	}
	return Plugin_Handled;
}

public Action Command_Goto(int client, int args)
{
	if (!gcv_bPluginEnabled.BoolValue)
	{
		ReplyToCommand(client, "The hl_goto plugin is disabled!");
		return Plugin_Handled;
	}

	if (args != 1)
	{
		ReplyToCommand(client, "[SM] Usage  sm_goto <target>");
		return Plugin_Handled;
	}

	float fTeleportOrigin[3];
	float fPlayerOrigin[3];

	char sArg1[MAX_NAME_LENGTH];
	GetCmdArg(1, sArg1, sizeof(sArg1));
	int iTarget = FindTarget(client, sArg1, gcv_bBotsEnabled.BoolValue?false:true, true);

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

	GetClientAbsOrigin(iTarget, fPlayerOrigin);

	fTeleportOrigin[0] = fPlayerOrigin[0];
	fTeleportOrigin[1] = fPlayerOrigin[1];
	fTeleportOrigin[2] = (fPlayerOrigin[2] + 73);

	TeleportEntity(client, fTeleportOrigin, NULL_VECTOR, NULL_VECTOR);
	PrintToChat(iTarget, "[SM] %N has been brought to you!", client);
	PrintToChat(client, "[SM] You have been brought to %N!", iTarget);
	return Plugin_Handled;
}

public Action Command_TeleMenu(int client, int args)
{
	if (!gcv_bPluginEnabled.BoolValue)
	{
		ReplyToCommand(client, "The goto plugin is disabled!");
		return Plugin_Handled;
	}
	
	if (!IsValidClient(client))
	{
		ReplyToCommand(client, "[SM] You must be ingame to use this command!");
		return Plugin_Handled;
	}

	OpenMainMenu(client);
	return Plugin_Handled;
}

public void OpenMainMenu(int client)
{
	Menu menu = new Menu(MainMenu_CallBack, MenuAction_Select | MenuAction_End); 
	menu.SetTitle("Main Menu :");

	menu.AddItem("bring", "Bring Player(s)");
	menu.AddItem("goto", "Go To Player");

	menu.Display(client, MENU_TIME_FOREVER); 
}

public int MainMenu_CallBack(Menu menu, MenuAction action, int param1, int param2) 
{
	switch (action)
	{
		case MenuAction_Select:
		{
			char item[64];
			GetMenuItem(menu, param2, item, sizeof(item));

			if (StrEqual(item, "bring"))
			{
				OpenBringMenu(param1);
			}
			else if (StrEqual(item, "goto"))
			{
				OpenGoToMenu(param1);
			}
		}
		case MenuAction_End:
		{
			delete menu;
		}
	}
}

void OpenBringMenu(int client)
{
	Menu menu = new Menu(BringMenu_CallBack, MenuAction_Select | MenuAction_End); 
	menu.SetTitle("Bring Menu");
	char sCommand[32] = "sm_bring";

	for(int i = 1; i <= MaxClients; i++)
	{
		if(IsValidClient(i, gcv_bBotsEnabled.BoolValue?true:false, false))
		{
			char sInfoBuffer[256];
			char sName[MAX_NAME_LENGTH];
			char sUserID[MAX_NAME_LENGTH];
			char sDisplay[128];
			IntToString(GetClientUserId(i), sUserID, sizeof(sUserID));
			GetClientName(i, sName, sizeof(sName));
			Format(sDisplay, sizeof(sDisplay), "%s (%s)", sName, sUserID);
			Format(sInfoBuffer, sizeof(sInfoBuffer), "%s %s", sCommand, sUserID);
			menu.AddItem(sInfoBuffer, sDisplay);
		}
	}
	menu.ExitBackButton = true;
	menu.Display(client, MENU_TIME_FOREVER);
}

public int BringMenu_CallBack(Menu menu, MenuAction action, int param1, int param2) 
{
	switch (action)
	{
		case MenuAction_Select:
		{
			char sInfo[64];
			GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
			char sTempArray[2][32];
			ExplodeString(sInfo, " ", sTempArray, sizeof(sTempArray), sizeof(sTempArray[]));

			if(!IsValidClient(GetClientOfUserId(StringToInt(sTempArray[1]))))
			{
				ReplyToCommand(param1, "Invalid target.");
			}
			else if(!IsPlayerAlive(GetClientOfUserId(StringToInt(sTempArray[1]))))
			{
				ReplyToCommand(param1, "Player no longer alive.");
			}
			else
			{
				char sCommand[300];
				Format(sCommand, sizeof(sCommand), "%s #%i", sTempArray[0], StringToInt(sTempArray[1]));
				FakeClientCommand(param1, sCommand);
			}
		}
		case MenuAction_Cancel:
		{
			//param1 is client, param2 is cancel reason (see MenuCancel types)
			if (param2 == MenuCancel_ExitBack)
			{
				OpenMainMenu(param1);
			}

		}
		case MenuAction_End:
		{
			//param1 is MenuEnd reason, if canceled param2 is MenuCancel reason
			delete menu;

		}
	}
}

void OpenGoToMenu(int client)
{
	Menu menu = new Menu(GoToMenu_Callback, MenuAction_Select | MenuAction_End); 
	menu.SetTitle("Bring Menu ");
	char sCommand[32] = "sm_goto";
	for (int i = 1; i <= MaxClients; i++)
	{
		if (IsValidClient(i, gcv_bBotsEnabled.BoolValue?true:false, false))
		{
			char sInfoBuffer[256];
			char sName[MAX_NAME_LENGTH];
			char sUserID[MAX_NAME_LENGTH];
			char sDisplay[128];
			IntToString(GetClientUserId(i), sUserID, sizeof(sUserID));
			GetClientName(i, sName, sizeof(sName));
			Format(sDisplay, sizeof(sDisplay), "%s (%s)", sName, sUserID);
			Format(sInfoBuffer, sizeof(sInfoBuffer), "%s %s", sCommand, sUserID);
			menu.AddItem(sInfoBuffer, sDisplay);
		}
	}
	menu.ExitBackButton = true;
	menu.Display(client, MENU_TIME_FOREVER);
}

public int GoToMenu_Callback(Menu menu, MenuAction action, int param1, int param2)
{
	switch (action)
	{
		case MenuAction_Select:
		{
			//param1 is client, param2 is sInfo

			char sInfo[64];
			GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
			char sTempArray[2][32];
			ExplodeString(sInfo, " ", sTempArray, sizeof(sTempArray), sizeof(sTempArray[]));

			if(!IsValidClient(GetClientOfUserId(StringToInt(sTempArray[1]))))
			{
					ReplyToCommand(param1, "Invalid target.");
			}
			else if(!IsPlayerAlive(GetClientOfUserId(StringToInt(sTempArray[1]))))
			{
					ReplyToCommand(param1, "Player no longer alive.");
			}
			else
			{
					char sCommand[300];
					Format(sCommand, sizeof(sCommand), "%s #%i", sTempArray[0], StringToInt(sTempArray[1]));
					FakeClientCommand(param1, sCommand);
			}
		}
		case MenuAction_Cancel:
		{
			//param1 is client, param2 is cancel reason (see MenuCancel types)
			if (param2 == MenuCancel_ExitBack)
			{
				OpenMainMenu(param1);
			}

		}
		case MenuAction_End:
		{
			//param1 is MenuEnd reason, if canceled param2 is MenuCancel reason
			delete menu;

		}
	}
}

void GetCollisionPoint(int client, float pos[3])
{
	float vOrigin[3];
	float vAngles[3];
	
	GetClientEyePosition(client, vOrigin);
	GetClientEyeAngles(client, vAngles);
	
	Handle trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SOLID, RayType_Infinite, TraceEntityFilterPlayer);
	
	if(TR_DidHit(trace))
	{
		TR_GetEndPosition(pos, trace);
		delete trace;
		
		return;
	}
	
	delete trace;
}

bool TraceEntityFilterPlayer(int entity, int contentsMask)
{
	return entity > MaxClients;
}  

bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = true)
{
	if(!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
	{
		return false;
	}
	return true;
}

// Copy & Pasted from ThatOneGuy 
bool HasFlags(int client, char[] sFlags)
{
	if(StrEqual(sFlags, "public", false) || StrEqual(sFlags, "", false))
	{
		return true;
	}
	
	if(StrEqual(sFlags, "none", false))
	{
		return false;
	}
	
	AdminId id = GetUserAdmin(client);
	if(id == INVALID_ADMIN_ID)
	{
		return false;
	}
	
	if(CheckCommandAccess(client, "sm_not_a_command", ADMFLAG_ROOT, true))
	{
		return true;
	}
	int iCount, iFound, flags;
	if(StrContains(sFlags, ";", false) != -1) //check if multiple strings
	{
		int c = 0, iStrCount = 0;
		while(sFlags[c] != '\0')
		{
			if(sFlags[c++] == ';')
			{
				iStrCount++;
			}
		}
		iStrCount++; //add one more for IP after last comma
		
		char[][] sTempArray = new char[iStrCount][30];
		ExplodeString(sFlags, ";", sTempArray, iStrCount, 30);
		
		for(int i = 0; i < iStrCount; i++)
		{
			flags = ReadFlagString(sTempArray[i]);
			iCount = 0;
			iFound = 0;
			for(int j = 0; j <= 20; j++)
			{
				if(flags & (1<<j))
				{
					iCount++;

					if(GetAdminFlag(id, view_as<AdminFlag>(j)))
					{
						iFound++;
					}
				}
			}
			
			if(iCount == iFound)
			{
				return true;
			}
		}
	}
	else
	{
		flags = ReadFlagString(sFlags);
		iCount = 0;
		iFound = 0;
		for(int i = 0; i <= 20; i++)
		{
			if(flags & (1<<i))
			{
				iCount++;

				if(GetAdminFlag(id, view_as<AdminFlag>(i)))
				{
					iFound++;
				}
			}
		}

		if(iCount == iFound)
		{
			return true;
		}
	}
	return false;
}

/* Changelog
	1.0 - Initial Release
	1.1 - Added LoadTranslations because I forgot
	1.2 - Removed cstrike.inc (allowed access for TF2/etc games)
	1.3 - Added CVAR to enable/disable the teleportation of bots & fixed issue where the config file wouldn't get executed
	1.4 - Fixed OnConVarChange issue 
	1.5 - Added menus!
	1.6 - Fixed targeting issue & Ported over to new syntax
	1.7 - Cleaned code, added new cvar, and removed autoexecconfig
	1.8 - Added HasFlags from ThatOneGuy
*/
`666 is offline
qingshanchengg
Junior Member
Join Date: Jan 2023
Old 06-10-2023 , 08:09   Re: [ANY] Bring/GoTo [UPDATED 2/6/2017]
Reply With Quote #28

plug Support or not《No More Room in Hell》?
__________________
:>
qingshanchengg is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 06-10-2023 , 10:19   Re: [ANY] Bring/GoTo [UPDATED 2/6/2017]
Reply With Quote #29

Quote:
Originally Posted by qingshanchengg View Post
plug Support or not《No More Room in Hell》?
should work

You can also try using this plugin, which I once wrote for myself: https://github.com/Grey83/SourceMod-...telemanager.sp
__________________
Grey83 is offline
qingshanchengg
Junior Member
Join Date: Jan 2023
Old 06-11-2023 , 12:23   Re: [ANY] Bring/GoTo [UPDATED 2/6/2017]
Reply With Quote #30

Quote:
Originally Posted by Grey83 View Post
should work

You can also try using this plugin, which I once wrote for myself: https://github.com/Grey83/SourceMod-...telemanager.sp
Thank you ,very much if I want other players to use "sm_teleme" to prevent getting lost。
Is that OK?

Overrides
{
"sm_teleme" ""
}
__________________
:>
qingshanchengg 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:17.


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