|
SourceMod Donor
|

04-09-2009
, 17:01
Re: [REQ] AMMOMOD Clone for TF2, most already finished.
|
#9
|
I've done this awhile ago for thenoid. The ammomod portion of the mod is very easy to re-create since you would only need to decrypt a few scripts, change some values, and then re-encrypt them. The part that you request is considered the "Duel Mod" portion of the mod and can be found here:
http://forums.alliedmods.net/showthread.php?t=80799
However, the code in the last post doesn't work correctly and doesn't include the queuing system that you want. So here is a hopefully working backup of the latest version of the classic Duel Mod with one arena only:
Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>
#define TEAM_SPEC 1
#define TEAM_RED 2
#define TEAM_BLUE 3
new Handle:g_hTeamLimit
new Handle:g_hEnableTeamLimit
new Handle:g_hFragLimit
new Handle:g_hEnableQueue
new Handle:g_hHostname
new Handle:TeamTimer[MAXPLAYERS]
new Handle:AdvertiseTimer[MAXPLAYERS]
new Handle:ScoreTimer
new g_Duelers[4]
new Handle:g_ctf
new Handle:g_hQueue
new g_loser
new losetime
public Plugin:myinfo =
{
name = "TF2 Duel Tools",
author = "noobcannonlol",
description = "For use on duel maps",
version = "1.0",
url = "gamesyn.com"
}
public OnPluginStart()
{
g_hEnableTeamLimit = CreateConVar("mp_enableteamlimit", "1", "1 (on) or 0 (off)")
g_hTeamLimit = CreateConVar("mp_teamlimit", "1", "Limit teams to this value")
g_hEnableQueue = CreateConVar("mp_enablequeue", "1", "Enable the dueling queue")
g_hFragLimit = FindConVar("mp_fraglimit")
g_hHostname = FindConVar("hostname")
HookEvent("player_team", Event_PlayerTeam, EventHookMode_Pre)
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre)
HookEvent("teamplay_round_start", RoundStartEvent)
HookEvent("player_hurt", Event_PlayerHurt)
HookEvent("teamplay_point_captured", Event_PointCapture, EventHookMode_Pre)
g_hQueue = CreateArray(33)
RegConsoleCmd("say", Command_Say)
}
public OnClientDisconnect_Post(client)
{
RemovePlayerFromQueue(client)
CreateTimer(1.0, CheckGame)
}
public Action:Command_Say(client, args)
{
new String:text[192]
GetCmdArg(1, text, sizeof(text))
new String:arg[8]
GetCmdArg(2, arg, sizeof(arg))
if (IsQueueOn())
{
if (StrEqual(text, "!add"))
{
AddPlayerToQueue(client)
return Plugin_Handled
}
else if (StrEqual(text, "!remove"))
{
RemovePlayerFromQueue(client)
return Plugin_Handled
}
else if(StrEqual(text, "!queue"))
{
PrintQueue()
return Plugin_Handled
}
else if (StrEqual(text, "!duelhelp"))
{
ShowHelpPanel(client)
return Plugin_Handled
}
}
return Plugin_Continue
}
public Event_PointCapture(Handle:event, const String:name[], bool:dontBroadcast)
{
return Plugin_Handled
}
public OnClientPutInServer(client)
{
new Handle:pack
AdvertiseTimer[client] = CreateDataTimer(10.0, Advertise, pack)
WritePackCell(pack, client)
}
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new userid = GetEventInt(event, "userid")
new client = GetClientOfUserId(userid)
if (!IsClientInGame(client) || IsFakeClient(client))
return Plugin_Continue
SetHudTextParams(0.01, 0.8, 5.0, 255, 255, 255, 255)
ShowHudText(client, 3, "Health: %d", GetClientHealth(client))
new red_dueler = GetDueler(TEAM_RED)
new blue_dueler = GetDueler(TEAM_BLUE)
if ((red_dueler == 0) || (blue_dueler == 0))
return Plugin_Continue
new String:red_dueler_name[32]
new String:blue_dueler_name[32]
GetClientName(red_dueler, red_dueler_name, sizeof(red_dueler_name))
GetClientName(blue_dueler, blue_dueler_name, sizeof(blue_dueler_name))
for (new i = 1; i <= GetMaxClients(); i++)
{
if (IsClientInGame(i) && (GetClientTeam(i) == TEAM_SPEC))
{
ShowHudText(i, 3, "%s Health: %d\n%s Health: %d", blue_dueler_name, GetClientHealth(blue_dueler), red_dueler_name, GetClientHealth(red_dueler))
}
}
return Plugin_Continue
}
public RoundStartEvent(Handle:event, const String:name[], bool:dontBroadcast)
{
g_ctf = CreateEntityByName("game_round_win")
DispatchSpawn(g_ctf)
}
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new attacker_id = GetEventInt(event, "attacker")
new attacker = GetClientOfUserId(attacker_id)
new victim_id = GetEventInt(event, "userid")
new victim = GetClientOfUserId(victim_id)
PrintToChat(victim, "Your killer still has %d health.", GetClientHealth(attacker))
for (new i = 1; i <= GetMaxClients(); i++)
{
if (IsClientInGame(i) && (GetClientTeam(i) > TEAM_SPEC))
{
TF2_SetPlayerResourceData(i, TFResource_TotalScore, GetClientFrags(i))
TF2_SetPlayerResourceData(i, TFResource_Score, GetClientFrags(i))
}
}
SetEventBool(event, "dominated", false)
SetEventBool(event, "revenge", false)
if (GetFragLimit() == 0)
return Plugin_Continue
CreateTimer(0.1, CheckFrags)
return Plugin_Continue
}
public Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
if (!GetConVarBool(g_hEnableTeamLimit))
return Plugin_Continue
new userId = GetEventInt(event, "userid")
new oldteam = GetEventInt(event, "oldteam")
new newteam = GetEventInt(event, "team")
new player = GetClientOfUserId(userId)
if ((newteam == TEAM_RED) || (newteam == TEAM_BLUE))
{
if (IsQueueOn() && (g_Duelers[newteam] != player))
{
PrintToChat(player, "[Duel Mod] Wait your turn!")
new Handle:pack
TeamTimer[player] = CreateDataTimer(0.1, ChangeTeam, pack)
WritePackCell(pack, player)
WritePackCell(pack, TEAM_SPEC)
return Plugin_Handled
}
else if (GetTeamClientCount(newteam) >= GetTeamLimit())
{
PrintToChat(player, "[Duel Mod] That team is full!")
new Handle:pack
TeamTimer[player] = CreateDataTimer(0.1, ChangeTeam, pack)
WritePackCell(pack, player)
WritePackCell(pack, TEAM_SPEC)
return Plugin_Handled
}
//else if (player == g_loser && (GetGameTime() <= (losetime + 10.0)))
//{
// PrintToChat(g_loser, "[Duel Mod] Losers have to wait 10 seconds before they can join a duel")
//}
}
return Plugin_Continue
}
public GetTeamFragCount(team)
{
new fragcount = 0
for (new i = 1; i <= GetMaxClients(); i++)
{
if(IsClientConnected(i) && IsClientInGame(i) && (GetClientTeam(i) == team))
{
fragcount += TF2_GetPlayerResourceData(i, TFResource_Score)
}
}
return fragcount
}
public GetTeamLimit()
{
return GetConVarInt(g_hTeamLimit)
}
public GetFragLimit()
{
return GetConVarInt(g_hFragLimit)
}
public EndRound(winner)
{
new String:name[32]
GetTeamName(winner, name, sizeof(name))
SetVariantInt(0)
AcceptEntityInput(g_ctf, "SetTeam")
AcceptEntityInput(g_ctf, "RoundWin")
PrintCenterTextAll("First to %d frags is %s! Restarting game...", GetFragLimit(), name)
ServerCommand("mp_restartgame 10")
new loser
for(new i = 1; i <= GetMaxClients(); i++)
{
if (IsClientInGame(i))
{
new team = GetClientTeam(i)
if ((team != winner) && (team != TEAM_SPEC))
{
loser = i
g_loser = loser
losetime = GetGameTime()
new Handle:pack
TeamTimer[loser] = CreateDataTimer(5.0, ChangeTeam, pack)
WritePackCell(pack, loser)
WritePackCell(pack, TEAM_SPEC)
}
}
}
}
public GetDueler(team)
{
for (new i = 1; i <= GetMaxClients();i++)
{
if (IsClientInGame(i) && (GetClientTeam(i) == team))
{
return i
}
}
return 0
}
public IsQueueOn()
{
return GetConVarBool(g_hEnableQueue)
}
public PrintQueue()
{
new String:buffer[384]
StrCat(buffer, sizeof(buffer), "[Duel Mod] Waiting in line: ")
if(GetArraySize(g_hQueue == 0))
{
StrCat(buffer, sizeof(buffer), "No one!")
}
else
{
for(new i = 0; i < 33; i++)
{
new client = GetArrayCell(g_hQueue, i)
if (IsClientConnected(client))
{
new String:name[40]
GetClientName(client, name, sizeof(name))
TrimString(name)
StrCat(buffer, sizeof(buffer), name)
StrCat(buffer, sizeof(buffer), " - ")
}
}
}
PrintToChatAll(buffer)
}
public PushPlayerQueue(team)
{
if(GetArraySize(g_hQueue) == 0)
return
new client = GetArrayCell(g_hQueue, 0)
if (client)
{
g_Duelers[team] = client
ChangeClientTeam(client, team)
RemovePlayerFromQueue(client)
new String:name[32]
GetClientName(client, name, sizeof(name))
TrimString(name)
PrintToChatAll("[Duel Mod] %s has joined the duel.", name)
TF2_SetPlayerClass(client, TFClass_Soldier)
}
}
public AddPlayerToQueue(client)
{
if(IsPlayerInQueue(client))
{
return
}
PushArrayCell(g_hQueue, client)
PrintQueue()
CreateTimer(1.0, CheckGame)
}
public RemovePlayerFromQueue(client)
{
if(IsPlayerInQueue(client))
{
RemoveFromArray(g_hQueue, FindValueInArray(g_hQueue, client))
}
}
public IsPlayerInQueue(client)
{
if(FindValueInArray(g_hQueue, client) > -1)
{
return true
}
else
{
return false
}
}
public Action:ChangeTeam(Handle:timer, Handle:pack)
{
new client, team
ResetPack(pack)
client = ReadPackCell(pack)
team = ReadPackCell(pack)
ChangeClientTeam(client, team)
CreateTimer(1.0, CheckGame)
TeamTimer[client] = INVALID_HANDLE
}
public Action:CheckGame(Handle:timer)
{
//PrintToServer("Checking duel status...")
if(GetTeamClientCount(TEAM_BLUE) < GetTeamLimit())
{
PushPlayerQueue(TEAM_BLUE)
}
else if (GetTeamClientCount(TEAM_RED) < GetTeamLimit())
{
PushPlayerQueue(TEAM_RED)
}
}
public Action:CheckFrags(Handle:timer)
{
if (GetTeamFragCount(TEAM_RED) >= GetFragLimit())
EndRound(TEAM_RED)
if (GetTeamFragCount(TEAM_BLUE) >= GetFragLimit())
EndRound(TEAM_BLUE)
}
public Action:Advertise(Handle:timer, Handle:pack)
{
new client
ResetPack(pack)
client = ReadPackCell(pack)
PrintToChat(client, "[SM] This server is running Duel Mod by noobcannonlol. Type !help for commands.")
ShowHelpPanel(client)
}
public ShowHelpPanel(client)
{
new Handle:panel = CreatePanel()
DrawPanelItem(panel, "Ammo mod by thenoid", ITEMDRAW_RAWLINE)
DrawPanelItem(panel, "Duel mod by noobcannonlol", ITEMDRAW_RAWLINE)
DrawPanelItem(panel, "Play 1v1 duels with a queueing system here", ITEMDRAW_RAWLINE)
DrawPanelItem(panel, "!add", ITEMDRAW_RAWLINE)
DrawPanelItem(panel, "!remove", ITEMDRAW_RAWLINE)
DrawPanelItem(panel, "!queue", ITEMDRAW_RAWLINE)
DrawPanelItem(panel, "!duelhelp", ITEMDRAW_RAWLINE)
SetPanelKeys(panel, 2^9)
SendPanelToClient(panel, client, NullPanelHandler, 10.0)
CloseHandle(panel)
}
public NullPanelHandler(Handle:menu, MenuAction:action, param1, param2)
{
}
You can donate money if you appreciate it that much but I don't mind since I don't need any  .
EDIT: just noticed a lot of useless and unorganized code in there but whatever
Last edited by noob cannon lol; 04-09-2009 at 17:09.
|
|