inital commit
This commit is contained in:
167
ctf_bball2_arena.sp
Normal file
167
ctf_bball2_arena.sp
Normal file
@@ -0,0 +1,167 @@
|
||||
/* Plugin Template generated by Pawn Studio */
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include <tf2>
|
||||
#include <tf2_stocks>
|
||||
|
||||
new teamnum[MAXPLAYERS+1], arenanum[MAXPLAYERS+1], anzplayinteam[4][4], Float:newdest[MAXPLAYERS+1][3];
|
||||
new Float:arena_z = 68.0;
|
||||
new String:path[PLATFORM_MAX_PATH];
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "CTF_BBALL2_ARENA",
|
||||
author = "Chefe",
|
||||
description = "<no>",
|
||||
version = "1.0",
|
||||
url = "<<< www.the-bos.de >>>"
|
||||
}
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
HookEvent("player_team", Event_PlayerTeam, EventHookMode_Pre);
|
||||
HookEvent("player_death", Event_PlayerDeath);
|
||||
RegConsoleCmd("sm_join", Command_Join, "Join an Arena");
|
||||
|
||||
BuildPath(Path_SM, path, sizeof(path), "configs/dest.txt");
|
||||
}
|
||||
|
||||
public Action:Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new userid = GetEventInt(event, "userid");
|
||||
new client = GetClientOfUserId(userid);
|
||||
SetEventBool(event, "silent", true);
|
||||
|
||||
if (GetEventInt(event, "team") != teamnum[client])
|
||||
{
|
||||
CreateTimer(0.1, ChangeTeam, client);
|
||||
}
|
||||
|
||||
return Plugin_Changed;
|
||||
}
|
||||
|
||||
public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new userid = GetEventInt(event, "userid");
|
||||
new client = GetClientOfUserId(userid);
|
||||
|
||||
PerformPlayerSpawn(arenanum[client], teamnum[client], client, 2.0);
|
||||
}
|
||||
|
||||
public Action:ChangeTeam(Handle:timer, any:client)
|
||||
{
|
||||
new team = 1;
|
||||
if (teamnum[client] != 0)
|
||||
{
|
||||
team = teamnum[client]
|
||||
}
|
||||
ChangeClientTeam(client, team);
|
||||
PrintToChat(client, "[BBA] Select Arena with !join");
|
||||
}
|
||||
|
||||
public Action:Command_Join(client, args)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler1);
|
||||
SetMenuTitle(menu, "Join Arena");
|
||||
AddMenuItem(menu, "1", "Arena 1");
|
||||
AddMenuItem(menu, "2", "Arena 2");
|
||||
AddMenuItem(menu, "3", "Arena 3");
|
||||
AddMenuItem(menu, "4", "Arena 4");
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public MenuHandler1(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_Select)
|
||||
{
|
||||
new String:info[32];
|
||||
|
||||
/* Get item info */
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
|
||||
switch (StringToInt(info))
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
PerformArenaJoin(0, param1);
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
PerformArenaJoin(1, param1);
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
PerformArenaJoin(2, param1);
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
PerformArenaJoin(3, param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action:RespawnClient(Handle:timer, any:client)
|
||||
{
|
||||
TF2_RespawnPlayer(client);
|
||||
}
|
||||
|
||||
public Action:TeleportClient(Handle:timer, any:client)
|
||||
{
|
||||
TeleportEntity(client, newdest[client], NULL_VECTOR, NULL_VECTOR);
|
||||
}
|
||||
|
||||
FindPerfektTeam(arena)
|
||||
{
|
||||
new anzblu = anzplayinteam[arena][3]
|
||||
new anzred = anzplayinteam[arena][2]
|
||||
|
||||
if (anzblu > anzred)
|
||||
{
|
||||
return 2;
|
||||
} else if (anzblu < anzred) {
|
||||
return 3;
|
||||
} else if (anzred == anzblu) {
|
||||
return GetRandomInt(2, 3);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
PerformArenaJoin(arena, client)
|
||||
{
|
||||
ForcePlayerSuicide(client);
|
||||
new newteam = FindPerfektTeam(0);
|
||||
|
||||
teamnum[client] = newteam;
|
||||
arenanum[client] = arena;
|
||||
ChangeClientTeam(client, newteam);
|
||||
anzplayinteam[arena][newteam] = anzplayinteam[arena][newteam] + 1;
|
||||
TF2_SetPlayerClass(client, TFClass_Soldier, false, true);
|
||||
|
||||
PerformPlayerSpawn(arena, newteam, client, 0.0);
|
||||
}
|
||||
|
||||
PerformPlayerSpawn(arena, team, client, Float:spawntime)
|
||||
{
|
||||
new Handle:kv = CreateKeyValues("ArenaDest");
|
||||
FileToKeyValues(kv, path)
|
||||
KvJumpToKey(kv, "y", false);
|
||||
|
||||
new String:strteam[5], String:strarena[5];
|
||||
IntToString(team, strteam, sizeof(strteam));
|
||||
IntToString(arena, strarena, sizeof(strarena));
|
||||
newdest[client][1] = KvGetFloat(kv, strteam, 0.0);
|
||||
KvGoBack(kv);
|
||||
KvJumpToKey(kv, "x");
|
||||
KvJumpToKey(kv, strarena);
|
||||
newdest[client][0] = GetRandomFloat(KvGetFloat(kv, "min"), KvGetFloat(kv, "max"));
|
||||
newdest[client][2] = arena_z;
|
||||
|
||||
CloseHandle(kv);
|
||||
|
||||
CreateTimer(FloatAdd(spawntime, 0.2), RespawnClient, client);
|
||||
CreateTimer(FloatAdd(spawntime, 0.3), TeleportClient, client);
|
||||
}
|
||||
|
Reference in New Issue
Block a user