forked from TheDoctor0/CoDMod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcod_transfer.sma
More file actions
141 lines (89 loc) · 3.72 KB
/
Copy pathcod_transfer.sma
File metadata and controls
141 lines (89 loc) · 3.72 KB
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
#include <amxmodx>
#include <cstrike>
#include <cod>
#define PLUGIN "CoD Transfer"
#define VERSION "1.1.1"
#define AUTHOR "O'Zone"
new const commandTransfer[][] = { "przelej", "say /przelew", "say_team /przelew", "say /przelej", "say_team /przelej" };
new transferPlayer[MAX_PLAYERS + 1], bool:mapEnd;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
for (new i; i < sizeof commandTransfer; i++) register_clcmd(commandTransfer[i], "transfer_menu");
register_clcmd("ILOSC_HONORU", "transfer_honor_handle");
}
public cod_end_map()
mapEnd = true;
public transfer_menu(id)
{
if (!is_user_connected(id) || !cod_check_account(id) || mapEnd) return PLUGIN_HANDLED;
client_cmd(id, "spk %s", codSounds[SOUND_SELECT]);
new menuData[256], playerName[MAX_NAME], playerId[3], players, menu = menu_create("\yWybierz \rGracza\y, ktoremu chcesz przelac \rHonor\w:", "transfer_menu_handle");
for (new player = 1; player <= MAX_PLAYERS; player++) {
if (!is_user_connected(player) || !cod_get_user_class(player) || player == id) continue;
get_user_name(player, playerName, charsmax(playerName));
formatex(menuData, charsmax(menuData), "%s \y[%d Honoru]", playerName, cod_get_user_honor(player));
num_to_str(player, playerId, charsmax(playerId));
menu_additem(menu, menuData, playerId);
players++;
}
menu_setprop(menu, MPROP_EXITNAME, "Wyjscie");
menu_setprop(menu, MPROP_BACKNAME, "Poprzednie");
menu_setprop(menu, MPROP_NEXTNAME, "Nastepne");
if (!players) {
menu_destroy(menu);
cod_print_chat(id, "Na serwerze nie ma gracza, ktoremu moglbys przelac^x03 honor^x01!");
} else menu_display(id, menu);
return PLUGIN_HANDLED;
}
public transfer_menu_handle(id, menu, item)
{
if (!is_user_connected(id) || !cod_check_account(id) || mapEnd) return PLUGIN_HANDLED;
if (item == MENU_EXIT) {
client_cmd(id, "spk %s", codSounds[SOUND_EXIT]);
menu_destroy(menu);
return PLUGIN_HANDLED;
}
client_cmd(id, "spk %s", codSounds[SOUND_SELECT]);
new playerId[3], itemAccess, itemCallback;
menu_item_getinfo(menu, item, itemAccess, playerId, charsmax(playerId), _, _, itemCallback);
new player = str_to_num(playerId);
menu_destroy(menu);
if (!is_user_connected(player)) {
cod_print_chat(id, "Tego gracza nie ma juz na serwerze!");
return PLUGIN_HANDLED;
}
transferPlayer[id] = player;
client_cmd(id, "messagemode ILOSC_HONORU");
cod_print_chat(id, "Wpisz ilosc^x03 honoru^x01, ktora chcesz przelac!");
client_print(id, print_center, "Wpisz ilosc honoru, ktora chcesz przelac!");
return PLUGIN_HANDLED;
}
public transfer_honor_handle(id)
{
if (!is_user_connected(id) || !cod_check_account(id) || mapEnd) return PLUGIN_HANDLED;
client_cmd(id, "spk %s", codSounds[SOUND_EXIT]);
if (!is_user_connected(transferPlayer[id])) {
cod_print_chat(id, "Gracza, ktoremu chcesz przelac^x03 honor^x01 nie ma juz na serwerze!");
return PLUGIN_HANDLED;
}
new honorData[16], honorAmount;
read_args(honorData, charsmax(honorData));
remove_quotes(honorData);
honorAmount = str_to_num(honorData);
if (honorAmount <= 0) {
cod_print_chat(id, "Nie mozesz przelac mniej niz^x03 1 honoru^x01!");
return PLUGIN_HANDLED;
}
if (cod_get_user_honor(id) < honorAmount) {
cod_print_chat(id, "Nie masz tyle^x03 honoru^x01!");
return PLUGIN_HANDLED;
}
new playerName[MAX_NAME], playerIdName[MAX_NAME];
get_user_name(id, playerName, charsmax(playerName));
get_user_name(transferPlayer[id], playerIdName, charsmax(playerIdName));
cod_set_user_honor(transferPlayer[id], cod_get_user_honor(transferPlayer[id]) + honorAmount);
cod_set_user_honor(id, cod_get_user_honor(id) - honorAmount);
cod_print_chat(0, "^x03%s^x01 przelal^x04 %i honoru^x01 na konto^x03 %s^x01.", playerName, honorAmount, playerIdName);
return PLUGIN_HANDLED;
}