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

@red - @blue - @all works with 1 player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kerem Er
Member
Join Date: Mar 2015
Old 02-16-2018 , 12:39   @red - @blue - @all works with 1 player
Reply With Quote #1

I use Teleport By Name but its older than 9 years for write a new comment there.

When execute teleport command only 1 person beaming. I check also Multiple Targets but i couldn't find anything wrong. What i'm missing?

Code:
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.2"

static String:FileLoc[128];
static bool:FileIn;
static String:MapName[255];

public OnPluginStart()
{
	RegAdminCmd("sm_teleport", TeleportPlayer, ADMFLAG_ROOT, "<name> <destination name> Teleports a player to a location.");
}

public OnMapStart()
{
	GetCurrentMap(MapName, 255);

	BuildPath(Path_SM, FileLoc, 128, "data/telelocs.txt");
	if(!FileExists(FileLoc))
	{
		PrintToServer("[SM] Error: Missing file: %s", FileLoc);
		FileIn = false;
	}
	else
	{
		FileIn = true;
	}
}

public Action:TeleportPlayer(client, Args)
{
	char arg1[32];
	
	if(!FileIn)
	{
		PrintToConsole(client, "[SM] Error: Data file missing.");
		return Plugin_Handled;
	}

	if(Args < 2)
	{
		PrintToConsole(client, "[SM] Usage: sm_teleport <name> <destination name>");
		return Plugin_Handled;
	}

	decl String:TargetName[32];
	decl String:TestName[32];
	decl String:TestString[64];
	decl Target;
	decl String:AdminName[32];
	decl String:LocName[64];

	GetCmdArg(1, TargetName, 32);
	GetCmdArg(2, LocName, 64);

	Target = -1;

	for(new Test = 1; Test <= GetMaxClients(); Test++)
	{
		if(IsClientInGame(Test) && Target == -1)
		{
			GetClientName(Test, TestName, 32);
			
			if(StrContains(TestName, TargetName, false) != -1)
			{
				TargetName = TestName;
				Target = Test;
			}
		}
	}

	char target_name[MAX_TARGET_LENGTH];
	int target_list[MAXPLAYERS], target_count;
	bool tn_is_ml;

	if ((target_count = ProcessTargetString(
			arg1,
			client,
			target_list,
			MAXPLAYERS,
			COMMAND_FILTER_ALIVE, /* Only allow alive players */
			target_name,
			sizeof(target_name),
			tn_is_ml)) <= 0)
	{
		/* This function replies to the admin with a failure message */
		ReplyToTargetError(client, target_count);
		return Plugin_Handled;
	}


	for (new i = 0; i < target_count; i++)
	{
		if(target_list[i] == -1)
		{
			PrintToConsole(client, "[SM] %s is not in-game.", target_name);
			return Plugin_Handled;
		}

		if(!IsPlayerAlive(target_list[i]))
		{
			PrintToConsole(client, "[SM] %s is not alive.", target_name);
			return Plugin_Handled;
		}

		if(client == 0)
		{
			AdminName = "Console";
		}
		else
		{
			GetClientName(client, AdminName, 32);
		}
		
		decl Float:Loc[3];
		decl String:Buffer[3][64];
		decl Handle:Vault;

		Vault = CreateKeyValues("Vault");
		FileToKeyValues(Vault, FileLoc);

		KvJumpToKey(Vault, MapName, true);

		KvGetString(Vault, LocName, TestString, 64, "null");

		KvRewind(Vault);

		CloseHandle(Vault);

		if(StrEqual(TestString, "null"))
		{
			PrintToConsole(client, "[SM] No teleport location for %s.", LocName);
			return Plugin_Handled;
		}
		
		ExplodeString(TestString, " ", Buffer, 3, 64);

		Loc[0] = StringToFloat(Buffer[0]);
		Loc[1] = StringToFloat(Buffer[1]);
		Loc[2] = StringToFloat(Buffer[2]);

		TeleportEntity(target_list[i], Loc, NULL_VECTOR, NULL_VECTOR);

		if(Target != client)
		{
			PrintToConsole(client, "[SM] Teleported %s to %s.", TargetName, LocName);
			PrintToChat(Target, "[SM] %s seni %s bölgesine ışınladı", AdminName, LocName);
		}
		else
		{
			PrintToChat(client, "[SM] Kendini %s bölgesine ışınladın", LocName);
		}
	}

	return Plugin_Handled;
}
Kerem Er is offline
Kerem Er
Member
Join Date: Mar 2015
Old 02-22-2018 , 02:20   Re: @red - @blue - @all works with 1 player
Reply With Quote #2

any idea?
Kerem Er is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 02-22-2018 , 02:30   Re: @red - @blue - @all works with 1 player
Reply With Quote #3

You're declaring arg1... and then never putting anything into it? You're passing a blank string through ProcessTargetString().

Also, you're mixing old and new syntaxes, which is really unnerving.

Also, you're re-parsing the KV file for EVERY SINGLE PLAYER in a given command use, rather than using it once, and only once.

I have no idea what Target is, or what it's supposed to be doing.

This is a mess.
__________________

Last edited by ddhoward; 02-22-2018 at 02:32.
ddhoward 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 22:46.


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