· 6 years ago · Jul 06, 2019, 10:10 PM
1#pragma semicolon 1
2
3// ===================
4// >>> DEFINE
5// ===================
6
7#define PLUGIN_AUTHOR "Bioly"
8#define PLUGIN_VERSION "0.1"
9#define CrateModel "models/props/crates/csgo_drop_crate_bravo.mdl"
10#define MaxItems 400
11#define LoopValidClients(%1) for(int %1 = 1; %1 < MaxClients; %1++) if(IsValidClient(%1))
12
13// ====================
14// >>> INCLUDE
15// ====================
16
17#include <sourcemod>
18#include <sdktools>
19#include <cstrike>
20#include <sdkhooks>
21#include <errors>
22#include <colors>
23#include <casesys>
24#include <store>
25
26// ====================
27// >>> ZMIENNE
28// ====================
29
30Database DatabaseHandle;
31char g_cConfigFile[PLATFORM_MAX_PATH];
32char g_cError[128];
33char g_cPrefix[64];
34char g_cItemsNames[MaxItems + 1][32];
35char g_cItemsDesc[MaxItems + 1][64];
36char g_cItemsType[MaxItems + 1][64];
37char g_cItemsCase[MaxItems + 1][64];
38char g_cTempType[MAXPLAYERS][64];
39bool g_bInTrade[MAXPLAYERS];
40bool g_bAccept[MAXPLAYERS];
41bool g_bSetCost[MAXPLAYERS];
42int g_iInvitation[MAXPLAYERS] = { -1, ... };
43int g_iTradeItem[MAXPLAYERS];
44int g_iTradePlayer[MAXPLAYERS];
45int g_iSetCost[MAXPLAYERS];
46int g_iGoldChance;
47int g_iRedChance;
48int g_iBlueChance;
49int g_iWhiteChance;
50int g_iChestChance;
51int g_iItems;
52int g_iClientHelmet[MAXPLAYERS];
53int g_iClientArmor[MAXPLAYERS];
54int g_iClientPants[MAXPLAYERS];
55int g_iClientBoots[MAXPLAYERS];
56int g_iClientSword[MAXPLAYERS];
57int g_iClientStone[MAXPLAYERS];
58int g_iClientShield[MAXPLAYERS];
59int g_iClientPickup[MAXPLAYERS];
60int g_Offset_GroundEnt = -1;
61Handle g_hItems[MaxItems];
62
63#pragma newdecls required
64
65EngineVersion g_Game;
66
67// ===========================
68// >>> PLUGIN INFO
69// ===========================
70
71public Plugin myinfo =
72{
73 name = "[Bioly] Case System",
74 author = PLUGIN_AUTHOR,
75 description = "N/A",
76 version = PLUGIN_VERSION,
77 url = "id/ToTenBioly"
78};
79
80// ====================
81// >>> OnPluginStart
82// ====================
83
84public void OnPluginStart()
85{
86 Errors.SetPluginName("[Bioly] Case System");
87 g_Game = GetEngineVersion();
88 if (g_Game != Engine_CSGO && g_Game != Engine_CSS)
89 {
90 Errors.ThrowCriticalError(0, "Ten plugin jest tylko do CSGO/CSS.");
91 }
92 BuildPath(Path_SM, g_cConfigFile, sizeof(g_cConfigFile), "configs/bioly_csys.cfg");
93 DB_Connect();
94 HookEvent("player_death", playerDeath);
95 HookEvent("player_spawn", playerSpawn);
96 RegConsoleCmd("sm_ekwipunek", EQCallback);
97 RegConsoleCmd("sm_eq", EQCallback);
98 RegConsoleCmd("sm_wyrzuc", DropCallback);
99 RegConsoleCmd("sm_wymiana", TradeCallback);
100 RegConsoleCmd("sm_trade", TradeCallback);
101 RegConsoleCmd("sm_przyjmij", AcceptCallback);
102 RegConsoleCmd("sm_przedmioty", AllItemsCallback);
103 RegConsoleCmd("sm_market", MarketCallback);
104 RegConsoleCmd("sm_rynek", MarketCallback);
105 RegAdminCmd("sm_itemy", AllItemsAdmin, ADMFLAG_ROOT);
106 RegAdminCmd("sm_ustaw", SetItem, ADMFLAG_ROOT);
107 AddCommandListener(ChatListener, "say");
108 AddCommandListener(ChatListener, "say2");
109 AddCommandListener(ChatListener, "say_team");
110 g_Offset_GroundEnt = FindSendPropInfo("CBasePlayer", "m_hGroundEntity");
111 if (g_Offset_GroundEnt == -1)
112 {
113 SetFailState("Unable to find offset for ground entity.");
114 }
115 g_cItemsNames[0] = "Brak";
116 g_cItemsDesc[0] = "Brak";
117 g_cItemsType[0] = "Brak";
118 g_cItemsCase[0] = "Brak";
119}
120public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
121{
122 CreateNative("CSYS_ZarejestrujItem", Native_CSYS_ZarejestrujItem);
123 CreateNative("CSYS_PobierzItemGracza", Native_CSYS_PobierzItemGracza);
124 CreateNative("CSYS_ZniszczItem", Native_CSYS_ZniszczItem);
125 CreateNative("CSYS_PobierzTypItemu", Native_CSYS_PobierzTypItemu);
126 CreateNative("CSYS_UstawItemGracza", Native_CSYS_UstawItemGracza);
127 RegPluginLibrary("casesys");
128 return APLRes_Success;
129}
130public void OnMapStart()
131{
132 PrecacheModel(CrateModel);
133 LoadConfig();
134 DB_Connect();
135}
136public void OnClientAuthorized(int client, const char[] auth)
137{
138 DataPack dp = new DataPack();
139 dp.WriteCell(client);
140 dp.WriteString(auth);
141 CreateTimer(1.0, CSYSGen, dp);
142}
143public Action CSYSGen(Handle timer, DataPack dp)
144{
145 dp.Reset();
146 int client = dp.ReadCell();
147 if (!IsFakeClient(client))
148 {
149 char auth[64];
150 dp.ReadString(auth, sizeof(auth));
151 DB_LoadCSYS(client, auth);
152 char sQuery[300];
153 Format(sQuery, sizeof(sQuery), "SELECT * FROM `bcsys_market` WHERE `steamid`=`%s`", auth);
154 DatabaseHandle.Query(DB_Check, sQuery, client);
155 }
156}
157public void DB_Check(Database db, DBResultSet results, const char[] error, any data)
158{
159 int client = data;
160 if (results == null)
161 {
162 return;
163 }
164 if (results.RowCount > 0)
165 {
166 if (results.FetchRow())
167 {
168 char sQuery[300];
169 int iItem = results.FetchInt(1);
170 int iCost = results.FetchInt(2);
171 int iAdded = results.FetchInt(3);
172 if (iAdded == 1)
173 {
174 char sSteamID[35];
175 GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
176 Store_SetClientCredits(client, Store_GetClientCredits(client) + iCost);
177 Format(sQuery, sizeof(sQuery), "DELETE FROM `bcsys_market` WHERE `steamid`='%s' AND `item`=%i AND `cost`=%i AND `added`=1", sSteamID, iItem, iCost);
178 DatabaseHandle.Query(SQLCallback_Void, sQuery);
179 }
180 }
181 }
182}
183public void OnClientPutInServer(int client)
184{
185 SDKHook(client, SDKHook_PreThink, Prethink);
186}
187public void OnClientDisconnect(int client)
188{
189 SDKUnhook(client, SDKHook_PreThink, Prethink);
190 DB_UpdateAccount(client);
191 if (g_bInTrade[client])
192 {
193 CPrintToChat(g_iTradePlayer[client], "%s Gracz \x04%N \x01wyszedł z serwera podczas wymiany.", g_cPrefix, client);
194 Reset(client);
195 Reset(g_iTradePlayer[client]);
196 }
197 ToggleOffAllVariables(client);
198}
199public Action playerDeath(Event event, char[] name, bool dontBroadcast)
200{
201 int client = GetClientOfUserId(event.GetInt("userid"));
202 if (GetClientTeam(client) != CS_TEAM_T)
203 return Plugin_Continue;
204
205 int iCaseChance = GetRandomInt(1, 100);
206 if (iCaseChance <= g_iChestChance)
207 SpawnCrate(client);
208
209 return Plugin_Continue;
210}
211public Action playerSpawn(Event event, char[] name, bool dontBroadcast)
212{
213 int client = GetClientOfUserId(event.GetInt("userid"));
214 /*
215 if (GetClientTeam(client) != CS_TEAM_CT)
216 return Plugin_Continue;
217 */
218 if (g_iClientHelmet[client] != 0)
219 SetPerk(client, g_iClientHelmet[client]);
220 if (g_iClientArmor[client] != 0)
221 SetPerk(client, g_iClientArmor[client]);
222 if (g_iClientPants[client] != 0)
223 SetPerk(client, g_iClientPants[client]);
224 if (g_iClientBoots[client] != 0)
225 SetPerk(client, g_iClientBoots[client]);
226 if (g_iClientSword[client] != 0)
227 SetPerk(client, g_iClientSword[client]);
228 if (g_iClientStone[client] != 0)
229 SetPerk(client, g_iClientStone[client]);
230 if (g_iClientShield[client] != 0)
231 SetPerk(client, g_iClientShield[client]);
232 if (g_iClientPickup[client] != 0)
233 SetPerk(client, g_iClientPickup[client]);
234
235 //return Plugin_Continue;
236}
237public Action EQCallback(int client, int args)
238{
239 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
240 CPrintToChat(client, "%s Sprawdź konsole. \x06(~)", g_cPrefix);
241 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
242 PrintToConsole(client, " ");
243 PrintToConsole(client, " ");
244 PrintToConsole(client, "=============================================================");
245 PrintToConsole(client, "» Twój hełm: %s [%s].", g_cItemsNames[g_iClientHelmet[client]], g_cItemsCase[g_iClientHelmet[client]]);
246 PrintToConsole(client, "» Twoja zbroja: %s [%s].", g_cItemsNames[g_iClientArmor[client]], g_cItemsCase[g_iClientArmor[client]]);
247 PrintToConsole(client, "» Twoje spodnie: %s [%s].", g_cItemsNames[g_iClientPants[client]], g_cItemsCase[g_iClientPants[client]]);
248 PrintToConsole(client, "» Twoje buty: %s [%s].", g_cItemsNames[g_iClientBoots[client]], g_cItemsCase[g_iClientBoots[client]]);
249 PrintToConsole(client, "» Twój miecz: %s [%s].", g_cItemsNames[g_iClientSword[client]], g_cItemsCase[g_iClientSword[client]]);
250 PrintToConsole(client, "» Twój kamień: %s [%s].", g_cItemsNames[g_iClientStone[client]], g_cItemsCase[g_iClientStone[client]]);
251 PrintToConsole(client, "» Twoja tarcza: %s [%s].", g_cItemsNames[g_iClientShield[client]], g_cItemsCase[g_iClientShield[client]]);
252 PrintToConsole(client, "=============================================================");
253 return Plugin_Handled;
254}
255public Action AllItemsAdmin(int client, int args)
256{
257 CPrintToChat(client, "%s Sprawdź konsole. [\x06~\x01]", g_cPrefix);
258 for (int i; i < g_iItems; i++)
259 {
260 PrintToConsole(client, "ID: %i | Nazwa itemu: %s | Skrzynka: %s", i, g_cItemsNames[i], g_cItemsCase[i]);
261 }
262 return Plugin_Handled;
263}
264public Action SetItem(int client, int args)
265{
266 if (args < 2)
267 {
268 CPrintToChat(client, "%s Poprawne użycie: \x07!ustaw \x01<\x10nick\x01> \x01<\x10id\x01>", g_cPrefix);
269 return Plugin_Handled;
270 }
271
272 char sName[64];
273 GetCmdArg(1, sName, sizeof(sName));
274
275 char sItem[64];
276 GetCmdArg(2, sItem, sizeof(sItem));
277
278 int iTarget = FindTarget(client, sName, true, false);
279 if (iTarget == -1)
280 {
281 CPrintToChat(client, "%s Nie znaleziono gracza o podanym nicku.", g_cPrefix);
282 return Plugin_Handled;
283 }
284
285 CSYS_UstawItemGracza(iTarget, StringToInt(sItem));
286 CPrintToChat(client, "%s Poprawnie ustawiono przedmiot graczowi \x10%N\x01.", g_cPrefix, iTarget);
287 CPrintToChat(iTarget, "%s Administrator \x10%N\x01 ustawił Ci nowy przedmiot.", g_cPrefix, client);
288
289 return Plugin_Handled;
290}
291public Action DropCallback(int client, int args)
292{
293 if (args < 1)
294 {
295 CPrintToChat(client, "%s Poprawne użycie: \x07!wyrzuc \x01<\x10helm \x01| \x10zbroja \x01| \x10spodnie \x01| \x10buty \x01| \x10miecz \x01| \x10kamien \x01| \x10tarcza\x01>", g_cPrefix);
296 return Plugin_Handled;
297 }
298
299 char sItem[64];
300 GetCmdArg(1, sItem, sizeof(sItem));
301
302 if ((StrContains(sItem, "helm")) != -1)
303 {
304 if (g_iClientHelmet[client] != 0)
305 {
306 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
307 CPrintToChat(client, "%s Poprawnie wyrzuciłeś item: \x06%s\x01.", g_cPrefix, g_cItemsNames[g_iClientHelmet[client]]);
308 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
309 DisableItem(client, g_iClientHelmet[client], "Helm");
310 }
311 }
312 else if ((StrContains(sItem, "zbroja")) != -1)
313 {
314 if (g_iClientArmor[client] != 0)
315 {
316 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
317 CPrintToChat(client, "%s Poprawnie wyrzuciłeś item: \x06%s\x01.", g_cPrefix, g_cItemsNames[g_iClientArmor[client]]);
318 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
319 DisableItem(client, g_iClientArmor[client], "Zbroja");
320 }
321 }
322 else if ((StrContains(sItem, "spodnie")) != -1)
323 {
324 if (g_iClientPants[client] != 0)
325 {
326 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
327 CPrintToChat(client, "%s Poprawnie wyrzuciłeś item: \x06%s\x01.", g_cPrefix, g_cItemsNames[g_iClientPants[client]]);
328 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
329 DisableItem(client, g_iClientPants[client], "Spodnie");
330 }
331 }
332 else if ((StrContains(sItem, "buty")) != -1)
333 {
334 if (g_iClientBoots[client] != 0)
335 {
336 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
337 CPrintToChat(client, "%s Poprawnie wyrzuciłeś item: \x06%s\x01.", g_cPrefix, g_cItemsNames[g_iClientBoots[client]]);
338 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
339 DisableItem(client, g_iClientBoots[client], "Buty");
340 }
341 }
342 else if ((StrContains(sItem, "miecz")) != -1)
343 {
344 if (g_iClientSword[client] != 0)
345 {
346 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
347 CPrintToChat(client, "%s Poprawnie wyrzuciłeś item: \x06%s\x01.", g_cPrefix, g_cItemsNames[g_iClientSword[client]]);
348 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
349 DisableItem(client, g_iClientSword[client], "Miecz");
350 }
351 }
352 else if ((StrContains(sItem, "kamien")) != -1)
353 {
354 if (g_iClientStone[client] != 0)
355 {
356 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
357 CPrintToChat(client, "%s Poprawnie wyrzuciłeś item: \x06%s\x01.", g_cPrefix, g_cItemsNames[g_iClientStone[client]]);
358 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
359 DisableItem(client, g_iClientStone[client], "Kamien");
360 }
361 }
362 else if ((StrContains(sItem, "tarcza")) != -1)
363 {
364 if (g_iClientShield[client] != 0)
365 {
366 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
367 CPrintToChat(client, "%s Poprawnie wyrzuciłeś item: \x06%s\x01.", g_cPrefix, g_cItemsNames[g_iClientShield[client]]);
368 CPrintToChat(client, "=================== \x02» EKWIPUNEK « \x01===================");
369 DisableItem(client, g_iClientShield[client], "Tarcza");
370 }
371 }
372 else CPrintToChat(client, "%s Poprawne użycie: \x07!wyrzuc \x01<\x10helm | zbroja | spodnie | buty | miecz | kamien | tarcza\x01>", g_cPrefix);
373 return Plugin_Handled;
374}
375public Action Prethink(int client)
376{
377 if (!IsValidClient(client) || IsFakeClient(client))
378 return Plugin_Continue;
379
380 if (IsPlayerAlive(client) && GetClientTeam(client) == CS_TEAM_CT)
381 {
382 int iEntityBelow = GetEntDataEnt2(client, g_Offset_GroundEnt);
383 if (IsValidEdict(iEntityBelow))
384 {
385 char sProp[64];
386 GetEntPropString(iEntityBelow, Prop_Data, "m_iName", sProp, sizeof(sProp));
387 if ((StrContains(sProp, "case_")) != -1)
388 {
389 char sItem[2][12];
390 ExplodeString(sProp, "|", sItem, sizeof(sItem), sizeof(sItem[]));
391 ShowMenu(client, StringToInt(sItem[1]));
392 CPrintToChatAll("%s Gracz \x06%N \x01znalazł skrzynke [%s].", g_cPrefix, client, g_cItemsCase[StringToInt(sItem[1])]);
393 AcceptEntityInput(iEntityBelow, "kill");
394 }
395 }
396 }
397 return Plugin_Continue;
398}
399public void ShowMenu(int client, int item)
400{
401 char sType[64];
402 char sBuffer[128];
403 CSYS_PobierzTypItemu(sType, item);
404 Menu ItemPickUpMenu = new Menu(ItemPickUpMenuCallback);
405 Format(sBuffer, sizeof(sBuffer), "Skrzynka :: Otwieranie\n» Typ: %s\n» Nazwa: %s\n» Opis: %s\n \n", sType, g_cItemsNames[item], g_cItemsDesc[item]);
406 ItemPickUpMenu.SetTitle(sBuffer);
407 IntToString(item, sBuffer, sizeof(sBuffer));
408 ItemPickUpMenu.AddItem(sBuffer, "Biorę!");
409 ItemPickUpMenu.AddItem("nie", "Co to za shit? Nie chcę tego.");
410 ItemPickUpMenu.Display(client, 0);
411}
412public int ItemPickUpMenuCallback(Menu ItemPickUpMenu, MenuAction action, int param1, int param2)
413{
414 switch (action)
415 {
416 case MenuAction_Select:
417 {
418 char sItem[64];
419 ItemPickUpMenu.GetItem(param2, sItem, sizeof(sItem));
420 if (StrEqual(sItem, "nie"))
421 {
422 delete ItemPickUpMenu;
423 }
424 else
425 {
426 int iItem = StringToInt(sItem);
427 char sType[64];
428 CSYS_PobierzTypItemu(sType, iItem);
429 if (CSYS_PobierzItemGracza(param1, sType) != 0)
430 DisableItem(param1, CSYS_PobierzItemGracza(param1, sType), sType);
431
432 if (StrEqual(sType, "Helm"))
433 g_iClientHelmet[param1] = iItem;
434
435 if (StrEqual(sType, "Zbroja"))
436 g_iClientArmor[param1] = iItem;
437
438 if (StrEqual(sType, "Spodnie"))
439 g_iClientPants[param1] = iItem;
440
441 if (StrEqual(sType, "Buty"))
442 g_iClientBoots[param1] = iItem;
443
444 if (StrEqual(sType, "Miecz"))
445 g_iClientSword[param1] = iItem;
446
447 if (StrEqual(sType, "Kamien"))
448 g_iClientStone[param1] = iItem;
449
450 if (StrEqual(sType, "Tarcza"))
451 g_iClientShield[param1] = iItem;
452
453 if (StrEqual(sType, "Pickup"))
454 g_iClientPickup[param1] = iItem;
455
456 SetPerk(param1, iItem);
457 CPrintToChat(param1, "=================== \x02» EKWIPUNEK « \x01===================");
458 CPrintToChat(param1, "%s Poprawnie podniosłeś item: \x06%s\x01.", g_cPrefix, g_cItemsNames[iItem]);
459 CPrintToChat(param1, "=================== \x02» EKWIPUNEK « \x01===================");
460 }
461 }
462 case MenuAction_End:
463 {
464 delete ItemPickUpMenu;
465 }
466 }
467}
468public void SpawnCrate(int client)
469{
470 int iEnt = CreateEntityByName("prop_dynamic_override");
471 if (iEnt == -1)
472 return;
473
474 if (!IsModelPrecached(CrateModel))
475 PrecacheModel(CrateModel);
476
477 float vOrigin[3];
478 SetEntityModel(iEnt, CrateModel);
479 GetClientAbsOrigin(client, vOrigin);
480 vOrigin[2] -= 65;
481 int iChance = GetRandomInt(1, 100);
482 int color[4] = { 255, 255, 255, 255 };
483 char sGold[400][32], sRed[400][32], sBlue[400][32], sWhite[400][32], sTemp[32];
484 int iGold, iRed, iBlue, iWhite;
485 for (int i; i <= g_iItems; i++)
486 {
487 IntToString(i, sTemp, sizeof(sTemp));
488 if (StrEqual(g_cItemsCase[i], "Gold"))
489 {
490 iGold++;
491 sGold[iGold] = sTemp;
492 }
493 else if (StrEqual(g_cItemsCase[i], "Red"))
494 {
495 iRed++;
496 sRed[iRed] = sTemp;
497 }
498 else if (StrEqual(g_cItemsCase[i], "Blue"))
499 {
500 iBlue++;
501 sBlue[iBlue] = sTemp;
502 }
503 else if (StrEqual(g_cItemsCase[i], "White"))
504 {
505 iWhite++;
506 sWhite[iWhite] = sTemp;
507 }
508 }
509 char sPropName[64];
510 if (iChance <= g_iGoldChance)
511 {
512 color[0] = 255;
513 color[1] = 242;
514 color[2] = 0;
515 int iGoldItem = GetRandomInt(1, iGold);
516 Format(sPropName, sizeof(sPropName), "case_gold|%s", sGold[iGoldItem]);
517 SetEntPropString(iEnt, Prop_Data, "m_iName", sPropName);
518 }
519 else if (g_iGoldChance < iChance <= g_iRedChance)
520 {
521 color[0] = 255;
522 color[1] = 0;
523 color[2] = 0;
524 int iRedItem = GetRandomInt(1, iRed);
525 Format(sPropName, sizeof(sPropName), "case_red|%s", sRed[iRedItem]);
526 SetEntPropString(iEnt, Prop_Data, "m_iName", sPropName);
527 }
528 else if (g_iRedChance < iChance <= g_iBlueChance)
529 {
530 color[0] = 0;
531 color[1] = 127;
532 color[2] = 255;
533 int iBlueItem = GetRandomInt(1, iBlue);
534 Format(sPropName, sizeof(sPropName), "case_blue|%s", sBlue[iBlueItem]);
535 SetEntPropString(iEnt, Prop_Data, "m_iName", sPropName);
536 }
537 else if (g_iBlueChance < iChance <= g_iWhiteChance)
538 {
539 color[0] = 255;
540 color[1] = 255;
541 color[2] = 255;
542 int iWhiteItem = GetRandomInt(1, iWhite);
543 Format(sPropName, sizeof(sPropName), "case_white|%s", sWhite[iWhiteItem]);
544 SetEntPropString(iEnt, Prop_Data, "m_iName", sPropName);
545 }
546 SetEntityRenderColor(iEnt, color[0], color[1], color[2], 255);
547 DispatchKeyValueFloat(iEnt, "solid", 2.0);
548 DispatchSpawn(iEnt);
549 TeleportEntity(iEnt, vOrigin, NULL_VECTOR, NULL_VECTOR);
550}
551public Action TradeCallback(int client, int args)
552{
553 if (args < 1)
554 {
555 CPrintToChat(client, "%s Poprawne użycie: \x07!wymiana \x01<\x10nick\x01>", g_cPrefix);
556 return Plugin_Handled;
557 }
558
559 char sName[64];
560 GetCmdArg(1, sName, sizeof(sName));
561
562 char target_name[MAX_TARGET_LENGTH];
563 int target_list[MAXPLAYERS], target_count;
564 bool tn_is_ml;
565 if ((target_count = ProcessTargetString(
566 sName,
567 0,
568 target_list,
569 MAXPLAYERS,
570 COMMAND_FILTER_ALIVE,
571 target_name,
572 sizeof(target_name),
573 tn_is_ml)) <= 0)
574 {
575 CPrintToChat(client, "%s Nie znaleziono gracza o podanym nicku.", g_cPrefix);
576 return Plugin_Handled;
577 }
578
579 if (g_bInTrade[client])
580 {
581 CPrintToChat(client, "%s Jesteś aktualnie podczas wymiany.", g_cPrefix);
582 return Plugin_Handled;
583 }
584
585 for (int i = 0; i < target_count; i++)
586 {
587 int iUserID = GetClientUserId(target_list[i]);
588 if (target_list[i] == client)
589 {
590 CPrintToChat(client, "%s Nie możesz się wymieniać sam ze sobą.", g_cPrefix);
591 return Plugin_Handled;
592 }
593 if (g_bInTrade[target_list[i]])
594 {
595 CPrintToChat(client, "%s Gracz którego chcesz zaprosić aktualnie się z kimś wymienia.", g_cPrefix);
596 return Plugin_Handled;
597 }
598 if (g_iInvitation[GetClientOfUserId(iUserID)] != -1)
599 {
600 CPrintToChat(client, "%s Gracz \x10%N \x01jest już przez kogoś zaproszony.", g_cPrefix, target_list[i]);
601 return Plugin_Handled;
602 }
603 g_iInvitation[GetClientOfUserId(iUserID)] = GetClientUserId(client);
604 CPrintToChat(client, "==================== \x06» WYMIANA « \x01====================");
605 CPrintToChat(client, "%s Zaproszenie do wymiany zostało wysłane.", g_cPrefix);
606 CPrintToChat(client, "==================== \x06» WYMIANA « \x01====================");
607 CPrintToChat(GetClientOfUserId(iUserID), "==================== \x06» WYMIANA « \x01====================");
608 CPrintToChat(GetClientOfUserId(iUserID), "%s Zostałeś zaproszony do wymiany przez \x06%N\x01.", g_cPrefix, client);
609 CPrintToChat(GetClientOfUserId(iUserID), "%s Aby zakceptować zaproszenie wpisz na chacie \x10!przyjmij\x01.", g_cPrefix);
610 CPrintToChat(GetClientOfUserId(iUserID), "==================== \x06» WYMIANA « \x01====================");
611 CreateTimer(10.0, ForceCancel, target_list[i]);
612 }
613 return Plugin_Handled;
614}
615public Action ForceCancel(Handle timer, int client)
616{
617 if (!g_bInTrade[client])
618 {
619 int sender = GetClientOfUserId(g_iInvitation[client]);
620 CPrintToChat(client, "%s Czas na zakceptowanie wymiany minął.", g_cPrefix);
621 Reset(client);
622 Reset(sender);
623 }
624}
625public Action AcceptCallback(int client, int args)
626{
627 int sender = GetClientOfUserId(g_iInvitation[client]);
628 if (g_bInTrade[client])
629 {
630 CPrintToChat(client, "%s Jesteś aktualnie podczas wymiany.", g_cPrefix);
631 return Plugin_Handled;
632 }
633 if (g_iInvitation[client] == -1)
634 {
635 CPrintToChat(client, "%s Nie zostałeś zaproszony do żadnej wymiany.", g_cPrefix);
636 return Plugin_Handled;
637 }
638 if (!IsValidClient(sender))
639 {
640 CPrintToChat(client, "%s Gracz \x06%N \x01wyszedł z serwera.", g_cPrefix, sender);
641 return Plugin_Handled;
642 }
643 g_bInTrade[sender] = true;
644 g_bInTrade[client] = true;
645 g_iTradePlayer[sender] = client;
646 g_iTradePlayer[client] = sender;
647 CPrintToChat(client, "==================== \x06» WYMIANA « \x01====================");
648 CPrintToChat(client, "%s Poprawnie dołączyłeś do wymiany.", g_cPrefix);
649 CPrintToChat(client, "==================== \x06» WYMIANA « \x01====================");
650 CPrintToChat(sender, "==================== \x06» WYMIANA « \x01====================");
651 CPrintToChat(sender, "%s Gracz \x10%N \x01zaakceptował twoje zaproszenie do wymiany.", g_cPrefix, client);
652 CPrintToChat(sender, "==================== \x06» WYMIANA « \x01====================");
653 ShowTradeMenu(client);
654 ShowTradeMenu(sender);
655 return Plugin_Handled;
656}
657public void ShowTradeMenu(int client)
658{
659 Menu TradeMenu = new Menu(TradeMenuCallback);
660 TradeMenu.SetTitle("Wymiana :: Wybierz przedmiot który chcesz wymienić");
661 TradeMenu.AddItem("Helm", "Hełm", g_iClientHelmet[client] == 0 ? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
662 TradeMenu.AddItem("Zbroja", "Zbroja", g_iClientArmor[client] == 0 ? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
663 TradeMenu.AddItem("Spodnie", "Spodnie", g_iClientPants[client] == 0 ? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
664 TradeMenu.AddItem("Buty", "Buty", g_iClientBoots[client] == 0 ? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
665 TradeMenu.AddItem("Miecz", "Miecz", g_iClientSword[client] == 0 ? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
666 TradeMenu.AddItem("Kamien", "Kamień", g_iClientStone[client] == 0 ? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
667 TradeMenu.AddItem("Tarcza", "Tarcza", g_iClientShield[client] == 0 ? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
668 TradeMenu.ExitButton = false;
669 TradeMenu.Display(client, 0);
670}
671public int TradeMenuCallback(Menu TradeMenu, MenuAction action, int param1, int param2)
672{
673 switch (action)
674 {
675 case MenuAction_Select:
676 {
677 char item[64];
678 TradeMenu.GetItem(param2, item, sizeof(item));
679 if (StrEqual(item, "Helm"))
680 {
681 g_iTradeItem[param1] = g_iClientHelmet[param1];
682 }
683 else if (StrEqual(item, "Zbroja"))
684 {
685 g_iTradeItem[param1] = g_iClientArmor[param1];
686 }
687 else if (StrEqual(item, "Spodnie"))
688 {
689 g_iTradeItem[param1] = g_iClientPants[param1];
690 }
691 else if (StrEqual(item, "Buty"))
692 {
693 g_iTradeItem[param1] = g_iClientBoots[param1];
694 }
695 else if (StrEqual(item, "Miecz"))
696 {
697 g_iTradeItem[param1] = g_iClientSword[param1];
698 }
699 else if (StrEqual(item, "Kamien"))
700 {
701 g_iTradeItem[param1] = g_iClientStone[param1];
702 }
703 else if (StrEqual(item, "Tarcza"))
704 {
705 g_iTradeItem[param1] = g_iClientShield[param1];
706 }
707 if (g_iTradeItem[param1] != 0 && g_iTradeItem[g_iTradePlayer[param1]] != 0)
708 {
709 CreateConfirmMenu(param1);
710 CreateConfirmMenu(g_iTradePlayer[param1]);
711 }
712 }
713 case MenuAction_End:
714 {
715 delete TradeMenu;
716 }
717 }
718}
719public void CreateConfirmMenu(int client)
720{
721 char sBuffer[220];
722 Menu AcceptMenu = new Menu(AcceptMenuCallback);
723
724 Format(sBuffer, sizeof(sBuffer), "Wymiana :: Oferta\n» Oferujesz: %s[%s]\n» Oferta %N: %s[%s]\n \n", g_cItemsNames[g_iTradeItem[client]], g_cItemsCase[g_iTradeItem[client]], g_iTradePlayer[client], g_cItemsNames[g_iTradeItem[g_iTradePlayer[client]]], g_cItemsCase[g_iTradeItem[g_iTradePlayer[client]]]);
725 AcceptMenu.SetTitle(sBuffer);
726
727 AcceptMenu.AddItem("akceptuje", "Akceptuje");
728 AcceptMenu.AddItem("scam", "Jakiś scam ;_;. Nie chcę tego.");
729 AcceptMenu.ExitButton = false;
730 AcceptMenu.Display(client, 0);
731}
732public int AcceptMenuCallback(Menu AcceptMenu, MenuAction action, int param1, int param2)
733{
734 switch (action)
735 {
736 case MenuAction_Select:
737 {
738 if (g_bInTrade[param1])
739 {
740 char item[64];
741 AcceptMenu.GetItem(param2, item, sizeof(item));
742 if (StrEqual(item, "akceptuje"))
743 {
744 g_bAccept[param1] = true;
745 if (g_bAccept[param1] && g_bAccept[g_iTradePlayer[param1]])
746 {
747 char sType[64];
748 CSYS_PobierzTypItemu(sType, g_iTradeItem[g_iTradePlayer[param1]]);
749 if (StrEqual(sType, "Helm"))
750 {
751 if (g_iClientHelmet[param1] != 0)DisableItem(param1, g_iClientHelmet[param1], "Helm");
752 g_iClientHelmet[param1] = g_iTradeItem[g_iTradePlayer[param1]];
753 }
754 else if (StrEqual(sType, "Zbroja"))
755 {
756 if (g_iClientArmor[param1] != 0)DisableItem(param1, g_iClientArmor[param1], "Zbroja");
757 g_iClientArmor[param1] = g_iTradeItem[g_iTradePlayer[param1]];
758 }
759 else if (StrEqual(sType, "Spodnie"))
760 {
761 if (g_iClientPants[param1] != 0)DisableItem(param1, g_iClientPants[param1], "Spodnie");
762 g_iClientPants[param1] = g_iTradeItem[g_iTradePlayer[param1]];
763 }
764 else if (StrEqual(sType, "Buty"))
765 {
766 if (g_iClientBoots[param1] != 0)DisableItem(param1, g_iClientBoots[param1], "Buty");
767 g_iClientBoots[param1] = g_iTradeItem[g_iTradePlayer[param1]];
768 }
769 else if (StrEqual(sType, "Miecz"))
770 {
771 if (g_iClientSword[param1] != 0)DisableItem(param1, g_iClientSword[param1], "Miecz");
772 g_iClientSword[param1] = g_iTradeItem[g_iTradePlayer[param1]];
773 }
774 else if (StrEqual(sType, "Kamien"))
775 {
776 if (g_iClientStone[param1] != 0)DisableItem(param1, g_iClientStone[param1], "Kamien");
777 g_iClientStone[param1] = g_iTradeItem[g_iTradePlayer[param1]];
778 }
779 else if (StrEqual(sType, "Tarcza"))
780 {
781 if (g_iClientShield[param1] != 0)DisableItem(param1, g_iClientShield[param1], "Tarcza");
782 g_iClientShield[param1] = g_iTradeItem[g_iTradePlayer[param1]];
783 }
784 CSYS_PobierzTypItemu(sType, g_iTradeItem[param1]);
785 if (StrEqual(sType, "Helm"))
786 {
787 if (g_iClientHelmet[g_iTradePlayer[param1]] != 0)DisableItem(g_iTradePlayer[param1], g_iClientHelmet[g_iTradePlayer[param1]], "Helm");
788 g_iClientHelmet[g_iTradePlayer[param1]] = g_iTradeItem[param1];
789 }
790 else if (StrEqual(sType, "Zbroja"))
791 {
792 if (g_iClientArmor[g_iTradePlayer[param1]] != 0)DisableItem(g_iTradePlayer[param1], g_iClientArmor[g_iTradePlayer[param1]], "Zbroja");
793 g_iClientArmor[g_iTradePlayer[param1]] = g_iTradeItem[param1];
794 }
795 else if (StrEqual(sType, "Spodnie"))
796 {
797 if (g_iClientPants[g_iTradePlayer[param1]] != 0)DisableItem(g_iTradePlayer[param1], g_iClientPants[g_iTradePlayer[param1]], "Spodnie");
798 g_iClientPants[g_iTradePlayer[param1]] = g_iTradeItem[param1];
799 }
800 else if (StrEqual(sType, "Buty"))
801 {
802 if (g_iClientBoots[g_iTradePlayer[param1]] != 0)DisableItem(g_iTradePlayer[param1], g_iClientBoots[g_iTradePlayer[param1]], "Buty");
803 g_iClientBoots[g_iTradePlayer[param1]] = g_iTradeItem[param1];
804 }
805 else if (StrEqual(sType, "Miecz"))
806 {
807 if (g_iClientSword[g_iTradePlayer[param1]] != 0)DisableItem(g_iTradePlayer[param1], g_iClientSword[g_iTradePlayer[param1]], "Miecz");
808 g_iClientSword[g_iTradePlayer[param1]] = g_iTradeItem[param1];
809 }
810 else if (StrEqual(sType, "Kamien"))
811 {
812 if (g_iClientStone[g_iTradePlayer[param1]] != 0)DisableItem(g_iTradePlayer[param1], g_iClientStone[g_iTradePlayer[param1]], "Kamien");
813 g_iClientStone[g_iTradePlayer[param1]] = g_iTradeItem[param1];
814 }
815 else if (StrEqual(sType, "Tarcza"))
816 {
817 if (g_iClientShield[g_iTradePlayer[param1]] != 0)DisableItem(g_iTradePlayer[param1], g_iClientShield[g_iTradePlayer[param1]], "Tarcza");
818 g_iClientShield[g_iTradePlayer[param1]] = g_iTradeItem[param1];
819 }
820 CPrintToChat(param1, "==================== \x06» WYMIANA « \x01====================");
821 CPrintToChat(param1, "%s Wymiana przebiegła pomyślnie.", g_cPrefix);
822 CPrintToChat(param1, "==================== \x06» WYMIANA « \x01====================");
823 CPrintToChat(g_iTradePlayer[param1], "==================== \x06» WYMIANA « \x01====================");
824 CPrintToChat(g_iTradePlayer[param1], "%s Wymiana przebiegła pomyślnie.", g_cPrefix);
825 CPrintToChat(g_iTradePlayer[param1], "==================== \x06» WYMIANA « \x01====================");
826 Reset(param1);
827 Reset(g_iTradePlayer[param1]);
828 }
829 }
830 else if (StrEqual(item, "scam"))
831 {
832 CPrintToChat(param1, "==================== \x06» WYMIANA « \x01====================");
833 CPrintToChat(param1, "%s Stwierdziłeś, że ta wymiana to scam.", g_cPrefix);
834 CPrintToChat(param1, "%s Wymiana została wstrzymana.", g_cPrefix);
835 CPrintToChat(param1, "==================== \x06» WYMIANA « \x01====================");
836 CPrintToChat(g_iTradePlayer[param1], "==================== \x06» WYMIANA « \x01====================");
837 CPrintToChat(g_iTradePlayer[param1], "%s Gracz \x06%N \x01stwierdził, że ta wymiana to scam.", g_cPrefix, param1);
838 CPrintToChat(g_iTradePlayer[param1], "%s Wymiana została wstrzymana.", g_cPrefix);
839 CPrintToChat(g_iTradePlayer[param1], "==================== \x06» WYMIANA « \x01====================");
840 Reset(param1);
841 Reset(g_iTradePlayer[param1]);
842 }
843 }
844 }
845 case MenuAction_End:
846 {
847 delete AcceptMenu;
848 }
849 }
850}
851public Action AllItemsCallback(int client, int args)
852{
853 char sItem[64], sBuffer[64];
854 Menu ItemsListMenu = new Menu(ItemsListMenuCallback);
855 ItemsListMenu.SetTitle("Skrzynki :: Lista itemów\n \n");
856 for (int i = 1; i <= g_iItems; i++)
857 {
858 Format(sItem, sizeof(sItem), "» %s [%s]", g_cItemsNames[i], g_cItemsCase[i]);
859 IntToString(i, sBuffer, sizeof(sBuffer));
860 ItemsListMenu.AddItem(sBuffer, sItem);
861 }
862 if (g_iItems == 0)
863 {
864 Format(sItem, sizeof(sItem), "» %s [%s]", g_cItemsNames[0], g_cItemsCase[0]);
865 ItemsListMenu.AddItem("0", sItem);
866 }
867 ItemsListMenu.Display(client, 0);
868 return Plugin_Handled;
869}
870public int ItemsListMenuCallback(Menu ItemsListMenu, MenuAction action, int param1, int param2)
871{
872 switch (action)
873 {
874 case MenuAction_Select:
875 {
876 char sItem[64];
877 ItemsListMenu.GetItem(param2, sItem, sizeof(sItem));
878 int iID = StringToInt(sItem);
879 OpenDescriptionMenu(param1, iID);
880 }
881 case MenuAction_End:
882 {
883 delete ItemsListMenu;
884 }
885 }
886}
887public void OpenDescriptionMenu(int client, int iID)
888{
889 char sItem[128];
890 Menu DescMenu = new Menu(DescMenuCallback);
891 DescMenu.SetTitle("Skrzynki :: Opis itemu\n \n", MENU_ACTIONS_ALL);
892 Format(sItem, sizeof(sItem), "» Nazwa: %s", g_cItemsNames[iID]);
893 DescMenu.AddItem("", sItem, ITEMDRAW_DISABLED);
894 Format(sItem, sizeof(sItem), "» Opis: %s", g_cItemsDesc[iID]);
895 DescMenu.AddItem("", sItem, ITEMDRAW_DISABLED);
896 Format(sItem, sizeof(sItem), "» Skrzynka: %s", g_cItemsCase[iID]);
897 DescMenu.AddItem("", sItem, ITEMDRAW_DISABLED);
898 DescMenu.ExitBackButton = true;
899 DescMenu.Display(client, 0);
900}
901public int DescMenuCallback(Menu DescMenu, MenuAction action, int param1, int param2)
902{
903 switch (action)
904 {
905 case MenuAction_End:
906 {
907 delete DescMenu;
908 }
909 case MenuAction_Cancel:
910 {
911 FakeClientCommand(param1, "sm_przedmioty");
912 }
913 }
914}
915public Action MarketCallback(int client, int args)
916{
917 Menu MarketMenu = new Menu(MarketMenuCallback);
918 MarketMenu.SetTitle("Rynek :: Co chcesz zrobić?\n \n");
919 MarketMenu.AddItem("buy", "Zakupić przedmiot");
920 MarketMenu.AddItem("sell", "Sprzedać przedmiot");
921 MarketMenu.Display(client, 0);
922 return Plugin_Handled;
923}
924public int MarketMenuCallback(Menu MarketMenu, MenuAction action, int param1, int param2)
925{
926 switch (action)
927 {
928 case MenuAction_Select:
929 {
930 char sItem[64];
931 MarketMenu.GetItem(param2, sItem, sizeof(sItem));
932 if (StrEqual(sItem, "buy"))
933 {
934 char sQuery[300];
935 Format(sQuery, sizeof(sQuery), "SELECT * FROM `bcsys_market`");
936 DatabaseHandle.Query(DB_LoadShop, sQuery, param1);
937
938 }
939 else if (StrEqual(sItem, "sell"))
940 {
941 SellItems(param1);
942 }
943 }
944 case MenuAction_End:
945 {
946 delete MarketMenu;
947 }
948 }
949}
950public void DB_LoadShop(Database db, DBResultSet results, const char[] error, any data)
951{
952 int client = data;
953 if (results == null)
954 {
955 return;
956 }
957 Menu BuyMenu = new Menu(BuyMenuCallback);
958 BuyMenu.SetTitle("Rynek :: Kup");
959 if (results.RowCount > 0)
960 {
961 while (results.FetchRow())
962 {
963 char sBuffer[128];
964 char sSteamID[35];
965 char sItem[128];
966 int iItem;
967 int iCost;
968 results.FetchString(0, sSteamID, sizeof(sSteamID));
969 iItem = results.FetchInt(1);
970 iCost = results.FetchInt(2);
971 Format(sBuffer, sizeof(sBuffer), "[%i][%s]%s", iCost, g_cItemsCase[iItem], g_cItemsNames[iItem]);
972 Format(sItem, sizeof(sItem), "%s;%i;%i", sSteamID, iItem, iCost);
973 BuyMenu.AddItem(sItem, sBuffer);
974 }
975 }
976 else
977 {
978 BuyMenu.AddItem("null", "Brak itemów", ITEMDRAW_DISABLED);
979 }
980 BuyMenu.ExitBackButton = true;
981 BuyMenu.Display(client, MENU_TIME_FOREVER);
982}
983public int BuyMenuCallback(Menu BuyMenu, MenuAction action, int param1, int param2)
984{
985 switch (action)
986 {
987 case MenuAction_Select:
988 {
989 char sItem[128];
990 char sExploded[3][128];
991 char sBuffer[128];
992 char sQuery[300];
993 BuyMenu.GetItem(param2, sItem, sizeof(sItem));
994 // sExploded[0] - SteamID | sExploded[1] - Item | sExploded[2] - Koszt
995 ExplodeString(sItem, ";", sExploded, sizeof(sExploded), sizeof(sExploded[]));
996 if (Store_GetClientCredits(param1) < StringToInt(sExploded[2]))
997 {
998 CPrintToChat(param1, "%s Masz za mało kredytów.", g_cPrefix);
999 return;
1000 }
1001 CSYS_PobierzTypItemu(sBuffer, StringToInt(sExploded[1]));
1002 if (StrEqual(sBuffer, "Helm"))
1003 {
1004 if (g_iClientHelmet[param1] != 0)DisableItem(param1, g_iClientHelmet[param1], "Helm");
1005 g_iClientHelmet[param1] = StringToInt(sExploded[1]);
1006 }
1007 else if (StrEqual(sBuffer, "Zbroja"))
1008 {
1009 if (g_iClientArmor[param1] != 0)DisableItem(param1, g_iClientArmor[param1], "Zbroja");
1010 g_iClientArmor[param1] = StringToInt(sExploded[1]);
1011 }
1012 else if (StrEqual(sBuffer, "Spodnie"))
1013 {
1014 if (g_iClientPants[param1] != 0)DisableItem(param1, g_iClientPants[param1], "Spodnie");
1015 g_iClientPants[param1] = StringToInt(sExploded[1]);
1016 }
1017 else if (StrEqual(sBuffer, "Buty"))
1018 {
1019 if (g_iClientBoots[param1] != 0)DisableItem(param1, g_iClientBoots[param1], "Buty");
1020 g_iClientBoots[param1] = StringToInt(sExploded[1]);
1021 }
1022 else if (StrEqual(sBuffer, "Miecz"))
1023 {
1024 if (g_iClientSword[param1] != 0)DisableItem(param1, g_iClientSword[param1], "Miecz");
1025 g_iClientSword[param1] = StringToInt(sExploded[1]);
1026 }
1027 else if (StrEqual(sBuffer, "Kamien"))
1028 {
1029 if (g_iClientStone[param1] != 0)DisableItem(param1, g_iClientStone[param1], "Kamien");
1030 g_iClientStone[param1] = StringToInt(sExploded[1]);
1031 }
1032 else if (StrEqual(sBuffer, "Tarcza"))
1033 {
1034 if (g_iClientShield[param1] != 0)DisableItem(param1, g_iClientShield[param1], "Tarcza");
1035 g_iClientShield[param1] = StringToInt(sExploded[1]);
1036 }
1037 Store_SetClientCredits(param1, Store_GetClientCredits(param1) - StringToInt(sExploded[2]));
1038 CPrintToChat(param1, "%s Poprawnie zakupiłeś przedmiot.", g_cPrefix);
1039 Format(sQuery, sizeof(sQuery), "UPDATE `bcsys_market` SET `added`=1 WHERE `steamid`='%s' AND `item`=%i AND `cost`=%i", sExploded[0], sExploded[1], sExploded[2]);
1040 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1041 LoopValidClients(i)
1042 {
1043 char sSteamID[35];
1044 GetClientAuthId(i, AuthId_Steam2, sSteamID, sizeof(sSteamID));
1045 if (StrEqual(sExploded[0], sSteamID))
1046 {
1047 Store_SetClientCredits(i, Store_GetClientCredits(i) + StringToInt(sExploded[2]));
1048 Format(sQuery, sizeof(sQuery), "DELETE FROM `bcsys_market` WHERE `steamid`='%s' AND `item`=%i AND `cost`=%i", sExploded[0], sExploded[1], sExploded[2]);
1049 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1050 }
1051 }
1052 }
1053 case MenuAction_End:
1054 {
1055 delete BuyMenu;
1056 }
1057 }
1058}
1059public void SellItems(int client)
1060{
1061 Menu SellMenu = new Menu(SellMenuCallback);
1062 SellMenu.SetTitle("Rynek :: Sprzedaj\n \n");
1063 SellMenu.AddItem("Helm", "Hełm", g_iClientHelmet[client] != 0 ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
1064 SellMenu.AddItem("Zbroja", "Zbroja", g_iClientArmor[client] != 0 ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
1065 SellMenu.AddItem("Spodnie", "Spodnie", g_iClientPants[client] != 0 ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
1066 SellMenu.AddItem("Buty", "Buty", g_iClientBoots[client] != 0 ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
1067 SellMenu.AddItem("Miecz", "Miecz", g_iClientSword[client] != 0 ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
1068 SellMenu.AddItem("Kamien", "Kamień", g_iClientStone[client] != 0 ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
1069 SellMenu.AddItem("Tarcza", "Tarcza", g_iClientShield[client] != 0 ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
1070 SellMenu.ExitBackButton = true;
1071 SellMenu.Display(client, 0);
1072}
1073public int SellMenuCallback(Menu SellMenu, MenuAction action, int param1, int param2)
1074{
1075 switch (action)
1076 {
1077 case MenuAction_Select:
1078 {
1079 char sItem[64];
1080 SellMenu.GetItem(param2, sItem, sizeof(sItem));
1081 SetCost(param1, sItem);
1082 }
1083 case MenuAction_End:
1084 {
1085 delete SellMenu;
1086 }
1087 case MenuAction_Cancel:
1088 {
1089 FakeClientCommand(param1, "sm_rynek");
1090 }
1091 }
1092}
1093public void SetCost(int client, char[] sType)
1094{
1095 strcopy(g_cTempType[client], sizeof(g_cTempType[]), sType);
1096 char sBuffer[64];
1097 Format(sBuffer, sizeof(sBuffer), "Rynek :: Sprzedaj\n» Wybrany item: %s\n \n", sType);
1098 Menu SetCostMenu = new Menu(SetCostMenuCallback);
1099 SetCostMenu.SetTitle(sBuffer);
1100
1101 Format(sBuffer, sizeof(sBuffer), "Cena: %i", g_iSetCost[client]);
1102 SetCostMenu.AddItem("set", sBuffer);
1103 SetCostMenu.AddItem(sType, "Wystaw przedmiot", g_iSetCost[client] > 0 ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
1104 SetCostMenu.ExitBackButton = true;
1105 SetCostMenu.Display(client, 0);
1106}
1107public int SetCostMenuCallback(Menu SetCostMenu, MenuAction action, int param1, int param2)
1108{
1109 switch (action)
1110 {
1111 case MenuAction_Select:
1112 {
1113 char sItem[64];
1114 char sQuery[300];
1115 char sAuth[35];
1116 SetCostMenu.GetItem(param2, sItem, sizeof(sItem));
1117 GetClientAuthId(param1, AuthId_Steam2, sAuth, sizeof(sAuth));
1118 if (StrEqual(sItem, "set"))
1119 {
1120 g_bSetCost[param1] = true;
1121 CPrintToChat(param1, "===================== \x06» RYNEK « \x01=====================");
1122 CPrintToChat(param1, "%s Wpisz cenę itemu.", g_cPrefix);
1123 CPrintToChat(param1, "%s Jeśli chcesz anulować wpisz \x06Anuluj\x01.", g_cPrefix);
1124 CPrintToChat(param1, "===================== \x06» RYNEK « \x01=====================");
1125 return;
1126 }
1127 else if (StrEqual(sItem, "Helm"))
1128 {
1129 if (g_iClientHelmet[param1] != 0)
1130 {
1131 Format(sQuery, sizeof(sQuery), "INSERT INTO `bcsys_market` VALUES ('%s', %i, %i, 0)", sAuth, g_iClientHelmet[param1], g_iSetCost[param1]);
1132 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1133 g_iClientHelmet[param1] = 0;
1134 CPrintToChat(param1, "%s Poprawnie wystawiłeś przedmiot.", g_cPrefix);
1135 }
1136 }
1137 else if (StrEqual(sItem, "Zbroja"))
1138 {
1139 if (g_iClientArmor[param1] != 0)
1140 {
1141 Format(sQuery, sizeof(sQuery), "INSERT INTO `bcsys_market` VALUES ('%s', %i, %i, 0)", sAuth, g_iClientArmor[param1], g_iSetCost[param1]);
1142 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1143 g_iClientArmor[param1] = 0;
1144 CPrintToChat(param1, "%s Poprawnie wystawiłeś przedmiot.", g_cPrefix);
1145 }
1146 }
1147 else if (StrEqual(sItem, "Spodnie"))
1148 {
1149 if (g_iClientPants[param1] != 0)
1150 {
1151 Format(sQuery, sizeof(sQuery), "INSERT INTO `bcsys_market` VALUES ('%s', %i, %i)", sAuth, g_iClientPants[param1], g_iSetCost[param1]);
1152 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1153 g_iClientPants[param1] = 0;
1154 CPrintToChat(param1, "%s Poprawnie wystawiłeś przedmiot.", g_cPrefix);
1155 }
1156 }
1157 else if (StrEqual(sItem, "Buty"))
1158 {
1159 if (g_iClientBoots[param1] != 0)
1160 {
1161 Format(sQuery, sizeof(sQuery), "INSERT INTO `bcsys_market` VALUES ('%s', %i, %i)", sAuth, g_iClientBoots[param1], g_iSetCost[param1]);
1162 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1163 g_iClientBoots[param1] = 0;
1164 CPrintToChat(param1, "%s Poprawnie wystawiłeś przedmiot.", g_cPrefix);
1165 }
1166 }
1167 else if (StrEqual(sItem, "Miecz"))
1168 {
1169 if (g_iClientSword[param1] != 0)
1170 {
1171 Format(sQuery, sizeof(sQuery), "INSERT INTO `bcsys_market` VALUES ('%s', %i, %i)", sAuth, g_iClientSword[param1], g_iSetCost[param1]);
1172 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1173 g_iClientSword[param1] = 0;
1174 CPrintToChat(param1, "%s Poprawnie wystawiłeś przedmiot.", g_cPrefix);
1175 }
1176 }
1177 else if (StrEqual(sItem, "Kamien"))
1178 {
1179 if (g_iClientStone[param1] != 0)
1180 {
1181 Format(sQuery, sizeof(sQuery), "INSERT INTO `bcsys_market` VALUES ('%s', %i, %i)", sAuth, g_iClientStone[param1], g_iSetCost[param1]);
1182 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1183 g_iClientStone[param1] = 0;
1184 CPrintToChat(param1, "%s Poprawnie wystawiłeś przedmiot.", g_cPrefix);
1185 }
1186 }
1187 else if (StrEqual(sItem, "Tarcza"))
1188 {
1189 if (g_iClientShield[param1] != 0)
1190 {
1191 Format(sQuery, sizeof(sQuery), "INSERT INTO `bcsys_market` VALUES ('%s', %i, %i)", sAuth, g_iClientShield[param1], g_iSetCost[param1]);
1192 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1193 g_iClientShield[param1] = 0;
1194 CPrintToChat(param1, "%s Poprawnie wystawiłeś przedmiot.", g_cPrefix);
1195 }
1196 }
1197 ResetSell(param1);
1198 FakeClientCommand(param1, "sm_rynek");
1199 }
1200 case MenuAction_End:
1201 {
1202 delete SetCostMenu;
1203 }
1204 case MenuAction_Cancel:
1205 {
1206 SellItems(param1);
1207 }
1208 }
1209}
1210public Action ChatListener(int client, const char[] command, int args)
1211{
1212 if (!IsValidClient(client))
1213 return Plugin_Handled;
1214
1215 char cMessage[64];
1216 GetCmdArg(1, cMessage, sizeof(cMessage));
1217 if (g_bSetCost[client])
1218 {
1219 if (StrContains(cMessage, "Anuluj", true) == 0)
1220 {
1221 g_bSetCost[client] = false;
1222 return Plugin_Handled;
1223 }
1224
1225 if ((StringToInt(cMessage)) <= 0)
1226 {
1227 CPrintToChat(client, "===================== \x06» RYNEK « \x01=====================");
1228 CPrintToChat(client, "%s Podana wartość nie jest cyfrą.", g_cPrefix);
1229 CPrintToChat(client, "%s Spróbuj jeszcze raz.", g_cPrefix);
1230 CPrintToChat(client, "===================== \x06» RYNEK « \x01=====================");
1231 return Plugin_Handled;
1232 }
1233 else
1234 {
1235 g_iSetCost[client] = StringToInt(cMessage);
1236 g_bSetCost[client] = false;
1237 SetCost(client, g_cTempType[client]);
1238 return Plugin_Handled;
1239 }
1240 }
1241 return Plugin_Continue;
1242}
1243public void Reset(int client)
1244{
1245 g_iInvitation[client] = -1;
1246 g_bInTrade[client] = false;
1247 g_bAccept[client] = false;
1248 g_iTradeItem[client] = 0;
1249 g_iTradePlayer[client] = -1;
1250}
1251public void ResetSell(int client)
1252{
1253 g_iSetCost[client] = 0;
1254 g_bSetCost[client] = false;
1255 g_cTempType[client] = "";
1256}
1257public void LoadConfig()
1258{
1259 KeyValues kvConfig = CreateKeyValues("CaseSys");
1260
1261 if (!kvConfig.ImportFromFile(g_cConfigFile))
1262 {
1263 Format(g_cError, sizeof(g_cError), "[ - Bioly_CSYS - ] Nie można odczytaćpoprawnie configu %s", g_cConfigFile);
1264 Errors.ThrowCriticalError(1, g_cError);
1265 delete kvConfig;
1266 return;
1267 }
1268
1269 if (!kvConfig.GotoFirstSubKey())
1270 {
1271 Format(g_cError, sizeof(g_cError), "[ - Bioly_CSYS - ] Nie można odczytaćpoprawnie configu %s", g_cConfigFile);
1272 Errors.ThrowCriticalError(2, g_cError);
1273 delete kvConfig;
1274 return;
1275 }
1276
1277 kvConfig.JumpToKey("General");
1278 kvConfig.GetString("prefix", g_cPrefix, sizeof(g_cPrefix));
1279 g_iChestChance = kvConfig.GetNum("chest");
1280 g_iGoldChance = kvConfig.GetNum("gold");
1281 g_iRedChance = kvConfig.GetNum("red");
1282 g_iBlueChance = kvConfig.GetNum("blue");
1283 g_iWhiteChance = kvConfig.GetNum("white");
1284
1285 delete kvConfig;
1286}
1287public void DB_Connect()
1288{
1289 if (SQL_CheckConfig("bCSYS"))
1290 Database.Connect(DB_ConnectCallback, "bCSYS");
1291 else
1292 {
1293 Format(g_cError, sizeof(g_cError), "[ - Bioly_CSYS - ] Brak wpisu 'bCSYS' w configu database.cfg.");
1294 Errors.ThrowCriticalError(3, g_cError);
1295 }
1296 return;
1297}
1298public void DB_ConnectCallback(Database db, const char[] error, any data)
1299{
1300 if (db == null || error[0])
1301 {
1302 Format(g_cError, sizeof(g_cError), "[ - Bioly_CSYS - ] Error: %s", error);
1303 Errors.ThrowCriticalError(4, g_cError);
1304 }
1305 DatabaseHandle = db;
1306 char sQuery[1000];
1307 Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS `bcsys` ( `steamid` VARCHAR(28) NOT NULL , `helm` SMALLINT(4) NOT NULL , `zbroja` SMALLINT(4) NOT NULL , `spodnie` SMALLINT(4) NOT NULL , `buty` SMALLINT(4) NOT NULL , `miecz` SMALLINT(4) NOT NULL , `kamien` SMALLINT(4) NOT NULL , `tarcza` SMALLINT(4) NOT NULL , PRIMARY KEY (`steamid`)) ENGINE = InnoDB;");
1308 Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS `bcsys_market` ( `steamid` VARCHAR(28) NOT NULL , `item` SMALLINT(4) NOT NULL , `cost` SMALLINT(4) NOT NULL , `added` SMALLINT(4) NOT NULL , PRIMARY KEY (`steamid`)) ENGINE = InnoDB;");
1309 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1310}
1311public void DB_LoadCSYS(int client, const char[] auth)
1312{
1313 char sQuery[256];
1314 Format(sQuery, sizeof(sQuery), "SELECT * FROM `bcsys` WHERE `steamid`='%s'", auth);
1315 DatabaseHandle.Query(DB_LoadCSYSCallback, sQuery, client);
1316}
1317public void DB_LoadCSYSCallback(Database db, DBResultSet results, const char[] error, any data)
1318{
1319 int client = data;
1320 if (results == null)
1321 {
1322 KickClient(client, "[ - Bioly_CSYS - ] Twoje konto nie zostało zautoryzowane.");
1323 LogError("[ - Bioly_CSYS - ] Wystąpił błąd w funkcji `DB_LoadCSYSCallback`. Error: %s", error);
1324 return;
1325 }
1326 if (results.RowCount > 0)
1327 {
1328 if (results.FetchRow())
1329 {
1330 g_iClientHelmet[client] = results.FetchInt(1);
1331 g_iClientArmor[client] = results.FetchInt(2);
1332 g_iClientPants[client] = results.FetchInt(3);
1333 g_iClientBoots[client] = results.FetchInt(4);
1334 g_iClientSword[client] = results.FetchInt(5);
1335 g_iClientStone[client] = results.FetchInt(6);
1336 g_iClientShield[client] = results.FetchInt(7);
1337 }
1338 }
1339 else
1340 {
1341 DB_CreateAccount(client);
1342 }
1343}
1344public void DB_CreateAccount(int client)
1345{
1346 char sQuery[256];
1347 char sAuth[35];
1348 GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
1349 Format(sQuery, sizeof(sQuery), "INSERT INTO `bcsys` VALUES ('%s', 0, 0, 0, 0, 0, 0, 0)", sAuth);
1350 g_iClientHelmet[client] = 0;
1351 g_iClientArmor[client] = 0;
1352 g_iClientPants[client] = 0;
1353 g_iClientBoots[client] = 0;
1354 g_iClientSword[client] = 0;
1355 g_iClientStone[client] = 0;
1356 g_iClientShield[client] = 0;
1357 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1358}
1359public void DB_UpdateAccount(int client)
1360{
1361 char sQuery[256];
1362 char sAuth[35];
1363 GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
1364 Format(sQuery, sizeof(sQuery), "UPDATE `bcsys` SET `helm`=%i, `zbroja`=%i, `spodnie`=%i, `buty`=%i, `miecz`=%i, `kamien`=%i, `tarcza`=%i WHERE `steamid`='%s'", g_iClientHelmet[client], g_iClientArmor[client], g_iClientPants[client], g_iClientBoots[client], g_iClientSword[client], g_iClientStone[client], g_iClientShield[client], sAuth);
1365 DatabaseHandle.Query(SQLCallback_Void, sQuery);
1366}
1367public void SQLCallback_Void(Database db, DBResultSet results, const char[] error, any data)
1368{
1369 if (db == null || error[0])
1370 {
1371 LogError("[ - Bioly_CSYS - ] Error SQLCallback_Void");
1372 }
1373}
1374public void ToggleOffAllVariables(int client)
1375{
1376 if (g_iClientHelmet[client] != 0)
1377 DisableItem(client, g_iClientHelmet[client], "Helm");
1378 if (g_iClientArmor[client] != 0)
1379 DisableItem(client, g_iClientArmor[client], "Zbroja");
1380 if (g_iClientPants[client] != 0)
1381 DisableItem(client, g_iClientPants[client], "Spodnie");
1382 if (g_iClientBoots[client] != 0)
1383 DisableItem(client, g_iClientBoots[client], "Buty");
1384 if (g_iClientSword[client] != 0)
1385 DisableItem(client, g_iClientSword[client], "Miecz");
1386 if (g_iClientStone[client] != 0)
1387 DisableItem(client, g_iClientStone[client], "Kamien");
1388 if (g_iClientShield[client] != 0)
1389 DisableItem(client, g_iClientShield[client], "Tarcza");
1390 if (g_iClientPickup[client] != 0)
1391 DisableItem(client, g_iClientPickup[client], "Pickup");
1392
1393 ResetSell(client);
1394}
1395public void SetPerk(int client, int item)
1396{
1397 Function func = GetFunctionByName(g_hItems[item], "CSYS_ItemON");
1398 if (func != INVALID_FUNCTION)
1399 {
1400 Call_StartFunction(g_hItems[item], func);
1401 Call_PushCell(client);
1402 Call_PushCell(item);
1403 Call_Finish();
1404 }
1405}
1406public void DisableItem(int client, int item, char[] sType)
1407{
1408 Function func;
1409 if (StrEqual(sType, "Helm"))func = GetFunctionByName(g_hItems[g_iClientHelmet[item]], "CSYS_ItemOFF");
1410 if (StrEqual(sType, "Zbroja"))func = GetFunctionByName(g_hItems[g_iClientArmor[item]], "CSYS_ItemOFF");
1411 if (StrEqual(sType, "Spodnie"))func = GetFunctionByName(g_hItems[g_iClientPants[item]], "CSYS_ItemOFF");
1412 if (StrEqual(sType, "Buty"))func = GetFunctionByName(g_hItems[g_iClientBoots[item]], "CSYS_ItemOFF");
1413 if (StrEqual(sType, "Miecz"))func = GetFunctionByName(g_hItems[g_iClientSword[item]], "CSYS_ItemOFF");
1414 if (StrEqual(sType, "Kamien"))func = GetFunctionByName(g_hItems[g_iClientStone[item]], "CSYS_ItemOFF");
1415 if (StrEqual(sType, "Tarcza"))func = GetFunctionByName(g_hItems[g_iClientShield[item]], "CSYS_ItemOFF");
1416 if (StrEqual(sType, "Pickup"))func = GetFunctionByName(g_hItems[g_iClientPickup[item]], "CSYS_ItemOFF");
1417 if (func != INVALID_FUNCTION)
1418 {
1419 if (StrEqual(sType, "Helm"))Call_StartFunction(g_hItems[g_iClientHelmet[client]], func);
1420 if (StrEqual(sType, "Zbroja"))Call_StartFunction(g_hItems[g_iClientArmor[client]], func);
1421 if (StrEqual(sType, "Spodnie"))Call_StartFunction(g_hItems[g_iClientPants[client]], func);
1422 if (StrEqual(sType, "Buty"))Call_StartFunction(g_hItems[g_iClientBoots[client]], func);
1423 if (StrEqual(sType, "Miecz"))Call_StartFunction(g_hItems[g_iClientSword[client]], func);
1424 if (StrEqual(sType, "Kamien"))Call_StartFunction(g_hItems[g_iClientStone[client]], func);
1425 if (StrEqual(sType, "Tarcza"))Call_StartFunction(g_hItems[g_iClientShield[client]], func);
1426 if (StrEqual(sType, "Pickup"))Call_StartFunction(g_hItems[g_iClientPickup[client]], func);
1427 Call_PushCell(client);
1428 if (StrEqual(sType, "Helm"))Call_PushCell(g_iClientHelmet[client]);
1429 if (StrEqual(sType, "Zbroja"))Call_PushCell(g_iClientArmor[client]);
1430 if (StrEqual(sType, "Spodnie"))Call_PushCell(g_iClientPants[client]);
1431 if (StrEqual(sType, "Buty"))Call_PushCell(g_iClientBoots[client]);
1432 if (StrEqual(sType, "Miecz"))Call_PushCell(g_iClientSword[client]);
1433 if (StrEqual(sType, "Kamien"))Call_PushCell(g_iClientStone[client]);
1434 if (StrEqual(sType, "Tarcza"))Call_PushCell(g_iClientShield[client]);
1435 if (StrEqual(sType, "Pickup"))Call_PushCell(g_iClientPickup[client]);
1436 Call_Finish();
1437 }
1438 if (StrEqual(sType, "Helm"))g_iClientHelmet[client] = 0;
1439 if (StrEqual(sType, "Zbroja"))g_iClientArmor[client] = 0;
1440 if (StrEqual(sType, "Spodnie"))g_iClientPants[client] = 0;
1441 if (StrEqual(sType, "Buty"))g_iClientBoots[client] = 0;
1442 if (StrEqual(sType, "Miecz"))g_iClientSword[client] = 0;
1443 if (StrEqual(sType, "Kamien"))g_iClientStone[client] = 0;
1444 if (StrEqual(sType, "Tarcza"))g_iClientShield[client] = 0;
1445 if (StrEqual(sType, "Pickup"))g_iClientPickup[client] = 0;
1446}
1447public int Native_CSYS_ZarejestrujItem(Handle plugin, int numParams)
1448{
1449 if (numParams != 4)
1450 {
1451 Errors.ThrowCriticalError(3, "Błędnie zarejestrowany item.");
1452 return -1;
1453 }
1454 if (g_iItems++ > MaxItems)
1455 {
1456 Errors.ThrowCriticalError(4, "Przekroczono maksymalnąilośćitemów.");
1457 return -2;
1458 }
1459
1460 g_hItems[g_iItems] = plugin;
1461 GetNativeString(1, g_cItemsNames[g_iItems], sizeof(g_cItemsNames[]));
1462 GetNativeString(2, g_cItemsDesc[g_iItems], sizeof(g_cItemsDesc[]));
1463 GetNativeString(3, g_cItemsType[g_iItems], sizeof(g_cItemsType[]));
1464 GetNativeString(4, g_cItemsCase[g_iItems], sizeof(g_cItemsCase[]));
1465 return g_iItems;
1466}
1467public int Native_CSYS_PobierzItemGracza(Handle plugin, int numParams)
1468{
1469 int client = GetNativeCell(1);
1470 if (IsValidClient(client))
1471 {
1472 char sType[64];
1473 GetNativeString(2, sType, sizeof(sType));
1474 if (StrEqual(sType, "Helm"))
1475 return g_iClientHelmet[client];
1476
1477 if (StrEqual(sType, "Zbroja"))
1478 return g_iClientArmor[client];
1479
1480 if (StrEqual(sType, "Spodnie"))
1481 return g_iClientPants[client];
1482
1483 if (StrEqual(sType, "Buty"))
1484 return g_iClientBoots[client];
1485
1486 if (StrEqual(sType, "Miecz"))
1487 return g_iClientSword[client];
1488
1489 if (StrEqual(sType, "Kamien"))
1490 return g_iClientStone[client];
1491
1492 if (StrEqual(sType, "Tarcza"))
1493 return g_iClientShield[client];
1494
1495 if (StrEqual(sType, "Pickup"))
1496 return g_iClientPickup[client];
1497 }
1498 return 0;
1499}
1500public int Native_CSYS_PobierzTypItemu(Handle plugin, int numParams)
1501{
1502 int item = GetNativeCell(2);
1503 SetNativeString(1, g_cItemsType[item], sizeof(g_cItemsType[]), false);
1504 return 0;
1505}
1506public int Native_CSYS_ZniszczItem(Handle plugin, int numParams)
1507{
1508 int client = GetNativeCell(1);
1509 int item = GetNativeCell(2);
1510 char sType[64];
1511 CSYS_PobierzTypItemu(sType, item);
1512 DisableItem(client, item, sType);
1513 return 0;
1514}
1515public int Native_CSYS_UstawItemGracza(Handle plugin, int numParams)
1516{
1517 int client = GetNativeCell(1);
1518 int item = GetNativeCell(2);
1519 char sType[64];
1520 CSYS_PobierzTypItemu(sType, item);
1521 if (StrEqual(sType, "Helm"))
1522 {
1523 if (g_iClientHelmet[client] != 0)DisableItem(client, g_iClientHelmet[client], "Helm");
1524 g_iClientHelmet[client] = item;
1525 }
1526 else if (StrEqual(sType, "Zbroja"))
1527 {
1528 if (g_iClientArmor[client] != 0)DisableItem(client, g_iClientArmor[client], "Zbroja");
1529 g_iClientArmor[client] = item;
1530 }
1531 else if (StrEqual(sType, "Spodnie"))
1532 {
1533 if (g_iClientPants[client] != 0)DisableItem(client, g_iClientPants[client], "Spodnie");
1534 g_iClientPants[client] = item;
1535 }
1536 else if (StrEqual(sType, "Buty"))
1537 {
1538 if (g_iClientBoots[client] != 0)DisableItem(client, g_iClientBoots[client], "Buty");
1539 g_iClientBoots[client] = item;
1540 }
1541 else if (StrEqual(sType, "Miecz"))
1542 {
1543 if (g_iClientSword[client] != 0)DisableItem(client, g_iClientSword[client], "Miecz");
1544 g_iClientSword[client] = item;
1545 }
1546 else if (StrEqual(sType, "Kamien"))
1547 {
1548 if (g_iClientStone[client] != 0)DisableItem(client, g_iClientStone[client], "Kamien");
1549 g_iClientStone[client] = item;
1550 }
1551 else if (StrEqual(sType, "Tarcza"))
1552 {
1553 if (g_iClientShield[client] != 0)DisableItem(client, g_iClientShield[client], "Tarcza");
1554 g_iClientShield[client] = item;
1555 }
1556 return 0;
1557}
1558stock bool IsValidClient(int client)
1559{
1560 if (client <= 0 || client > MaxClients || !IsClientConnected(client) || IsFakeClient(client))
1561 {
1562 return false;
1563 }
1564 return IsClientInGame(client);
1565}