-
Notifications
You must be signed in to change notification settings - Fork 1
/
td_givegold.sma
272 lines (214 loc) · 6.55 KB
/
td_givegold.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <td>
#include <ColorChat>
#define PLUGIN "Tower Defense: GiveGold"
#define VERSION "1.0 Beta"
#define AUTHOR "GT Team"
#define CHAT_PREFIX "[TD]"
new iPlayerTarget[33];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /daj", "Menu")
register_clcmd("say /przekaz", "Menu")
register_clcmd("say /give", "Menu")
register_clcmd("say /send", "Menu")
register_clcmd("givegold", "Menu")
register_clcmd("gold_ammount", "GiveGold")
register_clcmd("gold_ammount_admin", "GiveGoldAdmin", ADMIN_CVAR)
}
public Menu(id)
{
if((get_user_flags(id) & ADMIN_CVAR))
goto toMenu
if(!is_user_alive(id))
return
if(td_get_user_info(id, PLAYER_GOLD) <= 0) {
ColorChat(id, GREEN, "%s^x01 Nie mozesz wyslac zlota, poniewaz nic nie masz!", CHAT_PREFIX)
return
}
if(get_playersnum() == 0) {
ColorChat(id, GREEN, "%s Jestes sam!", CHAT_PREFIX)
return
}
toMenu:
new menu = menu_create("", "MenuH")
new szName[33]
new szData[3]
for(new i = 1; i < 33; i++) {
if(!is_user_alive(i) || is_user_hltv(i))
continue
/* Nie pokazuj swojego nicku w menu*/
if(!(get_user_flags(id) & ADMIN_CVAR) && i == id)
continue ;
get_user_name(i, szName, 32)
num_to_str(i, szData, 2)
menu_additem(menu, szName, szData)
}
menu_display(id, menu)
}
public MenuH(id, menu, item)
{
if(item == MENU_EXIT || !is_user_alive(id)) {
menu_destroy(menu)
return
}
new acces,cb, szData[3], szTarget[33], szTitle[70]
menu_item_getinfo(menu, item, acces, szData, 2, szTarget, 32, cb)
formatex(szTitle, charsmax(szTitle), "Wybrany gracz: \r%s^n\wIle chcesz mu wyslac?", szTarget)
new iMenu = menu_create(szTitle, "Menu2H")
new callback = menu_makecallback("Menu2Cb")
menu_additem(iMenu, "5", szData,_, callback)
menu_additem(iMenu, "10", szTarget,_, callback)
menu_additem(iMenu, "25",_,_, callback)
menu_additem(iMenu, "50",_,_, callback)
menu_additem(iMenu, "100",_,_, callback)
menu_additem(iMenu, "Wpisz",_,_, callback)
menu_additem(iMenu, "Admin Menu",_,ADMIN_CVAR)
menu_display(id, iMenu)
}
public Menu2Cb(id, menu, item)
{
new gold = td_get_user_info(id, PLAYER_GOLD)
if(item == 0 && gold < 5) return ITEM_DISABLED
else if(item == 1 && gold < 10) return ITEM_DISABLED
else if(item == 2 && gold < 25) return ITEM_DISABLED
else if(item == 3 && gold < 50) return ITEM_DISABLED
else if(item == 4 && gold < 100) return ITEM_DISABLED
else if(item == 5 && gold < 1) return ITEM_DISABLED
return ITEM_ENABLED
}
public Menu2H(id, menu, item)
{
if(item == MENU_EXIT || !is_user_alive(id)) {
menu_destroy(menu)
return
}
new acces,cb, szData[3], szTarget[33], szTemp[2]
menu_item_getinfo(menu, 1, acces, szTemp, 1, szTarget, 32, cb)
menu_item_getinfo(menu, 0, acces, szData, 2, szTemp, 1, cb)
new id2 = iPlayerTarget[id] = str_to_num(szData)
if(item == 0) {
ChangeGold(id, id2, 5, 0)
}
else if(item == 1) {
ChangeGold(id, id2, 10, 0)
}
else if(item == 2) {
ChangeGold(id, id2, 25, 0)
}
else if(item == 3) {
ChangeGold(id, id2, 50, 0)
}
else if(item == 4) {
ChangeGold(id, id2, 100, 0)
}
else if(item == 5) {
client_print(id, print_center, "Wpisz ile zlota chcesz przeslac");
console_cmd( id, "messagemode gold_ammount")
} else if(item == 6) {
menuAdmin(id, id2)
}
}
public menuAdmin(id, id2) {
new szTargetNick[33];
new szTitle[64];
get_user_name(id2, szTargetNick, 32)
if(!is_user_alive(id2)) {
ColorChat(id, GREEN, "%s^x01 Player '%s' is dead!", CHAT_PREFIX, szTargetNick)
Menu(id)
return
}
formatex(szTitle, charsmax(szTitle), "Wybrany gracz: \r%s^n\wIle chcesz mu wyslac?", szTargetNick)
new iMenu = menu_create(szTitle, "menuAdminH")
new szData[3];
num_to_str(id2, szData, 2)
menu_additem(iMenu, "5", szData)
menu_additem(iMenu, "10", szTargetNick)
menu_additem(iMenu, "25")
menu_additem(iMenu, "50")
menu_additem(iMenu, "100")
menu_additem(iMenu, "Wpisz")
menu_display(id, iMenu)
}
public menuAdminH(id, menu, item)
{
if(item == MENU_EXIT || !is_user_alive(id)) {
menu_destroy(menu)
return
}
new acces,cb, szData[3], szTarget[33], szTemp[2]
menu_item_getinfo(menu, 1, acces, szTemp, 1, szTarget, 32, cb)
menu_item_getinfo(menu, 0, acces, szData, 2, szTemp, 1, cb)
new id2 = iPlayerTarget[id] = str_to_num(szData)
if(item == 0) {
ChangeGold(id,id2, 5, 1)
}
else if(item == 1) {
ChangeGold(id,id2, 10, 1)
}
else if(item == 2) {
ChangeGold(id,id2, 25, 1)
}
else if(item == 3) {
ChangeGold(id,id2, 50, 1)
}
else if(item == 4) {
ChangeGold(id,id2, 100, 1)
}
else if(item == 5) {
client_print(id, print_center, "Wpisz ilde chcesz wyslac");
console_cmd( id, "messagemode gold_ammount_admin")
}
}
public GiveGoldAdmin(id)
{
new szAmmount[10]
read_args(szAmmount, 9)
remove_quotes(szAmmount)
if(str_to_num(szAmmount) <= 0) {
ColorChat(id, GREEN, "%s^x01 Wartosc '%d' jest za mala, wpisz poprawna!", CHAT_PREFIX, str_to_num(szAmmount))
menuAdmin(id, iPlayerTarget[id])
return;
}
ChangeGold(id, iPlayerTarget[id], str_to_num(szAmmount), 1);
}
public GiveGold(id)
{
new szAmmount[10]
read_args(szAmmount, 9)
remove_quotes(szAmmount)
if(str_to_num(szAmmount) > td_get_user_info(id, PLAYER_GOLD)) {
ColorChat(id, GREEN, "%s^x01 Wartosc '%d' jest za duza, wpisz poprawna!", CHAT_PREFIX, str_to_num(szAmmount))
Menu(id)
return;
} else if(str_to_num(szAmmount) <= 0) {
ColorChat(id, GREEN, "%s^x01 Wartosc '%d' jest za mala, wpisz poprawna!", CHAT_PREFIX, str_to_num(szAmmount))
Menu(id)
return;
}
ChangeGold(id, iPlayerTarget[id], str_to_num(szAmmount), 0);
}
ChangeGold(this, target, ammount, admin = 0)
{
new szName[33]
new szAdminName[33];
get_user_name(this, szAdminName, 32)
get_user_name(target, szName, charsmax(szName))
if(!is_user_connected(target)) {
ColorChat(this, GREEN, "%s^x01 Niestety gracz '%s' nie jest na serwerze!", CHAT_PREFIX, szName)
return;
}
if(!admin)
td_set_user_info(this, PLAYER_GOLD, td_get_user_info(this, PLAYER_GOLD) - ammount)
td_set_user_info(target, PLAYER_GOLD, td_get_user_info(target, PLAYER_GOLD) + ammount)
if(!admin)
ColorChat(this, GREEN, "%s^x01 Wyslales %d zlota do '%s'!", CHAT_PREFIX, ammount, szName)
else
ColorChat(0, GREEN, "%s^x01 Admin '%s' wyslal %d zlota do '%s'!", CHAT_PREFIX, szAdminName, ammount, szName)
if(admin)
ColorChat(target, GREEN, "%s^x01 Otrzymales od admina '%s' %d zlota", CHAT_PREFIX, szAdminName, ammount)
else
ColorChat(0, GREEN, "%s^x01 Gracz '%s' wyslal '%s' %d zlota!", CHAT_PREFIX, szAdminName, szName, ammount)
iPlayerTarget[this] = 0;
}