mirror of
https://codeberg.org/spire/setteam.git
synced 2026-06-03 14:24:07 +02:00
force team by steamid
This commit is contained in:
parent
7fb0c5694f
commit
280932c389
1 changed files with 25 additions and 20 deletions
|
|
@ -6,11 +6,11 @@ public Plugin:myinfo = {
|
|||
name = "setteam",
|
||||
author = "Icewind",
|
||||
description = "Set players team",
|
||||
version = "0.1",
|
||||
version = "0.2",
|
||||
url = "https://spire.tf"
|
||||
};
|
||||
|
||||
int force_team[MAXPLAYERS+1];
|
||||
KeyValues force_team;
|
||||
|
||||
public OnPluginStart() {
|
||||
RegServerCmd("sm_setteam", SetTeam, "Set a players team");
|
||||
|
|
@ -18,6 +18,8 @@ public OnPluginStart() {
|
|||
|
||||
AddCommandListener(Command_JoinTeam, "jointeam");
|
||||
AddCommandListener(Command_JoinTeam, "autoteam");
|
||||
|
||||
force_team = new KeyValues("ForceTeam");
|
||||
}
|
||||
|
||||
int parse_team(const char[] team_str) {
|
||||
|
|
@ -36,6 +38,23 @@ int parse_team(const char[] team_str) {
|
|||
return team;
|
||||
}
|
||||
|
||||
void set_force(int client, int team) {
|
||||
char authid[20];
|
||||
GetClientAuthId(client, AuthId_SteamID64, authid, sizeof(authid));
|
||||
if (team == 0) {
|
||||
force_team.DeleteKey(authid);
|
||||
} else {
|
||||
force_team.SetNum(authid, team);
|
||||
}
|
||||
}
|
||||
|
||||
int get_force(int client) {
|
||||
char authid[20];
|
||||
GetClientAuthId(client, AuthId_SteamID64, authid, sizeof(authid));
|
||||
|
||||
return force_team.GetNum(authid, 0);
|
||||
}
|
||||
|
||||
public Action:SetTeam(args) {
|
||||
char player[128];
|
||||
char team_str[128];
|
||||
|
|
@ -58,7 +77,7 @@ public Action:SetTeam(args) {
|
|||
|
||||
int client = FindTarget(0, player, false, true);
|
||||
|
||||
force_team[client] = 0;
|
||||
set_force(client, 0);
|
||||
ChangeClientTeam(client, team);
|
||||
|
||||
return Plugin_Handled;
|
||||
|
|
@ -81,35 +100,21 @@ public Action:ForceExec(args) {
|
|||
int client = FindTarget(0, player, false, true);
|
||||
|
||||
if (team == 0) {
|
||||
force_team[client] = team;
|
||||
set_force(client, team);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ChangeClientTeam(client, team);
|
||||
force_team[client] = team;
|
||||
set_force(client, team);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_JoinTeam(client, const String:command[], argc) {
|
||||
if (force_team[client] > 0) {
|
||||
if (get_force(client) > 0) {
|
||||
return Plugin_Handled;
|
||||
} else {
|
||||
return Plugin_Continue;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClientConnected(client) {
|
||||
force_team[client] = 0;
|
||||
}
|
||||
|
||||
public void OnClientDisconnect(client) {
|
||||
force_team[client] = 0;
|
||||
}
|
||||
|
||||
public OnMapStart() {
|
||||
for (int i = 0; i < MAXPLAYERS; i++) {
|
||||
force_team[i] = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue