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;
}