Skip to content
This repository was archived by the owner on Oct 30, 2019. It is now read-only.

Commit 77f534b

Browse files
CleversonCleverson
authored andcommitted
Added .surrender command
Added .surrender command ant their configs
1 parent aec8a8f commit 77f534b

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

addons/amxmodx/scripting/PugMenus.sma

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ new g_pHLDSVotes;
2929
new g_pVoteKickPercent;
3030
new g_pVoteKickTeams;
3131
new g_pVoteKickPlayers;
32+
new g_pSurrender;
3233

3334
new g_pMapCycle;
3435

@@ -57,6 +58,9 @@ new g_iPlayers[MAX_PLAYERS];
5758
new g_iVotes[MAX_PLAYERS];
5859
new g_iVoted[MAX_PLAYERS];
5960

61+
new g_iSurrenderVotes[PUG_MAX_TEAMS];
62+
new bool:g_bSurrenderVoted[MAX_PLAYERS];
63+
6064
public plugin_init()
6165
{
6266
register_plugin("Pug Mod (Vote System)",PUG_MOD_VERSION,PUG_MOD_AUTHOR);
@@ -80,13 +84,15 @@ public plugin_init()
8084
g_pVoteKickPercent = create_cvar("pug_vote_kick_percent","60.0",FCVAR_NONE,"Percentage to kick an player using Vote Kick");
8185
g_pVoteKickTeams = create_cvar("pug_vote_kick_teams","1",FCVAR_NONE,"Vote Kick only for teammates");
8286
g_pVoteKickPlayers = create_cvar("pug_vote_kick_players","3",FCVAR_NONE,"Players needed to a Vote Kick");
83-
87+
g_pSurrender = create_cvar("pug_vote_surrender","1",FCVAR_NONE,"Allow a player vote to surrender");
88+
8489
g_pMapCycle = get_cvar_pointer("mapcyclefile");
8590

8691
register_clcmd("vote","HLDS_Vote");
8792
register_clcmd("votemap","HLDS_Vote");
8893

8994
PugRegisterCommand("votekick","fnVoteKick",ADMIN_ALL,"PUG_DESC_VOTEKICK");
95+
PugRegisterCommand("surrender","fnSurrender",ADMIN_ALL,"PUG_DESC_SURRENDER");
9096

9197
PugRegisterAdminCommand("votemap","fnVoteMap",PUG_CMD_LVL,"PUG_DESC_VOTEMAP");
9298
PugRegisterAdminCommand("voteteams","fnVoteTeam",PUG_CMD_LVL,"PUG_DESC_VOTE_TEAMS");
@@ -256,6 +262,9 @@ public PugEventStart()
256262

257263
public PugEventEnd()
258264
{
265+
arrayset(g_iSurrenderVotes,0,sizeof(g_iSurrenderVotes));
266+
arrayset(g_bSurrenderVoted,false,sizeof(g_bSurrenderVoted));
267+
259268
set_pcvar_num(g_pMapVote,1);
260269
}
261270

@@ -761,6 +770,53 @@ public fnvoteKickHandle(id,iMenu,iKey)
761770
return PLUGIN_HANDLED;
762771
}
763772

773+
public fnSurrender(id)
774+
{
775+
if(STAGE_FIRSTHALF <= GET_PUG_STAGE() <= STAGE_OVERTIME)
776+
{
777+
if(get_pcvar_num(g_pSurrender))
778+
{
779+
if(!g_bSurrenderVoted[id])
780+
{
781+
new szTeam[13];
782+
get_user_team(id,szTeam,charsmax(szTeam));
783+
784+
new szName[MAX_NAME_LENGTH];
785+
get_user_name(id,szName,charsmax(szName));
786+
787+
new iTeam = PugGetClientTeam(id);
788+
789+
g_iSurrenderVotes[iTeam]++;
790+
g_bSurrenderVoted[id] = true;
791+
792+
new iPlayers[MAX_PLAYERS],iNum;
793+
get_players(iPlayers,iNum,"eh",szTeam);
794+
795+
client_print_color(id,print_team_red,"%s %L",g_sHead,LANG_SERVER,"PUG_VOTE_SURRENDER",szName,szTeam,g_iSurrenderVotes[iTeam],(iNum / 2));
796+
797+
if(g_iSurrenderVotes[iTeam] >= (iNum / 2))
798+
{
799+
PugEnd(PugGetWinner());
800+
}
801+
}
802+
else
803+
{
804+
client_print_color(id,print_team_red,"%s %L",g_sHead,LANG_SERVER,"PUG_VOTE_SURRENDER_ALREADY");
805+
}
806+
}
807+
else
808+
{
809+
client_print_color(id,print_team_red,"%s %L",g_sHead,LANG_SERVER,"PUG_VOTE_SURRENDER_DISABLED");
810+
}
811+
}
812+
else
813+
{
814+
client_print_color(id,print_team_red,"%s %L",g_sHead,LANG_SERVER,"PUG_VOTE_SURRENDER_LIVE");
815+
}
816+
817+
return PLUGIN_HANDLED;
818+
}
819+
764820
public fnVoteMap(id,iLevel)
765821
{
766822
if(!access(id,PUG_CMD_LVL) && (id != 0))

0 commit comments

Comments
 (0)