MegastoRM

sad?

Sep 29th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 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;
  12.  
  13. new const Cinovi[][]=
  14. {
  15. "Pocetnik",
  16. "Vojnik",
  17. "Regrut",
  18. "Admiral",
  19. "Pro Strelac",
  20. "General",
  21. "Marsal",
  22. "Zombie Pro",
  23. "Narkoman",
  24. "Zombie Master",
  25. "Swat",
  26. "Zombie Kralj"
  27. }
  28.  
  29. public plugin_init() {
  30. register_plugin("[ZP] Level System", "1.0b", "MegastorM")
  31. g_podaci = nvault_open("zm_level_mod");
  32.  
  33. register_event("DeathMsg", "player_death", "ade");
  34.  
  35. _pcvar_killxp = register_cvar("zp_lvl_killxp","1")
  36.  
  37. register_concmd("zp_set_lvl", "cmd_lvl", ADMIN_RCON, "<nick> <level>");
  38.  
  39. g_sync1 = CreateHudSyncObj()
  40. }
  41.  
  42. public cmd_lvl(id, level, cid)
  43. {
  44. if(!cmd_access(id,level,cid,2))
  45. return PLUGIN_HANDLED;
  46.  
  47. new arg1[33];
  48. new arg2[6];
  49. read_argv(1, arg1, 32);
  50. read_argv(2, arg2, 5);
  51. new player = cmd_target(id, arg1);
  52. if(!is_user_connected(player))
  53. return PLUGIN_HANDLED;
  54. new value = str_to_num(arg2)-1;
  55.  
  56. xp_igraca[player] = xp_za_level(value);
  57. level_igraca[player] = 0;
  58. proverilvl(player);
  59. return PLUGIN_HANDLED;
  60. }
  61.  
  62. public pokazi_podatke(id)
  63. {
  64. id -= HUD
  65.  
  66. if(!is_user_alive(id))
  67. return PLUGIN_HANDLED
  68.  
  69. set_task(0.1, "pokazi_podatke", id+HUD);
  70.  
  71. new ime[32]
  72.  
  73. get_user_name(id, ime, charsmax(ime))
  74.  
  75. set_dhudmessage(200, 0, 0, 0.02, 0.75, 0, 0.0, 0.3, 0.0, 0.0);
  76. 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]])
  77. return PLUGIN_CONTINUE;
  78. }
  79.  
  80. public player_death()
  81. {
  82. new attacker = read_data(1)
  83.  
  84. if(!is_user_connected(attacker))
  85. return PLUGIN_HANDLED
  86.  
  87. new xp_za_ubistvo = get_pcvar_num(_pcvar_killxp)
  88. if(level_igraca[attacker] < max_level || xp_igraca[attacker] >= 1999)
  89. {
  90. xp_igraca[attacker] += xp_za_ubistvo
  91. proverilvl(attacker)
  92. }
  93. else
  94. {
  95. level_igraca[attacker] = max_level
  96. proverilvl(attacker)
  97. }
  98.  
  99.  
  100. return PLUGIN_CONTINUE
  101. }
  102.  
  103. public proverilvl(id)
  104. {
  105. if(level_igraca[id] >= max_level)
  106. return PLUGIN_HANDLED
  107.  
  108. if(level_igraca[id] < max_level)
  109. {
  110. while(xp_igraca[id] >= xp_za_level(level_igraca[id]))
  111. {
  112. level_igraca[id]++
  113. set_hudmessage(200, 0, 0, -1.0, 0.25, 0, 1.0, 2.0, 0.1, 0.2);
  114. ShowSyncHudMsg(id, g_sync1, "%i level!", level_igraca[id]);
  115. }
  116. }
  117. else
  118. {
  119. level_igraca[id] = max_level
  120. }
  121.  
  122. switch(level_igraca[id])
  123. {
  124. case 1:
  125. {
  126. CinX[id] = 1
  127. }
  128. case 2..3:
  129. {
  130. CinX[id] = 2
  131. }
  132. case 4..7:
  133. {
  134. CinX[id] = 3
  135. }
  136. case 8..15:
  137. {
  138. CinX[id] = 4
  139. }
  140. case 16..23:
  141. {
  142. CinX[id] = 5
  143. }
  144. case 24..31:
  145. {
  146. CinX[id] = 6
  147. }
  148. case 32..63:
  149. {
  150. CinX[id] = 7
  151. }
  152. case 64..74:
  153. {
  154. CinX[id] = 8
  155. }
  156. case 75..127:
  157. {
  158. CinX[id] = 9
  159. }
  160. case 128..155:
  161. {
  162. CinX[id] = 10
  163. }
  164. case 156..191:
  165. {
  166. CinX[id] = 11
  167. }
  168. case 192..200:
  169. {
  170. CinX[id] = 12
  171. }
  172. }
  173.  
  174. return PLUGIN_CONTINUE
  175. }
  176.  
  177. public zp_user_infected_post()
  178. {
  179. new attacker = read_data(1)
  180.  
  181. if(!is_user_connected(attacker))
  182. return PLUGIN_HANDLED
  183.  
  184. xp_igraca[attacker]++
  185. proverilvl(attacker)
  186.  
  187. return PLUGIN_CONTINUE
  188. }
  189.  
  190. public xp_za_level(lvl)
  191. return lvl*10;
  192.  
  193.  
  194. public client_putinserver(id)
  195. {
  196. level_igraca[id] = 1
  197.  
  198. Ucitaj(id)
  199. set_task(3.0, "pokazi_podatke", id+HUD);
  200. }
  201.  
  202. public client_disconnect(id)
  203. {
  204. Sacuvaj(id)
  205. }
  206.  
  207. public Sacuvaj(id)
  208. {
  209. new vltkey[128]
  210. new podaci[256]
  211. new steam_id_igraca[64];
  212. format(podaci, charsmax(podaci),"#%i#%i#%i", xp_igraca[id], level_igraca[id], CinX[id]);
  213.  
  214. get_user_authid(id, steam_id_igraca, charsmax(steam_id_igraca))
  215.  
  216. format(vltkey, charsmax(vltkey),"%s-zm_lvl_mod", steam_id_igraca);
  217. nvault_set(g_podaci,vltkey,podaci);
  218.  
  219. return PLUGIN_CONTINUE;
  220. }
  221.  
  222. public Ucitaj(id)
  223. {
  224. new vltkey[128]
  225. new podaci[256]
  226. new steam_id_igraca[64];
  227.  
  228. get_user_authid(id, steam_id_igraca, charsmax(steam_id_igraca))
  229.  
  230. format(vltkey, charsmax(vltkey),"%s-zm_lvl_mod", steam_id_igraca);
  231. nvault_get(g_podaci,vltkey,podaci,255);
  232.  
  233. replace_all(podaci, 255, "#", " ");
  234.  
  235. new plrinfo[3][32];
  236.  
  237. parse(podaci, plrinfo[0], 31, plrinfo[1], 31, plrinfo[2], 31);
  238.  
  239. xp_igraca[id] = str_to_num(plrinfo[0]);
  240. level_igraca[id] = str_to_num(plrinfo[1])>0?str_to_num(plrinfo[1]):1;
  241. CinX[id] = str_to_num(plrinfo[2]);
  242.  
  243. return PLUGIN_CONTINUE;
  244. }
  245.  
  246. public plugin_end()
  247. nvault_close(g_podaci)
Advertisement
Add Comment
Please, Sign In to add comment