-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1v1.sma
141 lines (122 loc) · 3.8 KB
/
1v1.sma
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <tfcx>
#define PLUGIN "1v1"
#define VERSION "1.0"
#define AUTHOR "msouz"
new killgoal;
new playerReady[32];
new numPlayerReady;
new gameON = 0;
new playerKills[32];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
//RegisterHam(Ham_Killed, "player", "hamPlayerKilled", 1);
killgoal = register_cvar("kill_goal","50");
register_event( "DeathMsg", "death", "a" );
register_clcmd("say", "ready");
}
public plugin_precache()
{
precache_generic("sound/fight.mp3")
precache_generic("sound/victory.mp3")
}
public ready(id)
{
if(gameON == 0){
new buffer[256];
new buffer1[33];
new buffer2[33];
new name[32];
get_user_name(id, name, 31);
read_argv(1, buffer, 255);
parse(buffer, buffer1, 32, buffer2, 32);
new teamCheck;
teamCheck = get_user_team(id)
if (equali(buffer1, "!ready", 0))
{
// Check if player is on a team
if (teamCheck != 1 && teamCheck != 2){
client_print(0, print_chat, "You must be on a team to ready up")
return 0;
}
// Check if a player has already readied up
if (playerReady[id] == 1 || playerReady[id] == 2){
client_print(0, print_chat, "You have already readied up!")
return 0;
}
//code for ready up
if(numPlayerReady == 0){
playerReady[id] = 1;
client_print(0, print_chat, "%s is ready", name);
numPlayerReady++;
}
else if(numPlayerReady == 1){
client_print(0, print_chat, "%s is ready", name);
client_print(0, print_chat, "***PREPARE TO FIGHT****");
playerReady[id] = 2;
slayPlayers();
client_cmd(0,"mp3 play sound/fight.mp3"); //plays countdown
}
}
}
return 0;
}
public slayPlayers(){
//will kill players that have readied up
for(new i = 0; i < 32; ++i)
{
if(playerReady[i] > 0){
new name[32]
get_user_name(i, name, 31);
//client_print(0, print_chat, "***PREPARE TO FIGHT****");
server_cmd("amx_slay %s",name);
}
}
set_task(3.0, "turngameON", 0, "", 0, "a", 1); //needs to be a delay for the gameON function so that players dont lose a kill when the server kills them to start.
}
public turngameON(){
//needs to be a delay for the gameON function so that players dont lose a kill when the server kills them to start.
gameON = 1;
}
public death() {
if(gameON){
//client_print(0, print_chat, "test");
new attacker = read_data(1);
new victim = read_data(2);
new aname[32], vname[32];
new winningTeam;
get_user_name(attacker, aname, 31);
get_user_name(victim, vname, 31);
if(attacker == victim){
playerKills[victim]--;
client_print(0, print_chat, "%s killed themselves and now has %d kills", vname, playerKills[victim]);
}
else if (attacker == 0){
playerKills[victim]--;
client_print(0, print_chat, "%s died to fall damage and now has %d kills", vname, playerKills[victim]);
}
else if(attacker != victim){
playerKills[attacker]++;
client_print(0, print_chat, "%s %d - %s %d", aname, playerKills[attacker], vname, playerKills[victim]);
}
if(playerKills[attacker] == get_pcvar_num(killgoal)) {
winningTeam = get_user_team(attacker)
log_message("[1v1 MATCH RESULT] Team %d Wins %s %d %s %d", winningTeam, aname, playerKills[attacker], vname, playerKills[victim])
client_print(0, print_chat, "%s HAS WON THE MATCH", aname);
client_cmd(0,"mp3 play sound/victory.mp3");
server_cmd("mp_timelimit 1");
gameON = 0;
playerReady[attacker] = 0
playerReady[victim] = 0
playerKills[attacker] = 0
playerKills[victim] = 0
}
}
return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/