MegastoRM

zm_lvl_fixd

Sep 30th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <dhudmessage>
  6. #include <nvault>
  7. #include <zombieplague>
  8.  
  9. #define HUD 672
  10.  
  11. new max_level = 200, g_sync1, g_podaci, _pcvar_killxp, xp_igraca[33], CinX[33], level_igraca[33] = 1, _pcvar_boja[3], _pcvar_pozicija[2]
  12.  
  13. new const cfgfajl[] = "addons/amxmodx/configs/zp_lvl_podesavanja.cfg"
  14. new const conffolder[] = "addons/amxmodx/configs"
  15.  
  16. new const Cinovi[][]=
  17. {
  18. "Pocetnik",
  19. "Vojnik",
  20. "Regrut",
  21. "Admiral",
  22. "Pro Strelac",
  23. "General",
  24. "Marsal",
  25. "Zombie Pro",
  26. "Narkoman",
  27. "Zombie Master",
  28. "Swat",
  29. "Zombie Kralj"
  30. }
  31.  
  32. public plugin_init() {
  33. register_plugin("[ZP] Level System", "1.0b", "MegastorM")
  34. g_podaci = nvault_open("zm_level_mod");
  35.  
  36. register_event("DeathMsg", "player_death", "ade");
  37.  
  38. _pcvar_killxp = register_cvar("zp_lvl_killxp","1")
  39. _pcvar_boja[0] = register_cvar("zp_lvl_red","0")
  40. _pcvar_boja[1] = register_cvar("zp_lvl_green","200")
  41. _pcvar_boja[2] = register_cvar("zp_lvl_blue","250")
  42. _pcvar_pozicija[0] = register_cvar("zp_lvl_x","0.02")
  43. _pcvar_pozicija[1] = register_cvar("zp_lvl_y","-1.0")
  44.  
  45. register_concmd("zp_set_lvl", "cmd_lvl", ADMIN_RCON, "<nick> <level>");
  46.  
  47. g_sync1 = CreateHudSyncObj()
  48. }
  49.  
  50. public plugin_precache()
  51. {
  52. mkdir(conffolder)
  53. if(!file_exists(cfgfajl))
  54. {
  55. write_file(cfgfajl,"*****************************[ZP LVL Podesavanja]*****************************")
  56. write_file(cfgfajl,"<<----------------Ovde podesavate sve cvarove vezane za plugin---------------->>")
  57. write_file(cfgfajl," ")
  58. write_file(cfgfajl,"zp_lvl_killxp ^"1^" //XP za kill")
  59. write_file(cfgfajl,"zp_lvl_red ^"0^" //Kolicina-Nijansa crvene")
  60. write_file(cfgfajl,"zp_lvl_green ^"200^" //Kolicina-Nijansa zelene")
  61. write_file(cfgfajl,"zp_lvl_blue ^"250^" //Kolicina-Nijansa plave")
  62. write_file(cfgfajl,"zp_lvl_x ^"0.02^" //Pozicija po X osi(0.01-1.0(-1.0 za centar))")
  63. write_file(cfgfajl,"zp_lvl_y ^"-1.0^" //Pozicija po Y osi(0.01-1.0(-1.0 za centar))")
  64. }
  65. server_cmd("exec %s", cfgfajl)
  66. server_exec()
  67. }
  68.  
  69. public Reset(id)
  70. {
  71. xp_igraca[id] = 1
  72. proverilvl(id)
  73. client_print(id, print_chat, "[ZP] Uspesno si resetovao levele")
  74. }
  75.  
  76. public cmd_lvl(id, level, cid)
  77. {
  78. if(!cmd_access(id, level, cid, 3))
  79. return PLUGIN_HANDLED;
  80.  
  81. new arg1[33];
  82. new arg2[6];
  83. read_argv(1, arg1, 32);
  84. read_argv(2, arg2, 5);
  85. new player = cmd_target(id, arg1);
  86. if(!is_user_connected(player))
  87. return PLUGIN_HANDLED;
  88.  
  89. new value = str_to_num(arg2)-1;
  90.  
  91. if(value > 199)
  92. {
  93. client_print(id, print_console, "Ne mozes postaviti igracu vise od 199 levela!")
  94. return PLUGIN_HANDLED
  95. }
  96. client_print(id, print_console, "Uspesno si postavio %s %d levela", player, value)
  97. xp_igraca[player] = xp_za_level(value);
  98. level_igraca[player] = 0;
  99. proverilvl(player);
  100. return PLUGIN_HANDLED;
  101. }
  102.  
  103. public pokazi_podatke(id)
  104. {
  105. id -= HUD
  106.  
  107. if(!is_user_connected(id))
  108. return PLUGIN_HANDLED
  109.  
  110. set_task(0.1, "pokazi_podatke", id+HUD);
  111.  
  112. new ime[32]
  113.  
  114. get_user_name(id, ime, charsmax(ime))
  115.  
  116. set_dhudmessage(get_pcvar_num(_pcvar_boja[0]), get_pcvar_num(_pcvar_boja[1]), get_pcvar_num(_pcvar_boja[2]), get_pcvar_float(_pcvar_pozicija[0]), get_pcvar_float(_pcvar_pozicija[1]), 0, 0.0, 0.3, 0.0, 0.0);
  117. show_dhudmessage(id, "[Nick: %s]^n[Level: %i]^n[Exp: %i / %i]^n[Cin: %s]",ime,level_igraca[id], xp_igraca[id], xp_za_level(level_igraca[id]), Cinovi[CinX[id]])
  118. return PLUGIN_CONTINUE;
  119. }
  120.  
  121. public zp_user_humanized_post(id)
  122. {
  123. Ucitaj(id)
  124. set_task(0.5, "pokazi_podatke", id+HUD);
  125. }
  126.  
  127. public player_death()
  128. {
  129. new attacker = read_data(1)
  130.  
  131. if(!is_user_connected(attacker))
  132. return PLUGIN_HANDLED
  133.  
  134. new xp_za_ubistvo = get_pcvar_num(_pcvar_killxp)
  135. if(level_igraca[attacker] < max_level || xp_igraca[attacker] >= 1999)
  136. {
  137. xp_igraca[attacker] += xp_za_ubistvo
  138. proverilvl(attacker)
  139. }
  140. else
  141. {
  142. level_igraca[attacker] = max_level
  143. proverilvl(attacker)
  144. }
  145.  
  146.  
  147. return PLUGIN_CONTINUE
  148. }
  149.  
  150. public proverilvl(id)
  151. {
  152. if(level_igraca[id] >= max_level)
  153. return PLUGIN_HANDLED
  154.  
  155. if(level_igraca[id] < max_level)
  156. {
  157. while(xp_igraca[id] >= xp_za_level(level_igraca[id]))
  158. {
  159. level_igraca[id]++
  160. set_hudmessage(200, 0, 0, -1.0, 0.25, 0, 1.0, 2.0, 0.1, 0.2);
  161. ShowSyncHudMsg(id, g_sync1, "%i level!", level_igraca[id]);
  162. }
  163. }
  164. else
  165. {
  166. level_igraca[id] = max_level
  167. }
  168.  
  169. switch(level_igraca[id])
  170. {
  171. case 1:
  172. {
  173. CinX[id] = 1
  174. }
  175. case 2..3:
  176. {
  177. CinX[id] = 2
  178. }
  179. case 4..7:
  180. {
  181. CinX[id] = 3
  182. }
  183. case 8..15:
  184. {
  185. CinX[id] = 4
  186. }
  187. case 16..23:
  188. {
  189. CinX[id] = 5
  190. }
  191. case 24..31:
  192. {
  193. CinX[id] = 6
  194. }
  195. case 32..63:
  196. {
  197. CinX[id] = 7
  198. }
  199. case 64..74:
  200. {
  201. CinX[id] = 8
  202. }
  203. case 75..127:
  204. {
  205. CinX[id] = 9
  206. }
  207. case 128..155:
  208. {
  209. CinX[id] = 10
  210. }
  211. case 156..191:
  212. {
  213. CinX[id] = 11
  214. }
  215. case 192..200:
  216. {
  217. CinX[id] = 12
  218. }
  219. }
  220.  
  221. return PLUGIN_CONTINUE
  222. }
  223.  
  224. public zp_user_infected_post()
  225. {
  226. new attacker = read_data(1)
  227. new victim = read_data(2)
  228.  
  229. if(!is_user_connected(attacker))
  230. return PLUGIN_HANDLED
  231.  
  232. xp_igraca[attacker]++
  233. proverilvl(attacker)
  234.  
  235. set_task(0.5, "pokazi_podatke", attacker+HUD);
  236. set_task(0.5, "pokazi_podatke", victim+HUD);
  237.  
  238. return PLUGIN_CONTINUE
  239. }
  240.  
  241. public xp_za_level(lvl)
  242. return lvl*10;
  243.  
  244.  
  245. public client_putinserver(id)
  246. {
  247. level_igraca[id] = 1
  248.  
  249. Ucitaj(id)
  250. set_task(3.0, "pokazi_podatke", id+HUD);
  251. }
  252.  
  253. public client_disconnect(id)
  254. {
  255. Sacuvaj(id)
  256. }
  257.  
  258. public Sacuvaj(id)
  259. {
  260. new vltkey[128]
  261. new podaci[256]
  262. new steam_id_igraca[64];
  263. format(podaci, charsmax(podaci),"#%i#%i#%i", xp_igraca[id], level_igraca[id], CinX[id]);
  264.  
  265. get_user_authid(id, steam_id_igraca, charsmax(steam_id_igraca))
  266.  
  267. format(vltkey, charsmax(vltkey),"%s-zm_lvl_mod", steam_id_igraca);
  268. nvault_set(g_podaci,vltkey,podaci);
  269.  
  270. return PLUGIN_CONTINUE;
  271. }
  272.  
  273. public Ucitaj(id)
  274. {
  275. new vltkey[128]
  276. new podaci[256]
  277. new steam_id_igraca[64];
  278.  
  279. get_user_authid(id, steam_id_igraca, charsmax(steam_id_igraca))
  280.  
  281. format(vltkey, charsmax(vltkey),"%s-zm_lvl_mod", steam_id_igraca);
  282. nvault_get(g_podaci,vltkey,podaci,255);
  283.  
  284. replace_all(podaci, 255, "#", " ");
  285.  
  286. new plrinfo[3][32];
  287.  
  288. parse(podaci, plrinfo[0], 31, plrinfo[1], 31, plrinfo[2], 31);
  289.  
  290. xp_igraca[id] = str_to_num(plrinfo[0]);
  291. level_igraca[id] = str_to_num(plrinfo[1])>0?str_to_num(plrinfo[1]):1;
  292. CinX[id] = str_to_num(plrinfo[2]);
  293.  
  294. return PLUGIN_CONTINUE;
  295. }
  296.  
  297. public plugin_end()
  298. nvault_close(g_podaci)
Advertisement
Add Comment
Please, Sign In to add comment