MegastoRM

final_zp_lvl

Sep 30th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.46 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];
  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.  
  43. register_concmd("zp_set_lvl", "cmd_lvl", ADMIN_RCON, "<nick> <level>");
  44.  
  45. g_sync1 = CreateHudSyncObj()
  46. }
  47.  
  48. public plugin_precache()
  49. {
  50. mkdir(conffolder)
  51. if(!file_exists(cfgfajl))
  52. {
  53. write_file(cfgfajl,"*****************************[ZP LVL Podesavanja]*****************************")
  54. write_file(cfgfajl,"<<----------------Ovde podesavate sve cvarove vezane za plugin---------------->>")
  55. write_file(cfgfajl," ")
  56. write_file(cfgfajl,"zp_lvl_killxp ^"55^" //XP za kill")
  57. write_file(cfgfajl,"zp_lvl_red ^"0^" //Kolicina-Nijansa crvene")
  58. write_file(cfgfajl,"zp_lvl_green ^"200^" //Kolicina-Nijansa zelene")
  59. write_file(cfgfajl,"zp_lvl_blue ^"250^" //Kolicina-Nijansa plave")
  60. }
  61. server_cmd("exec %s", cfgfajl)
  62. server_exec()
  63. }
  64.  
  65. public cmd_lvl(id, level, cid)
  66. {
  67. if(!cmd_access(id,level,cid,2))
  68. return PLUGIN_HANDLED;
  69.  
  70. new arg1[33];
  71. new arg2[6];
  72. read_argv(1, arg1, 32);
  73. read_argv(2, arg2, 5);
  74. new player = cmd_target(id, arg1);
  75. if(!is_user_connected(player))
  76. return PLUGIN_HANDLED;
  77. new value = str_to_num(arg2)-1;
  78.  
  79. xp_igraca[player] = xp_za_level(value);
  80. level_igraca[player] = 0;
  81. proverilvl(player);
  82. return PLUGIN_HANDLED;
  83. }
  84.  
  85. public pokazi_podatke(id)
  86. {
  87. id -= HUD
  88.  
  89. if(!is_user_alive(id))
  90. return PLUGIN_HANDLED
  91.  
  92. set_task(0.1, "pokazi_podatke", id+HUD);
  93.  
  94. new ime[32]
  95.  
  96. get_user_name(id, ime, charsmax(ime))
  97.  
  98. set_dhudmessage(_pcvar_boja[0], _pcvar_boja[1], _pcvar_boja[2], 0.02, 0.75, 0, 0.0, 0.3, 0.0, 0.0);
  99. 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]])
  100. return PLUGIN_CONTINUE;
  101. }
  102.  
  103. public player_death()
  104. {
  105. new attacker = read_data(1)
  106.  
  107. if(!is_user_connected(attacker))
  108. return PLUGIN_HANDLED
  109.  
  110. new xp_za_ubistvo = get_pcvar_num(_pcvar_killxp)
  111. if(level_igraca[attacker] < max_level || xp_igraca[attacker] >= 1999)
  112. {
  113. xp_igraca[attacker] += xp_za_ubistvo
  114. proverilvl(attacker)
  115. }
  116. else
  117. {
  118. level_igraca[attacker] = max_level
  119. proverilvl(attacker)
  120. }
  121.  
  122.  
  123. return PLUGIN_CONTINUE
  124. }
  125.  
  126. public proverilvl(id)
  127. {
  128. if(level_igraca[id] >= max_level)
  129. return PLUGIN_HANDLED
  130.  
  131. if(level_igraca[id] < max_level)
  132. {
  133. while(xp_igraca[id] >= xp_za_level(level_igraca[id]))
  134. {
  135. level_igraca[id]++
  136. set_hudmessage(200, 0, 0, -1.0, 0.25, 0, 1.0, 2.0, 0.1, 0.2);
  137. ShowSyncHudMsg(id, g_sync1, "%i level!", level_igraca[id]);
  138. }
  139. }
  140. else
  141. {
  142. level_igraca[id] = max_level
  143. }
  144.  
  145. switch(level_igraca[id])
  146. {
  147. case 1:
  148. {
  149. CinX[id] = 1
  150. }
  151. case 2..3:
  152. {
  153. CinX[id] = 2
  154. }
  155. case 4..7:
  156. {
  157. CinX[id] = 3
  158. }
  159. case 8..15:
  160. {
  161. CinX[id] = 4
  162. }
  163. case 16..23:
  164. {
  165. CinX[id] = 5
  166. }
  167. case 24..31:
  168. {
  169. CinX[id] = 6
  170. }
  171. case 32..63:
  172. {
  173. CinX[id] = 7
  174. }
  175. case 64..74:
  176. {
  177. CinX[id] = 8
  178. }
  179. case 75..127:
  180. {
  181. CinX[id] = 9
  182. }
  183. case 128..155:
  184. {
  185. CinX[id] = 10
  186. }
  187. case 156..191:
  188. {
  189. CinX[id] = 11
  190. }
  191. case 192..200:
  192. {
  193. CinX[id] = 12
  194. }
  195. }
  196.  
  197. return PLUGIN_CONTINUE
  198. }
  199.  
  200. public zp_user_infected_post()
  201. {
  202. new attacker = read_data(1)
  203.  
  204. if(!is_user_connected(attacker))
  205. return PLUGIN_HANDLED
  206.  
  207. xp_igraca[attacker]++
  208. proverilvl(attacker)
  209.  
  210. return PLUGIN_CONTINUE
  211. }
  212.  
  213. public xp_za_level(lvl)
  214. return lvl*10;
  215.  
  216.  
  217. public client_putinserver(id)
  218. {
  219. level_igraca[id] = 1
  220.  
  221. Ucitaj(id)
  222. set_task(3.0, "pokazi_podatke", id+HUD);
  223. }
  224.  
  225. public client_disconnect(id)
  226. {
  227. Sacuvaj(id)
  228. }
  229.  
  230. public Sacuvaj(id)
  231. {
  232. new vltkey[128]
  233. new podaci[256]
  234. new steam_id_igraca[64];
  235. format(podaci, charsmax(podaci),"#%i#%i#%i", xp_igraca[id], level_igraca[id], CinX[id]);
  236.  
  237. get_user_authid(id, steam_id_igraca, charsmax(steam_id_igraca))
  238.  
  239. format(vltkey, charsmax(vltkey),"%s-zm_lvl_mod", steam_id_igraca);
  240. nvault_set(g_podaci,vltkey,podaci);
  241.  
  242. return PLUGIN_CONTINUE;
  243. }
  244.  
  245. public Ucitaj(id)
  246. {
  247. new vltkey[128]
  248. new podaci[256]
  249. new steam_id_igraca[64];
  250.  
  251. get_user_authid(id, steam_id_igraca, charsmax(steam_id_igraca))
  252.  
  253. format(vltkey, charsmax(vltkey),"%s-zm_lvl_mod", steam_id_igraca);
  254. nvault_get(g_podaci,vltkey,podaci,255);
  255.  
  256. replace_all(podaci, 255, "#", " ");
  257.  
  258. new plrinfo[3][32];
  259.  
  260. parse(podaci, plrinfo[0], 31, plrinfo[1], 31, plrinfo[2], 31);
  261.  
  262. xp_igraca[id] = str_to_num(plrinfo[0]);
  263. level_igraca[id] = str_to_num(plrinfo[1])>0?str_to_num(plrinfo[1]):1;
  264. CinX[id] = str_to_num(plrinfo[2]);
  265.  
  266. return PLUGIN_CONTINUE;
  267. }
  268.  
  269. public plugin_end()
  270. nvault_close(g_podaci)
Advertisement
Add Comment
Please, Sign In to add comment