Skip to content

Commit

Permalink
README and adminmenu
Browse files Browse the repository at this point in the history
 - Made slight changes to the admin menu.
 - Included the new place command in the admin menu.
 - Added a readme.
  • Loading branch information
N1ckles committed May 20, 2016
1 parent ad9951b commit 5c1409a
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 39 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Teleport
A teleport plugin for SourceMod originally made by zaCade. This should work for all games. All commands support filtering (@aim, @ct, @t, @all, etc.).
## Config
### sm_teleport_noblock
Set this to 1, if the server has player collision disabled, otherwise 0. (**Note:** This does not affect collision)
## Commands
### sm_goto [target]
Teleports you to the target player.
### sm_bring [target(s)]
Teleports the target player(s) to you.
### sm_send [target(s)] [destination]
Teleports all target players to a player (destination).
### sm_place [target(s)]
Teleports all target players to where your cursor is aiming.
140 changes: 101 additions & 39 deletions scripting/sm_teleport.sp
Original file line number Diff line number Diff line change
Expand Up @@ -39,92 +39,104 @@ public void OnAdminMenuReady(Handle topMenu) {
if (g_hAdminMenu != topMenu) {
g_hAdminMenu = topMenu;

TopMenuObject Playercommands = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS);
TopMenuObject hPlayerCommandsCategory = FindTopMenuCategory(g_hAdminMenu, ADMINMENU_PLAYERCOMMANDS);

if (Playercommands != INVALID_TOPMENUOBJECT) {
AddToTopMenu(g_hAdminMenu, "sm_bring", TopMenuObject_Item, Adminmenu_Bring, Playercommands, "sm_bring", ADMFLAG_SLAY);
AddToTopMenu(g_hAdminMenu, "sm_goto", TopMenuObject_Item, Adminmenu_Goto, Playercommands, "sm_goto", ADMFLAG_SLAY);
AddToTopMenu(g_hAdminMenu, "sm_send", TopMenuObject_Item, Adminmenu_Send, Playercommands, "sm_send", ADMFLAG_SLAY);
if (hPlayerCommandsCategory != INVALID_TOPMENUOBJECT) {
AddToTopMenu(g_hAdminMenu, "sm_bring", TopMenuObject_Item, AdminMenu_Bring, hPlayerCommandsCategory, "sm_bring", ADMFLAG_SLAY);
AddToTopMenu(g_hAdminMenu, "sm_goto", TopMenuObject_Item, AdminMenu_GoTo, hPlayerCommandsCategory, "sm_goto", ADMFLAG_SLAY);
AddToTopMenu(g_hAdminMenu, "sm_send", TopMenuObject_Item, AdminMenu_Send, hPlayerCommandsCategory, "sm_send", ADMFLAG_SLAY);
AddToTopMenu(g_hAdminMenu, "sm_place", TopMenuObject_Item, AdminMenu_Place, hPlayerCommandsCategory, "sm_place", ADMFLAG_SLAY);
}
}
}

public void Adminmenu_Bring(Handle topMenu, TopMenuAction Selection, TopMenuObject Object, int Parameter, char[] Buffer, int Maxlength) {
switch(Selection) {
public void AdminMenu_Bring(Handle topMenu, TopMenuAction action, TopMenuObject obj, int client, char[] buffer, int maxlength) {
switch(action) {
case(TopMenuAction_DisplayOption): {
Format(Buffer, Maxlength, "Bring player");
Format(buffer, maxlength, "Bring player");
}
case(TopMenuAction_SelectOption): {
Displaymenu_Bring(Parameter);
Displaymenu_Bring(client);
}
}
}

public void Adminmenu_Goto(Handle topMenu, TopMenuAction Selection, TopMenuObject Object, int Parameter, char[] Buffer, int Maxlength) {
switch(Selection) {
public void AdminMenu_GoTo(Handle topMenu, TopMenuAction action, TopMenuObject obj, int client, char[] buffer, int maxlength) {
switch(action) {
case(TopMenuAction_DisplayOption): {
Format(Buffer, Maxlength, "Goto player");
Format(buffer, maxlength, "Go to player");
}
case(TopMenuAction_SelectOption): {
Displaymenu_Goto(Parameter);
Displaymenu_Goto(client);
}
}
}

public void Adminmenu_Send(Handle topMenu, TopMenuAction Selection, TopMenuObject Object, int Parameter, char[] Buffer, int Maxlength) {
switch(Selection) {
public void AdminMenu_Send(Handle topMenu, TopMenuAction action, TopMenuObject obj, int client, char[] buffer, int maxlength) {
switch(action) {
case(TopMenuAction_DisplayOption): {
Format(buffer, maxlength, "Send player");
}
case(TopMenuAction_SelectOption): {
Displaymenu_Send(client);
}
}
}

public void AdminMenu_Place(Handle topMenu, TopMenuAction action, TopMenuObject obj, int client, char[] buffer, int maxlength) {
switch(action) {
case(TopMenuAction_DisplayOption): {
Format(Buffer, Maxlength, "Send player");
Format(buffer, maxlength, "Place player");
}
case(TopMenuAction_SelectOption): {
Displaymenu_Send(Parameter);
Displaymenu_Place(client);
}
}
}

public void Displaymenu_Bring(int client) {
Handle hMenu = CreateMenu(Commandmenu_Bring);
SetMenuTitle(hMenu, "Bring player:");
SetMenuTitle(hMenu, "Bring player");
SetMenuExitBackButton(hMenu, true);

for (int player = 1; player <= MaxClients; ++player) {
if (client != player && IsClientInGame(player) && IsClientConnected(player) && IsPlayerAlive(player)) {
char Buffer[128], Name[128], UserID[16];
IntToString(GetClientUserId(player), UserID, sizeof(UserID));
GetClientName(player, Name, sizeof(Name));
Format(Buffer, sizeof(Buffer), "%s (%s)", Name, UserID);
AddMenuItem(hMenu, UserID, Buffer);
char buffer[128], name[128], userID[16];
IntToString(GetClientUserId(player), userID, sizeof(userID));
GetClientName(player, name, sizeof(name));
Format(buffer, sizeof(buffer), "%s (%s)", name, userID);
AddMenuItem(hMenu, userID, buffer);
}
}

DisplayMenu(hMenu, client, MENU_TIME_FOREVER);
}

public void Displaymenu_Goto(int Client) {
public void Displaymenu_Goto(int client) {
Handle hMenu = CreateMenu(Commandmenu_Goto);
SetMenuTitle(hMenu, "Goto player:");
SetMenuExitBackButton(hMenu, true);

for (int Player = 1; Player <= MaxClients; Player++) {
if (Client != Player && IsClientInGame(Player) && IsClientConnected(Player) && IsPlayerAlive(Player)) {
char Buffer[128], Name[128], UserID[16];
IntToString(GetClientUserId(Player), UserID, sizeof(UserID));
GetClientName(Player, Name, sizeof(Name));
Format(Buffer, sizeof(Buffer), "%s (%s)", Name, UserID);
AddMenuItem(hMenu, UserID, Buffer);
for (int player = 1; player <= MaxClients; ++player) {
if (client != player && IsClientInGame(player) && IsClientConnected(player) && IsPlayerAlive(player)) {
char buffer[128], name[128], userID[16];
IntToString(GetClientUserId(player), userID, sizeof(userID));
GetClientName(player, name, sizeof(name));
Format(buffer, sizeof(buffer), "%s (%s)", name, userID);
AddMenuItem(hMenu, userID, buffer);
}
}

DisplayMenu(hMenu, Client, MENU_TIME_FOREVER);
DisplayMenu(hMenu, client, MENU_TIME_FOREVER);
}

public void Displaymenu_Send(int Client) {
public void Displaymenu_Send(int client) {
Handle hMenu = CreateMenu(Commandmenu_Send);
SetMenuTitle(hMenu, "Send player:");
SetMenuExitBackButton(hMenu, true);

for (int Player = 1; Player <= MaxClients; Player++) {
if (Client != Player && IsClientInGame(Player) && IsClientConnected(Player) && IsPlayerAlive(Player)) {
if (client != Player && IsClientInGame(Player) && IsClientConnected(Player) && IsPlayerAlive(Player)) {
char Buffer[128], Name[128], UserID[16];
IntToString(GetClientUserId(Player), UserID, sizeof(UserID));
GetClientName(Player, Name, sizeof(Name));
Expand All @@ -133,12 +145,12 @@ public void Displaymenu_Send(int Client) {
}
}

DisplayMenu(hMenu, Client, MENU_TIME_FOREVER);
DisplayMenu(hMenu, client, MENU_TIME_FOREVER);
}

public void Displaymenu_SendTo(int Client) {
Handle hMenu = CreateMenu(Commandmenu_SendTo);
SetMenuTitle(hMenu, "Send player: %N", g_aiSendTargets[Client]);
SetMenuTitle(hMenu, "Send %N to:", g_aiSendTargets[Client]);
SetMenuExitBackButton(hMenu, true);

for (int Player = 1; Player <= MaxClients; Player++) {
Expand All @@ -154,6 +166,24 @@ public void Displaymenu_SendTo(int Client) {
DisplayMenu(hMenu, Client, MENU_TIME_FOREVER);
}

public void Displaymenu_Place(int client) {
Handle hMenu = CreateMenu(Commandmenu_Place);
SetMenuTitle(hMenu, "Place a player at your aim:");
SetMenuExitBackButton(hMenu, true);

for (int player = 1; player <= MaxClients; ++player) {
if (client != player && IsClientInGame(player) && IsClientConnected(player) && IsPlayerAlive(player)) {
char buffer[128], name[128], userID[16];
IntToString(GetClientUserId(player), userID, sizeof(userID));
GetClientName(player, name, sizeof(name));
Format(buffer, sizeof(buffer), "%s (%s)", name, userID);
AddMenuItem(hMenu, userID, buffer);
}
}

DisplayMenu(hMenu, client, MENU_TIME_FOREVER);
}

public int Commandmenu_Bring(Menu hMenu, MenuAction Selection, int Parameter1, int Parameter2) {
switch(Selection) {
case(MenuAction_End): {
Expand Down Expand Up @@ -308,6 +338,34 @@ public Action Command_Bring(int Client, int ArgC) {
return Plugin_Handled;
}

public int Commandmenu_Place(Menu hMenu, MenuAction Selection, int Parameter1, int Parameter2) {
switch(Selection) {
case(MenuAction_End): {
CloseHandle(hMenu);
}
case(MenuAction_Cancel): {
DisplayTopMenu(g_hAdminMenu, Parameter1, TopMenuPosition_LastCategory);
}
case(MenuAction_Select): {
char Info[64];
GetMenuItem(hMenu, Parameter2, Info, sizeof(Info));
int Target = GetClientOfUserId(StringToInt(Info));

if (Target <= 0) {
ReplyToCommand(Parameter1, "[SM] Unable to find target.");
} else if (!CanUserTarget(Parameter1, Target)) {
ReplyToCommand(Parameter1, "[SM] Unable to target.");
} else if (!IsPlayerAlive(Target)) {
ReplyToCommand(Parameter1, "[SM] Player no longer alive.");
} else {
PerformTeleportToAim(Parameter1, Target);
LogAction(Parameter1, -1, "\"%L\" teleported \"%L\" to his aim.", Parameter1, Target);
ShowActivity(Parameter1, "teleported %N to his aim.", Target);
}
}
}
}

public Action Command_Place(int Client, int ArgC) {
if (ArgC <= 0) {
ReplyToCommand(Client, "[SM] Usage: sm_place <name>");
Expand Down Expand Up @@ -496,10 +554,14 @@ public bool GetAimDestination(int client, float destination[3]){
return false;
}

public void PerformTeleportToAim(int client) {
public void TeleportClientToAim(int client) {
PerformTeleportToAim(client, client);
}

public void PerformTeleportToAim(int aimer, int target) {
float dst[3];
if(GetAimDestination(client, dst)){
TeleportEntity(client, dst, NULL_VECTOR, NULL_VECTOR);
if(GetAimDestination(aimer, dst)){
TeleportEntity(target, dst, NULL_VECTOR, NULL_VECTOR);
}

}
Expand Down

0 comments on commit 5c1409a

Please sign in to comment.