PHP Code:
#define PLUGIN_AUTHOR "Klaus"
#define PLUGIN_VERSION "1.00"
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>
public Plugin myinfo =
{
name = "MoveTeam",
author = PLUGIN_AUTHOR,
description = "Allows admins to change players team",
version = PLUGIN_VERSION,
url = "https://steamcommunity.com/id/KlausLaw/"
};
public void OnPluginStart()
{
RegAdminCmd("sm_move", SM_Move, ADMFLAG_BAN);
}
public Action SM_Move(int client, int args)
{
openPlayersMenu(client);
return Plugin_Handled;
}
void openPlayersMenu(int client)
{
Menu menu = new Menu(Menu_PlayersList);
menu.SetTitle("[MoveTeam] - Select a player\n \n");
char sInfo[12], sName[MAX_NAME_LENGTH];
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i))continue;
IntToString(i, sInfo, sizeof(sInfo));
GetClientName(i, sName, sizeof(sName));
menu.AddItem(sInfo, sName);
}
menu.Display(client, MENU_TIME_FOREVER);
}
public int Menu_PlayersList(Menu menu, MenuAction action, int client, int Position)
{
if (action == MenuAction_Select)
{
char item[12];
menu.GetItem(Position, item, sizeof(item));
int target = StringToInt(item);
char sInfo[24];
Menu moveMenu = new Menu(Menu_MoveMenu);
moveMenu.SetTitle("[MoveTeam] - Select a team\n \n");
Format(sInfo, sizeof(sInfo), "%d-3", target);
moveMenu.AddItem(sInfo, "CT Team");
Format(sInfo, sizeof(sInfo), "%d-2", target);
moveMenu.AddItem(sInfo, "T Team");
Format(sInfo, sizeof(sInfo), "%d-1", target);
moveMenu.AddItem(sInfo, "Spec Team");
moveMenu.Display(client, MENU_TIME_FOREVER);
}
if (action == MenuAction_End)
{
delete menu;
}
}
public int Menu_MoveMenu(Menu menu, MenuAction action, int client, int Position)
{
if (action == MenuAction_Select)
{
char infoExploded[2][12];
char item[24];
menu.GetItem(Position, item, sizeof(item));
ExplodeString(item, "-", infoExploded, sizeof(infoExploded), sizeof(infoExploded[]));
int target = StringToInt(infoExploded[0]);
int team = StringToInt(infoExploded[1]);
ChangeClientTeam(target, team);
}
if (action == MenuAction_Cancel)
{
openPlayersMenu(client);
}
if (action == MenuAction_End)
{
delete menu;
}
}
Here you go, if you hit exit on the "Select a team" menu, you will be redirected to the main menu.
__________________