forked from TheVilleOrg/sourcemod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamswap.sp
71 lines (57 loc) · 1.63 KB
/
teamswap.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <sourcemod>
#include <sdktools_functions>
#pragma semicolon 1
#define PLUGIN_VERSION "1.0"
public Plugin:myinfo =
{
name = "Team Swap",
author = "Stevo.TVR",
description = "Swaps players' team",
version = PLUGIN_VERSION,
url = "http://www.theville.org/"
}
#define TEAM1 1
#define TEAM2 2
public OnPluginStart()
{
CreateConVar("sm_teamswap_version", PLUGIN_VERSION, "Team Swap version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
RegAdminCmd("sm_teamswap", CommandTeamSwap, ADMFLAG_KICK, "Swaps player's team");
LoadTranslations("core.phrases");
LoadTranslations("common.phrases");
}
public Action:CommandTeamSwap(client, args)
{
if(args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_teamswap <#userid|name>");
return Plugin_Handled;
}
new String:target[64], String:target_name[MAX_TARGET_LENGTH];
new targetArray[MAXPLAYERS];
new numtargets;
new bool:tn_is_ml;
GetCmdArg(1, target, sizeof(target));
numtargets = ProcessTargetString(target, client, targetArray, MAXPLAYERS, 0, target_name, sizeof(target_name), tn_is_ml);
if(numtargets <= 0)
{
ReplyToTargetError(client, numtargets);
return Plugin_Handled;
}
for(new i = 0; i < numtargets; i++)
{
if(IsClientInGame(targetArray[i]))
switchPlayerTeam(client, targetArray[i]);
}
return Plugin_Handled;
}
public switchPlayerTeam(client, target)
{
LogAction(client, target, "\"%L\" swapped team of \"%L\"", client, target);
ShowActivity(client, "swapped team of %N", target);
new team = GetClientTeam(target);
if(team == TEAM1)
ChangeClientTeam(target, TEAM2);
if(team == TEAM2)
ChangeClientTeam(target, TEAM1);
DispatchSpawn(target);
}