Advertisement
Guest User

Untitled

a guest
Nov 28th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.36 KB | None | 0 0
  1. #define LICZBA_OSIAGNIEC 13
  2. #define MAX_ACHIEVE 5
  3. new const osiagniecia[LICZBA_OSIAGNIEC][]= {
  4. "Zostan Januszem i zdobywaj AP",//ap 0
  5. "Bij i bij ile wlezie" ,//dmg 1
  6. "Wybij wszystkie zombie", //zombie 2
  7. "Zarazaj innych ludzi aby stali sie zombie",//zarazanie ludzi 3
  8. "Giniesz i giniesz nic nie pomagajac zombie", //smierc 4
  9. "Krol zombie cyz aby napewno taki mocny?",//nemek 5
  10. "Zabij ostatniego ocalalego", //survivor 6
  11. "Zabij zabojce ludzi",//assasin 7
  12. "Zabij mistrza snajperki",//sniper 8
  13. "Zabij matke wszystkich zombie", //matka 9
  14. "Zabij ostatniego czlowieka na ziemi",//last humna 10
  15. "Badz no-lifem",//czas gry 11
  16. "Tylko najlepsi przetrwaja"
  17. }
  18.  
  19. new const osiagniecia_wymagania[LICZBA_OSIAGNIEC][MAX_ACHIEVE]= {
  20. {10000,20000,30000,40000,50000},//ap
  21. {2000000,6000000,13000000,20000000,30000000}, //dmg
  22. {300,800,1500,2200,3000}, //kill zombie
  23. {200,400,600,800,1000}, //zarazenia //MyFrag - tu jest git
  24. {200,400,800,1200,1600}, //smierc
  25. {20,40,70,100,140}, //nemek
  26. {40,70,100,140,190}, //surc
  27. {20,40,70,100,140}, //asse
  28. {15,25,50,70,100},//sniepr
  29. {50,100,200,400,600}, //matki
  30. {50,100,150,250,400}, //las human
  31. {1000,2500,4500,6500,9900}, //czas
  32. {50,100,150,200,300} //rundy hm
  33. }
  34.  
  35. new const nagrody [LICZBA_OSIAGNIEC][MAX_ACHIEVE][] = {
  36. {"+1ap co runde","5% szans na dodatkowy exp za zabicie (5 do 20)","+1 ap co runde", "5%szans na dod exp(10-25)","+2ap co runde"},//ap gotowe w kodzie
  37.  
  38.  
  39. {"+1% dmg","+2% dmg","+2% dmg","+3%dmg","+4% dmg"}, //dmg gotowe w kodzie
  40.  
  41.  
  42. {"+1ap za killa","+1xp za killa"," +2xp za killa","+2xp za zabicie","2% szans na zadanie 1.5x dmg"}, //zombie gotowe w kodzie
  43.  
  44.  
  45. {"+100hp (hp dla zm)","+150hp (hp dla zm)","+200hp (hp dla zm)","+200hp (hp dla zm)","+250hp (hp dla zm)"},//inf human gotowe
  46.  
  47.  
  48. {"+1ap za smierc","+2 exp za smierc","+1 ap za smierc","+2exp za smierc","+1ap za smierc"},//death gotowe
  49.  
  50.  
  51. {"+2ap za zabicie nemka","+5expa za zabicie nemka","+5 ap za zabicie na nemka","+10exp za zabicie nemka","+6% obrazen przeciw nemkowi"}, //nemek gotowe
  52.  
  53.  
  54. {"+150 hp dla survivora","2% dmg","+250 hp","2%dmg","+4% obrazen jako survivor"},//surv gotowe poza hp
  55.  
  56.  
  57. {"+100hp dla assina","+100hp dla assasina","1% ze pocisk od humana nie trafi","%2 ze pocisk od humana nie trafi","3% szans ze atak zada nam 100 dmg"},//assasin do testu
  58.  
  59.  
  60. {"4%dmg w snipera","5%dmg w snipera","6%dmg w snipera","2% ze pocisk od snipera nie trafi","2% szans ze pocisk od snipera nie trafi"}, // sniper gotowa szansa
  61.  
  62.  
  63. {"+5 armoru co runde","+10armoru","+10 armoru","+15armoru","+15armoru"}, //matki gotowe
  64.  
  65.  
  66. {"5% dmg w lm ","5% dmg w lm ","5% dmg w lm ","5% dmg w lm ","paka dla matki"}, // last human gotowe do testu
  67.  
  68.  
  69. {"1% szybsze przeladowanie","1% szybsze przeladowanie","2% szybsze przeladowanie","2% szybsze przeladowanie","3% szybsze przeladowanie"}, // czas do testu
  70.  
  71.  
  72. {"lm na poczatek rundy ","15 hp dla lm","lm na poczatek rundy","20hp dla lm ","lm na poczatek rundy"} // przetrwanie jako human gotowe
  73.  
  74.  
  75. }
  76.  
  77. new ppre[LICZBA_OSIAGNIEC][] = {
  78. "AP","Give DMG","Killer zombie", "Infected Human", "Death", "Killer Nemesis", "Killer Survivor","Killer Assassin","Killer Sniper","Killer Mother Zombie","Killer Last Human","No-Life" , "survive round"
  79. }
  80.  
  81. new poddzialy [MAX_ACHIEVE][] = {
  82. "Swiezak",
  83. "Poczatkujacy",
  84. "Sredniozaawansowany",
  85. "Zaawansowany",
  86. "Ekspert"
  87.  
  88. }
  89. /* Plugin generated by AMXX-Studio */
  90.  
  91. #include <amxmodx>
  92. #include <amxmisc>
  93. #include <sqlx>
  94. #include <cstrike>
  95. #include <hamsandwich>
  96. #include <engine>
  97. #include <fakemeta>
  98. #include <fun>
  99.  
  100. #define PLUGIN "Osiagniecia Zombie Mod"
  101. #define VERSION "1.0.1"
  102. #define AUTHOR "Pogrom"
  103. #include <zp50_core>
  104. #include <zp50_gamemodes>
  105. #include <zp50_colorchat>
  106. #include <zp50_class_human>
  107. #include <zp50_class_zombie>
  108. #define LIBRARY_NEMESIS "zp50_class_nemesis"
  109. #include <zp50_class_nemesis>
  110. #define LIBRARY_ASSASIN "zp50_class_assassin"
  111. #include <zp50_class_assassin>
  112. #define LIBRARY_SURVIVOR "zp50_class_survivor"
  113. #include <zp50_class_survivor>
  114. #define LIBRARY_SNIPER "zp50_class_sniper"
  115. #include <zp50_class_sniper>
  116. #define LIBRARY_AMMOPACKS "zp50_ammopacks"
  117. #include <zp50_ammopacks>
  118. #include <colorchat>
  119. #include "osiagniecia.cfg"
  120. #define g_maxplayers 32
  121.  
  122.  
  123. #define TASK_LOAD_STATS 1550
  124.  
  125. #define TASK_OFFSET 1500
  126. new const prefix[] = "OSIAGNIECIA"
  127. new ZapiszStats[8000]
  128. new giLen=0, giMax=sizeof(ZapiszStats) - 1
  129. new callback
  130. new data[6]
  131. new dostep;
  132. new name[32]
  133.  
  134.  
  135. native get_user_xp(id);
  136. native set_user_xp(id, amount);
  137. native give_lm(id,ilosc);
  138. native daj_bombe(id);
  139. native ap_bonus_add(id,ilosc);
  140.  
  141. //dodajac usuwajac osiagniecia trzeba zmieniac funkcje wylicz i check oraz definicje powyzej oraz sql + dodac wymaagnia nagrody ppre i osiangiecia
  142. new ilosc[33][LICZBA_OSIAGNIEC]
  143. new g_stats[33][LICZBA_OSIAGNIEC]
  144.  
  145.  
  146. new command[][] = { "/osiagniecia","/achievements","/achieve"}
  147. new chat[][] = {"say","say_team" };
  148. new comm[][] = {"/osiagenieciainfo","/achievementsinfo","/achieveinfo","/infoachieve","/infoosiagniecia","/infoachievements"}
  149.  
  150.  
  151.  
  152. new g_sqlTable[31]= "zm_osiagniecia_testy"
  153. new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass
  154. new min_player,p_Enabled
  155. new asked_sql[33];
  156. new g_boolsqlOK = 0
  157. new Handle:g_SqlTuple
  158. new bool:wczytalo[33] = false
  159.  
  160.  
  161. new paka =0
  162.  
  163. new ilosc_wpisow = 0
  164. public plugin_init() {
  165. register_plugin(PLUGIN, VERSION, AUTHOR)
  166.  
  167. for (new i = 0; i <sizeof chat;i++)
  168. register_clcmd(chat[i],"Say_Handle")
  169.  
  170. min_player = get_cvar_pointer("min_liczba_graczy")
  171. p_Enabled = register_cvar("o_enable","1")
  172. mysqlx_host = register_cvar ("o_host", "localhost"); // The host from the db
  173. mysqlx_user = register_cvar ("o_user", "root"); // The username from the db login
  174. mysqlx_pass = register_cvar ("o_pass", ""); // The password from the db login
  175. mysqlx_db = register_cvar ("o_dbname", "db"); // The database name
  176.  
  177. register_menucmd(register_menuid("Main Menu"), 1023, "menu_osiagniecia_handle2")
  178.  
  179. RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
  180. register_event("DeathMsg", "event_deathmsg", "a");
  181. register_event("Damage", "on_damage", "b", "2!0", "3=0", "4!0")
  182.  
  183. register_logevent("Poczatek_Rundy", 2, "1=Round_Start")
  184. register_logevent("EventRoundEnd", 2, "1=Round_End")
  185. set_task(1.0, "sql_start")
  186. set_task(60.0, "increaseMinutes", .flags="b")
  187. set_task(60.0, "TaskZapiszStats", 0, _, _, "b")
  188. //register_concmd("osc","cmd_oc",ADMIN_IMMUNITY)
  189. ResetujZapytanie()
  190.  
  191.  
  192. }
  193.  
  194.  
  195. public plugin_natives()
  196. {
  197. register_native("load_stat","native_load_stat",1)
  198. register_native("add_ap_stat","native_add_ap",1)
  199. register_native("add_achieve","native_add_achieve",1)
  200. }
  201. public native_add_achieve(id,nr){
  202. server_print("%d %d", id , nr)
  203. g_stats[id][nr] = osiagniecia_wymagania[nr][ilosc[id][nr]]
  204. ilosc[id][nr]++
  205. }
  206. public native_load_stat(id,nr)
  207. {
  208. if(!is_user_connected(id))
  209. return 0
  210. if(wczytalo[id])
  211. return ilosc[id][nr]
  212. return 0
  213.  
  214. }
  215.  
  216. public native_add_ap(id){
  217. g_stats[id][0]++
  218. check(id)
  219. }
  220. public on_damage(id){
  221. new attacker_id = get_user_attacker(id)
  222. new damage = read_data(2);
  223.  
  224. if(!is_user_connected(id) || !is_user_connected(attacker_id) || get_user_team(id) == get_user_team(attacker_id) || !is_user_alive(id) || zp_class_nemesis_get(attacker_id) || zp_class_survivor_get(attacker_id) || zp_class_sniper_get(attacker_id) || zp_class_assassin_get(attacker_id))
  225. return PLUGIN_CONTINUE;
  226.  
  227. g_stats[attacker_id][1] += damage
  228. check(attacker_id)
  229. return PLUGIN_CONTINUE;
  230. }
  231.  
  232.  
  233. public Poczatek_Rundy()
  234. {
  235. new ammount = 0;
  236. if(players_num() < get_pcvar_num(min_player))
  237. {
  238. //ColorChat(g_attacker,GREEN,"[%s] Za mala liczba graczy aby osiagniecia byly naliczane",prefix)
  239. return
  240.  
  241. }
  242. for (new i = 1 ; i<33;i++)
  243. {
  244. if(!is_user_connected(i))
  245. continue;
  246. if(ilosc[i][0] >=1)
  247. ammount++
  248. if(ilosc[i][0] >= 3)
  249. ammount++
  250. if(ilosc[i][0] >= 5)
  251. ammount +=2
  252. if (ammount > 0){ // ap co runde
  253. zp_ammopacks_set(i,zp_ammopacks_get(i) +ammount)
  254. ap_bonus_add(i,ammount)
  255. }
  256. }
  257.  
  258. }
  259.  
  260. public EventRoundEnd()
  261. {
  262. if(players_num() < get_pcvar_num(min_player)){
  263. ColorChat(0,GREEN,"[%s] ^x01 Za mala liczba graczy",prefix)
  264. return
  265. }
  266. for (new id=1; id < 33; id++) {
  267. if(!is_user_connected(id) || !is_user_alive(id) )
  268. continue;
  269.  
  270. if(!zp_core_is_zombie(id))
  271. g_stats[id][12]++
  272.  
  273. }
  274. }
  275.  
  276.  
  277.  
  278. public zp_fw_core_spawn_post(id)
  279. {
  280. set_task(10.0, "Bonusy", id);
  281.  
  282. }
  283.  
  284. public Bonusy(id)
  285. {
  286. new dodatkowe_hp = 0
  287. new dodatkowy_armor = 0
  288.  
  289. if (zp_core_is_zombie(id) && !zp_class_assassin_get(id)&& !zp_class_nemesis_get(id))
  290. {
  291. if(ilosc[id][2] >= 1)
  292. {
  293. dodatkowe_hp += 100
  294.  
  295. }
  296. if(ilosc[id][2] >= 2){
  297. dodatkowe_hp += 150
  298.  
  299. }
  300. if(ilosc[id][2] >= 3)
  301. {
  302. dodatkowe_hp += 200
  303.  
  304.  
  305. }
  306. if(ilosc[id][2] >= 4){
  307. dodatkowe_hp += 200
  308.  
  309. }
  310. if(ilosc[id][2] >= 5){
  311. dodatkowe_hp += 250
  312.  
  313. }
  314.  
  315. if(dodatkowe_hp >0){
  316. set_user_health(id, get_user_health(id) + dodatkowe_hp)
  317. ColorChat(id,GREEN,"[%s] ^x01 Otrzymales dodatkowe ^x04 %d ^x01 hp za osiagniecia",prefix,dodatkowe_hp)
  318. }
  319. }
  320. else {
  321.  
  322. if(ilosc[id][9] >= 1){
  323. dodatkowy_armor += 5
  324.  
  325.  
  326. }
  327. if(ilosc[id][9] >= 2){
  328. dodatkowy_armor += 10
  329.  
  330.  
  331. }
  332. if(ilosc[id][9] >= 3){
  333. dodatkowy_armor += 10
  334.  
  335. }
  336.  
  337. if(ilosc[id][9] >= 4){
  338. dodatkowy_armor += 15
  339.  
  340. }
  341.  
  342. if(ilosc[id][9] >= 5){
  343. dodatkowy_armor += 15
  344.  
  345. }
  346.  
  347.  
  348. if(dodatkowy_armor > 0){
  349. set_user_armor(id, get_user_armor(id) + dodatkowy_armor)
  350. ColorChat(id,GREEN,"[%s] ^x01 Otrzymales dodatkowe ^x04 %d ^x01 armoru za osiagniecia ",prefix,dodatkowy_armor)
  351. }
  352. if (ilosc[id][12] == 5)
  353. give_lm(id,3)
  354. else if (ilosc[id][12] >= 3)
  355. give_lm(id,2)
  356. else if (ilosc[id][12] >= 1)
  357. give_lm(id,1)
  358. }
  359. paka = 1;
  360.  
  361. }
  362.  
  363. //===============================================
  364. //Pobieranie tekstu z say i sprawdzanie komend"
  365. //===============================================
  366. public Say_Handle(id)
  367. {
  368. new text[70], arg1[32], arg2[32]
  369. read_args(text, sizeof(text)-1)
  370. remove_quotes(text)
  371.  
  372. arg1[0] = '^0'
  373. arg2[0] = '^0'
  374.  
  375.  
  376. parse(text, arg1, sizeof(arg1)-1, arg2, sizeof(arg2)-1)
  377. //for(new i =0; i<sizeof comm;i++){
  378. //if(equali(arg1, comm[i])){
  379. // osiagniecia_info(id)
  380. // return PLUGIN_HANDLED
  381. //}
  382. //}
  383. if(arg2[0] == 0 )
  384. {
  385. for(new i = 0;i<sizeof comm;i++){
  386. if(equali(arg1, comm[i])){
  387. osiagniecia_info(id)
  388. return PLUGIN_HANDLED
  389. }
  390. }
  391.  
  392. for (new i = 0; i <sizeof command;i++){
  393. if(equali(arg1,command[i])){
  394. if (!g_boolsqlOK || !wczytalo[id]){
  395. ColorChat(id,GREEN,"[%s] ^x01 Trwa wczytywanie danych prosze czekac",prefix)
  396. Sprawdz_baze(id)
  397. return PLUGIN_HANDLED
  398. }
  399. menu_osiagniecia(id)
  400. return PLUGIN_HANDLED
  401. }
  402.  
  403. }
  404. return PLUGIN_CONTINUE
  405.  
  406.  
  407. }
  408. return PLUGIN_CONTINUE
  409.  
  410. }
  411. //========================
  412. //Info o osiagnieciach
  413. //========================
  414.  
  415. public osiagniecia_info(id)
  416. {
  417.  
  418. }
  419.  
  420. //====================
  421. //Menu osiagniec
  422. //====================
  423. public menu_osiagniecia(id)
  424. {
  425. new menu = menu_create("\yMenu \rOsiagniec","menu_osiagniec_handle")
  426. new formats[192]
  427. new data2[15]
  428. for(new i = 0;i<LICZBA_OSIAGNIEC;i++)
  429. {
  430. if(ilosc[id][i] < 5)
  431. formatex(formats,sizeof formats,"\w%s (%d/5)", osiagniecia[i],ilosc[id][i]);
  432.  
  433. else
  434. formatex(formats,sizeof formats,"\d%s\r[UKONCZONE]", osiagniecia[i])
  435. num_to_str(i,data2,sizeof(data2))
  436. menu_additem(menu,formats,data2,0);
  437. }
  438. menu_display(id,menu)
  439. }
  440.  
  441. public menu_osiagniec_handle(id,menu,item)
  442. {
  443.  
  444.  
  445. menu_item_getinfo(menu, item, dostep, data, 5, name, 31, callback);
  446. if (item == MENU_EXIT)
  447. return;
  448.  
  449. new item_id ;
  450. item_id = str_to_num(data)
  451. static formats[1024], iLen;
  452. iLen = 0;
  453. new xKeys3 = MENU_KEY_0|MENU_KEY_1;
  454. iLen += formatex(formats[iLen], sizeof formats - 1 - iLen, "\y Osiagniecia - \r %s ^n^n",ppre[item_id])
  455. //new menu2 =
  456. for(new i = 0;i<MAX_ACHIEVE;i++)
  457. {
  458. if(i + 1 > ilosc[id][item_id]) //jezeli i bedzie wieksze niz to co ma juz ukonczone w tej katgeori to dodaje zakres
  459. iLen += formatex(formats[iLen], sizeof formats - 1 - iLen,"\w %s \r(%d / %d) \y nagroda:\w %s^n", poddzialy[i],g_stats[id][item_id],osiagniecia_wymagania[item_id][i],nagrody[item_id][i]);
  460.  
  461. else
  462. iLen += formatex(formats[iLen], sizeof formats - 1 - iLen,"\d %s \r[UKONCZONE] \y nagroda:\w %s^n", poddzialy[i],nagrody[item_id][i])
  463.  
  464. }
  465. iLen+= formatex(formats[iLen],sizeof formats - 1 - iLen,"\r1. \wCofnij")
  466. iLen += formatex(formats[iLen], sizeof formats - 1 - iLen, "^n^n\r0.\w Wyjdz.")
  467.  
  468. show_menu(id, xKeys3, formats, -1, "Main Menu")
  469. //menu_display(id,menu2)
  470. }
  471. public menu_osiagniecia_handle2(id, key)
  472.  
  473. {
  474. switch(key){
  475. case 0: {
  476. menu_osiagniecia(id)
  477. }
  478. case 9:
  479. {
  480. return PLUGIN_HANDLED;
  481. }
  482. }
  483. return PLUGIN_CONTINUE
  484. }
  485. //===================================
  486. //Sprawdzenie czy nalezy sie nagroda
  487. //===================================
  488. public check(id)
  489. {
  490. for(new i = 0;i>12;i++)
  491. {
  492. for(new g=0;g<5;g++)
  493. {
  494. if(g_stats[id][i] >= osiagniecia_wymagania[i][g] && g+1>ilosc[id][i])
  495. {
  496. ilosc[id][i]++
  497. ColorChat(id,GREEN,"[%] ^x01Osiagnales osiagniecie ^x03 %s ^x01 na poziomie ^x03 %s",prefix,osiagniecia[i],poddzialy[g])
  498.  
  499. }
  500.  
  501.  
  502. }
  503. }
  504. }
  505.  
  506. //==================================================================
  507. //Sprawdzenie ktore osiagniecia juz wykonal gracz i w jakiej ilosc
  508. //==================================================================
  509. public wylicz(id)
  510. {
  511. for(new i = 0;i<LICZBA_OSIAGNIEC;i++)
  512. for(new g=0;g<MAX_ACHIEVE;g++)
  513. {
  514. if(g_stats[id][i] >= osiagniecia_wymagania[i][g] )
  515. {
  516. ilosc[id][i]++
  517. }
  518.  
  519. }
  520.  
  521. }
  522.  
  523. //=================================================================================
  524. //funkcja zwracajaca liczbe graczy bedacych na serwerze oraz nie bedacych na spec
  525. //=================================================================================
  526. public players_num(){
  527. new liczba= 0;
  528. for(new i=1; i < 33; i++)
  529. {
  530.  
  531. if(is_user_bot(i) || is_user_hltv(i) || !is_user_connected(i))
  532. continue;
  533. new CsTeams:team = cs_get_user_team(i)
  534. if(team == CS_TEAM_SPECTATOR && team == CS_TEAM_UNASSIGNED)
  535. continue
  536. liczba++;
  537. }
  538. return liczba
  539. }
  540. //====================================================
  541. //Pobranie czasu sp�dzonego na serwerze przez gracza
  542. //====================================================
  543. public increaseMinutes()
  544. {
  545.  
  546. if(players_num() < get_pcvar_num(min_player))
  547. {
  548. ColorChat(0,GREEN,"[%s] ^x01Za mala liczba graczy aby czas byl naliczany",prefix)
  549. return PLUGIN_CONTINUE
  550.  
  551. }
  552. new players[32], pnum, tempid
  553. get_players(players, pnum)
  554.  
  555. for(new i; i<pnum; i++)
  556. {
  557. tempid = players[i]
  558. new CsTeams:team = cs_get_user_team(tempid)
  559.  
  560. if(team != CS_TEAM_SPECTATOR && team != CS_TEAM_UNASSIGNED)
  561. {
  562. g_stats[tempid][11]++
  563. }
  564. }
  565. return PLUGIN_CONTINUE
  566. }
  567.  
  568.  
  569.  
  570.  
  571. //================
  572. //statystki osiagniec
  573. //=================
  574.  
  575.  
  576. public event_deathmsg()
  577. {
  578. if( !get_pcvar_num(p_Enabled) )
  579. return;
  580. if(players_num() < get_pcvar_num(min_player))
  581. {
  582. //ColorChat(g_attacker,GREEN,"[%s] Za mala liczba graczy aby osiagniecia byly naliczane",prefix)
  583. return
  584.  
  585. }
  586. new g_attacker = read_data(1);
  587. new g_victim = read_data(2);
  588. new ap_vic = 0,exp_vic =0,exp_att = 0, ap_att = 0
  589.  
  590. //nagroda za osiaecingia zginiecia
  591. if (ilosc[g_victim][4] == 5)
  592. {
  593. ap_vic +=1
  594. }
  595. if (ilosc[g_victim][4] >= 3)
  596. {
  597. ap_vic +=1
  598. }
  599. if (ilosc[g_victim][4] >= 1)
  600. {
  601. ap_vic +=1
  602. }
  603.  
  604. if (ilosc[g_victim][4] >= 4)
  605. exp_vic += 2
  606.  
  607. if (ilosc[g_victim][4] >= 2)
  608. exp_vic += 2
  609. if (ap_vic >0){
  610. ColorChat(g_victim,GREEN,"[%s] ^x01 Otrzymales ^x04 %d ^x01 dodatkowego ^x04 ap ^x01 z osiagniec",prefix,ap_vic)
  611. zp_ammopacks_set(g_victim,zp_ammopacks_get(g_victim) + ap_vic)
  612. ap_bonus_add(g_victim,ap_vic)
  613. }
  614. if(exp_vic >0)
  615. {
  616. ColorChat(g_victim,GREEN,"[%s] ^x01 Otrzymales ^x04 %d ^x01 dodatkowego ^x04 exp ^x01 z osiagniec",prefix,exp_vic)
  617. set_user_xp(g_victim,get_user_xp(g_victim) + exp_vic)
  618. }
  619.  
  620.  
  621. //nagroda za osiagniecia zabicia zm
  622.  
  623. if (ilosc[g_attacker][2] >= 4)
  624. exp_att += 2
  625. if (ilosc[g_attacker][2] >= 3)
  626. exp_att += 2
  627. if (ilosc[g_attacker][2] >= 2)
  628. exp_att += 1
  629. if(ilosc[g_attacker][2] >= 1)
  630. ap_att +=1
  631.  
  632. // exp i ap za osiagniecie nemkow
  633. if(ilosc[g_attacker][5] >= 4 && zp_class_nemesis_get(g_victim))
  634. exp_att += 10
  635.  
  636. if (ilosc[g_attacker][5] >= 2 && zp_class_nemesis_get(g_victim))
  637. exp_att += 5
  638.  
  639. if (ilosc[g_attacker][5] >= 3 && zp_class_nemesis_get(g_victim))
  640. {
  641. ap_att +=5
  642. }
  643. if (ilosc[g_attacker][4] >= 1 && zp_class_nemesis_get(g_victim))
  644. {
  645. ap_att +=2
  646. }
  647.  
  648. if(ilosc[g_attacker][0] >= 4 && random_num(1,100) <=5){
  649. exp_att += random_num(10,25)
  650.  
  651. }
  652. if(ilosc[g_attacker][0] >= 2 && random_num(1,100) <=5)
  653. exp_att += random_num(5,20)
  654. if(ap_att > 0)
  655. {
  656. ColorChat(g_attacker,GREEN,"[%s] ^x01Otrzymales ^x04 %d ^x01 dodatkowego ^x04 ap ^x01 z osiagniec",prefix,ap_att)
  657. zp_ammopacks_set(g_attacker,zp_ammopacks_get(g_attacker) + ap_att)
  658. ap_bonus_add(g_attacker,ap_att)
  659. }
  660. if(exp_att > 0){
  661. ColorChat(g_attacker,GREEN,"[%s] ^x01 Otrzymales ^x04 %d ^x01 dodatkowego ^x04 expa ^x01 z osiagniec",prefix,exp_att)
  662. set_user_xp(g_attacker,get_user_xp(g_attacker) + exp_att)
  663. }
  664.  
  665.  
  666. if(zp_core_is_zombie(g_victim) || zp_class_assassin_get(g_victim)|| zp_class_nemesis_get(g_victim)){
  667. g_stats[g_victim][4]++;
  668. check(g_victim)
  669. }
  670. if((1 <= g_attacker <= g_maxplayers))
  671. {
  672. if(g_victim != g_attacker)
  673. {
  674.  
  675. if(zp_core_is_zombie(g_attacker))
  676. {
  677. g_stats[g_attacker][3]++
  678. }
  679. else
  680. {
  681. g_stats[g_attacker][2]++
  682. }
  683.  
  684.  
  685. if(zp_class_nemesis_get(g_victim))
  686. {
  687.  
  688. g_stats[g_attacker][5]++
  689.  
  690. }
  691. if(zp_class_survivor_get(g_victim))
  692. {
  693. g_stats[g_attacker][6] ++
  694. }
  695. if(zp_class_assassin_get(g_victim))
  696. {
  697.  
  698. g_stats[g_attacker][7]++
  699.  
  700. }
  701. if(zp_class_sniper_get(g_victim))
  702. {
  703. g_stats[g_attacker][8]++
  704. }
  705.  
  706. new const Infection[] = "Infection Mode"
  707. new InfectionID = zp_gamemodes_get_id(Infection)
  708.  
  709. new const Multi[] = "Multiple Infection Mode"
  710. new MultiID = zp_gamemodes_get_id(Multi)
  711.  
  712. if(zp_core_is_last_human(g_victim) && (zp_gamemodes_get_current() == InfectionID || zp_gamemodes_get_current() == MultiID))
  713. {
  714.  
  715. g_stats[g_attacker][10]++
  716.  
  717. }
  718. else if(zp_core_is_first_zombie(g_victim) && (zp_gamemodes_get_current() == InfectionID || zp_gamemodes_get_current() == MultiID))
  719. {
  720. g_stats[g_attacker][9]++
  721.  
  722. }
  723. }
  724.  
  725. check(g_attacker)
  726. }
  727. }
  728.  
  729. //=================================
  730. //Bonusy za osiagniete osiagniecia
  731. //=================================
  732.  
  733. public TakeDamage(this, idinflictor, idattacker, Float:damage)
  734. {
  735. if(!is_user_alive(this) || !is_user_connected(this) || !is_user_connected(idattacker) || get_user_team(this) == get_user_team(idattacker))
  736. return HAM_IGNORED;
  737.  
  738.  
  739. if((zp_class_sniper_get(idattacker) && (random_num(1,100) <= 4) && ilosc[this][8] ==4) || (zp_class_sniper_get(idattacker) && (random_num(1,100) <= 2) && ilosc[this][8] ==4) ||(zp_class_assassin_get(this) && random_num(1,100) <=3 && ilosc[this][7] == 4) || (zp_class_assassin_get(this) && random_num(1,100) <=1 && ilosc[this][7] == 3))
  740. return HAM_SUPERCEDE
  741. new Float:am = 1.0
  742. if(ilosc[idattacker][1] >= 1)
  743. am += 0.01
  744. if(ilosc[idattacker][1] >= 2)
  745. am += 0.02
  746. if(ilosc[idattacker][1] >= 3)
  747. am += 0.02
  748. if(ilosc[idattacker][1] >= 4)
  749. am += 0.03
  750. if(ilosc[idattacker][1] == 5)
  751. am += 0.04
  752. if(zp_class_nemesis_get(this) && ilosc[idattacker][5] == 5 )
  753. am += 0.06
  754. if(zp_class_survivor_get(idattacker) && ilosc[idattacker][6] == 5 )
  755. am += 0.04
  756. if(zp_class_survivor_get(idattacker) && ilosc[idattacker][6] >= 4 )
  757. am += 0.02
  758. if(zp_class_survivor_get(idattacker) && ilosc[idattacker][5] >= 2 )
  759. am += 0.02
  760. if(zp_class_sniper_get(this) && ilosc[idattacker][8] >=1)
  761. am += 0.03
  762. if(zp_class_sniper_get(this) && ilosc[idattacker][8] >=2)
  763. am += 0.06
  764. if(zp_class_sniper_get(this) && ilosc[idattacker][8] >=3)
  765. am += 0.09
  766. if(ilosc[idattacker][2]==5 && random_num(1,100) <=2)
  767. am+=0.5
  768.  
  769. if (am >1.0)
  770. damage *= am
  771.  
  772.  
  773.  
  774. SetHamParamFloat(4, damage);
  775.  
  776. return HAM_IGNORED;
  777. }
  778.  
  779. //============================================
  780. //Polaczenie i rozlaczenie gracza z serwerem
  781. //============================================
  782. public client_connect(id)
  783. {
  784. asked_sql[id]=0
  785. wczytalo[id] = false
  786. if(g_boolsqlOK)
  787. Loadstats(id)
  788. else set_task(3.0, "Sprawdz_baze", id+TASK_LOAD_STATS);
  789.  
  790. }
  791.  
  792. public client_disconnect(id)
  793. {
  794. if(wczytalo[id])
  795. DodajWpis(id)
  796. }
  797. //========================================================
  798. /// Uchwyt do bazy oraz wyczytanie i zapisanie danych
  799. //========================================================
  800. public sql_start()
  801. {
  802. if ( !get_pcvar_num(p_Enabled))
  803. return;
  804.  
  805. if(g_boolsqlOK) return;
  806.  
  807. new szHost[64], szUser[32], szPass[32], szDB[128];
  808.  
  809. get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
  810. get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
  811. get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
  812. get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
  813.  
  814. g_SqlTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB);
  815.  
  816. new q_command[2098]
  817.  
  818. new iLen=0, iMax=sizeof(q_command) - 1
  819.  
  820. iLen += formatex(q_command[iLen], iMax-iLen,"CREATE TABLE IF NOT EXISTS zm_osiagniecia_testy ( ")
  821. iLen += formatex(q_command[iLen], iMax-iLen,"`nick` VARCHAR(48) NOT NULL, ")
  822. iLen += formatex(q_command[iLen], iMax-iLen,"`ammopacks` INT(6) DEFAULT 0, ")
  823. iLen += formatex(q_command[iLen], iMax-iLen,"`dam_done` INT(12) DEFAULT 0, ")
  824. iLen += formatex(q_command[iLen], iMax-iLen,"`zm_kill` INT(6) DEFAULT 0, ")
  825. iLen += formatex(q_command[iLen], iMax-iLen,"`hm_infkill` INT(6) DEFAULT 0, ")
  826. iLen += formatex(q_command[iLen], iMax-iLen,"`deaths` INT(6) DEFAULT 0, ")
  827. iLen += formatex(q_command[iLen], iMax-iLen,"`nem_kill` INT(4) DEFAULT 0, ")
  828. iLen += formatex(q_command[iLen], iMax-iLen,"`sur_kill` INT(4) DEFAULT 0, ")
  829. iLen += formatex(q_command[iLen], iMax-iLen,"`ass_kill` INT(4) DEFAULT 0, ")
  830. iLen += formatex(q_command[iLen], iMax-iLen,"`sni_kill` INT(4) DEFAULT 0, ")
  831. iLen += formatex(q_command[iLen], iMax-iLen,"`matki_kill` INT(4) DEFAULT 0, ")
  832. iLen += formatex(q_command[iLen], iMax-iLen,"`last_hm_kill` INT(4) DEFAULT 0, ")
  833. iLen += formatex(q_command[iLen], iMax-iLen,"`czas_online` INT(6) DEFAULT 0, ")
  834. iLen += formatex(q_command[iLen], iMax-iLen,"`prze_human` INT(6) DEFAULT 0, ")
  835.  
  836. iLen += formatex(q_command[iLen], iMax-iLen,"PRIMARY KEY (`nick`)) ")
  837. iLen += formatex(q_command[iLen], iMax-iLen,"DEFAULT CHARSET `utf8` COLLATE `utf8_general_ci`")
  838.  
  839. SQL_ThreadQuery(g_SqlTuple, "QueryCreateTable", q_command);
  840. }
  841. public QueryCreateTable( FailState, Handle:hQuery, szError[ ], Errcode, iData[ ], iDataSize, Float:fQueueTime )
  842. {
  843. if(FailState == TQUERY_CONNECT_FAILED) {
  844. log_to_file("sql_osiagniecia.log", "Could not connect to SQL database.");
  845. return PLUGIN_CONTINUE;
  846. }
  847. if(Errcode) {
  848. log_to_file("sql_ osiagniecia.log", "Error on Table query: %s", szError);
  849. return PLUGIN_CONTINUE;
  850. }
  851. if(FailState == TQUERY_QUERY_FAILED) {
  852. log_to_file("sql_osiagniecia.log", "Table Query failed.");
  853. return PLUGIN_CONTINUE;
  854. }
  855. g_boolsqlOK = 1;
  856. log_to_file("sql_osiagniecia.log", "Prawidlowe polaczenie");
  857.  
  858.  
  859.  
  860. return PLUGIN_CONTINUE;
  861. }
  862.  
  863.  
  864. public Sprawdz_baze(id)
  865. {
  866. id -= TASK_LOAD_STATS
  867. if(g_boolsqlOK)
  868. Loadstats(id)
  869. else
  870. {
  871. if(task_exists(id+TASK_LOAD_STATS))
  872. remove_task(id+TASK_LOAD_STATS)
  873.  
  874. set_task(3.0, "Sprawdz_baze", id+TASK_LOAD_STATS);
  875. }
  876. return PLUGIN_CONTINUE;
  877. }
  878.  
  879.  
  880. public Loadstats(id)
  881. {
  882. if(is_user_bot(id) || asked_sql[id])
  883. return PLUGIN_HANDLED;
  884. if(!module_exists("mysql"))
  885. {
  886. log_to_file("sql.log", "Modul mysql nie jest zaladowany gdy funkcja mysql sie odpala!");
  887. return PLUGIN_HANDLED;
  888. }
  889.  
  890. if(g_boolsqlOK) {
  891. new data[1];
  892. data[0] = id;
  893.  
  894. new name[48], q_command[2048];
  895. get_user_name(id, name, 47);
  896. replace_all(name, 47, "'", "\'");
  897. strtolower(name)
  898.  
  899. formatex(q_command, 511, "SELECT * FROM `%s` WHERE `nick`='%s'", g_sqlTable, name);
  900.  
  901. SQL_ThreadQuery(g_SqlTuple, "Load_stats_handle", q_command, data, 1);
  902.  
  903. asked_sql[id] = 1;
  904. }
  905. else sql_start();
  906.  
  907. return PLUGIN_HANDLED;
  908. }
  909. public Load_stats_handle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
  910. {
  911. new id = Data[0];
  912. asked_sql[id] = 0;
  913.  
  914.  
  915. if(FailState == TQUERY_CONNECT_FAILED) {
  916. log_to_file("sql.log", "Could not connect to SQL database.");
  917. return PLUGIN_CONTINUE;
  918. }
  919. if(FailState == TQUERY_QUERY_FAILED) {
  920. log_to_file("sql.log", "Load_xp Query failed.");
  921. return PLUGIN_CONTINUE;
  922. }
  923. if(Errcode) {
  924. log_to_file("sql.log", "Error on Load_xp query: %s", Error);
  925. return PLUGIN_CONTINUE;
  926. }
  927.  
  928. if(SQL_MoreResults(Query))
  929. {
  930. for (new i = 0 ; i < LICZBA_OSIAGNIEC; i++){
  931.  
  932. g_stats[id][i] = SQL_ReadResult(Query, i+1)
  933. ilosc[id][i] = 0
  934. }
  935. wczytalo[id] = true;
  936. }
  937. else
  938. {
  939. for (new i = 0 ; i < LICZBA_OSIAGNIEC; i++){
  940.  
  941. g_stats[id][i] = 0
  942. ilosc[id][i] = 0
  943. }
  944. wczytalo[id] = true
  945. }
  946. wylicz(id)
  947. return PLUGIN_CONTINUE;
  948. }
  949.  
  950.  
  951. public TaskZapiszStats()
  952. {
  953. if(g_boolsqlOK)
  954. {
  955. for(new id = 1; id <= 32; id++)
  956. {
  957. if(!is_user_connected(id) || is_user_hltv(id))
  958. continue;
  959. if(ilosc_wpisow >= 33)
  960. {
  961. ZakonczWpis_Zapiszstats();
  962. }
  963. DodajWpis(id);
  964. }
  965. ZakonczWpis_Zapiszstats()
  966. }
  967. else sql_start();
  968. }
  969. public ZakonczWpis_Zapiszstats()
  970. {
  971. replace(ZapiszStats[giLen-1], giLen, ZapiszStats[giLen-1], "")
  972.  
  973. giLen -= 1
  974.  
  975. giLen += formatex(ZapiszStats[giLen], giMax-giLen," ON DUPLICATE KEY UPDATE `ammopacks`=VALUES(`ammopacks`), `dam_done`=VALUES(`dam_done`), `zm_kill`=VALUES(`zm_kill`), `hm_infkill`=VALUES(`hm_infkill`), `deaths`=VALUES(`deaths`), ")
  976. giLen += formatex(ZapiszStats[giLen], giMax-giLen,"`nem_kill`=VALUES(`nem_kill`), `sur_kill`=VALUES(`sur_kill`), `ass_kill`=VALUES(`ass_kill`), `sni_kill`=VALUES(`sni_kill`), `matki_kill`=VALUES(`matki_kill`), `last_hm_kill`=VALUES(`last_hm_kill`), `czas_online`=VALUES(`czas_online`), `prze_human`=VALUES(`prze_human`)")
  977.  
  978. log_to_file("test_zapis_osc.log", "%s", ZapiszStats);
  979.  
  980. if(ilosc_wpisow > 0)
  981. SQL_ThreadQuery(g_SqlTuple, "ZapiszStatsHandle", ZapiszStats);
  982. else ResetujZapytanie();
  983.  
  984. return;
  985. }
  986. public ZapiszStatsHandle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize) {
  987.  
  988. ResetujZapytanie()
  989.  
  990. if(Errcode) {
  991. log_to_file("sql_osc.log", "Error on Save_xp query: %s", Error);
  992. return PLUGIN_CONTINUE;
  993. }
  994. if(FailState == TQUERY_QUERY_FAILED) {
  995. log_to_file("sql_osc.log", "Save_xp Query failed.");
  996. return PLUGIN_CONTINUE;
  997. }
  998. if(FailState == TQUERY_CONNECT_FAILED) {
  999. log_to_file("sql_osc.log", "Could not connect to SQL database.");
  1000. return PLUGIN_CONTINUE;
  1001. }
  1002.  
  1003. // client_print(0, print_chat,"Exp zostal zapisany");
  1004.  
  1005. return PLUGIN_CONTINUE;
  1006. }
  1007.  
  1008. public DodajWpis(id)
  1009. {
  1010. if(!wczytalo[id] || is_user_hltv(id))
  1011. return PLUGIN_CONTINUE;
  1012. if(ilosc_wpisow >= 64)
  1013. {
  1014. ZakonczWpis_Zapiszstats();
  1015. }
  1016. new name[48];
  1017.  
  1018. get_user_name(id, name, 47)
  1019. replace_all(name, 47, "'", "\'")
  1020. strtolower(name)
  1021.  
  1022. giLen += formatex(ZapiszStats[giLen], giMax-giLen,"('%s',%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d),",name,g_stats[id][0],g_stats[id][1],g_stats[id][2],g_stats[id][3],g_stats[id][4],g_stats[id][5],g_stats[id][6],g_stats[id][7],g_stats[id][8],g_stats[id][9],g_stats[id][10],g_stats[id][11],g_stats[id][12])
  1023.  
  1024.  
  1025. ilosc_wpisow++
  1026.  
  1027. return PLUGIN_CONTINUE;
  1028. }
  1029.  
  1030. public ResetujZapytanie()
  1031. {
  1032. ZapiszStats = ""
  1033. ilosc_wpisow = 0
  1034. giLen=0, giMax=sizeof(ZapiszStats) - 1
  1035. giLen += formatex(ZapiszStats[giLen], giMax-giLen,"INSERT INTO `zm_osiagniecia_testy`(`nick`, `ammopacks`, `dam_done`, `zm_kill`, `hm_infkill`, `deaths`, `nem_kill`, `sur_kill`, `ass_kill`, `sni_kill`, `matki_kill`, `last_hm_kill`, `czas_online`,`prze_human`) VALUES ")
  1036.  
  1037. return PLUGIN_CONTINUE;
  1038. }
  1039.  
  1040. public plugin_end() {
  1041. if(g_SqlTuple != Empty_Handle)
  1042. {
  1043. SQL_FreeHandle(g_SqlTuple) //free connection handle here
  1044. }
  1045.  
  1046. }
  1047. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  1048. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
  1049. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement