Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. #include <fun>
  5. #include <vault>
  6.  
  7. #define MAXCLASSES 5
  8.  
  9. new PlayerXP[33]
  10. new PlayerLevel[33]
  11.  
  12. new msgtext
  13.  
  14. new const LEVELS[6] = {
  15. 100,
  16. 200,
  17. 400,
  18. 800,
  19. 1600,
  20. 3200
  21. }
  22.  
  23. public plugin_init()
  24. {
  25. register_plugin("Animal Mod", "1.0", "Invalid")
  26.  
  27. register_cvar("sv_animalmod", "1")
  28.  
  29. register_event("DeathMsg", "DeathMsg", "a")
  30.  
  31. register_cvar("xp_per_kill", "20")
  32.  
  33. register_cvar("SaveXP", "1")
  34.  
  35. register_event("ResetHUD", "ResetHud", "b")
  36.  
  37. msgtext = get_user_msgid("statusText")
  38.  
  39. register_clcmd ("say /ps", "ShowHUD")
  40. }
  41.  
  42. public SaveXP(id)
  43. {
  44. new authid[32];
  45. get_user_authid(id,authid,31);
  46.  
  47. new vaultkey[64], vaultdata[64];
  48.  
  49. //Save their XP
  50. format(vaultkey,63,"ANIMAL-%s-xp",authid);
  51. format(vaultdata,63,"%d",PlayerXP[id]);
  52. set_vaultdata(vaultkey,vaultdata);
  53.  
  54. //Save their level
  55. format(vaultkey,63,"ANIMAL-%s-level",authid);
  56. format(vaultdata,63,"%d",PlayerLevel[id]);
  57. set_vaultdata(vaultkey,vaultdata);
  58. }
  59.  
  60. public LoadXP(id)
  61. {
  62. new authid[32];
  63. get_user_authid(id,authid,31);
  64.  
  65. new vaultkey[64], vaultdata[64];
  66.  
  67. //Load their XP
  68. format(vaultkey,63,"ANIMAL-%s-xp",authid);
  69. get_vaultdata(vaultkey,vaultdata,63);
  70. PlayerXP[id] = str_to_num(vaultdata);
  71.  
  72. //Load their level
  73. format(vaultkey,63,"ANIMAL-%s-level",authid);
  74. get_vaultdata(vaultkey,vaultdata,63);
  75. PlayerLevel[id] = str_to_num(vaultdata);
  76. }
  77.  
  78. public client_connect(id)
  79. {
  80. //Only load their XP if our SaveXP cvar is 1.
  81. if(get_cvar_num("SaveXP") == 1) {
  82.  
  83. LoadXP(id)
  84.  
  85. //Add a message if you want....
  86. client_print(id, print_chat, "[Animal Mod] XP Loaded!")
  87. client_print(id, print_chat, "[Animal Mod] You are level %s and %s XP", PlayerLevel[id], PlayerXP[id])
  88. }
  89. }
  90.  
  91. public client_disconnect(id)
  92. {
  93. //Only save their XP if our SaveXP cvar is 1.
  94. if(get_cvar_num("SaveXP") == 1) {
  95.  
  96. SaveXP(id)
  97. }
  98. }
  99.  
  100. public DeathMsg() //Note that i only had (), and not (id)
  101. {
  102. //Lets check if "sv_animalmod" is on. If its off, we'll stop the function.
  103. if(get_cvar_num("sv_animalmod") == 0) {
  104. return PLUGIN_HANDLED
  105. }
  106.  
  107. //Now we create a "attacker" varriable. So the XP will be given to the killer, and not all players on the server.
  108. new attacker = read_data(1)
  109.  
  110. //Now the plugin will check if the attacker doesnt have a class, and if he doesnt, the function will stop.
  111.  
  112. //Now lets see if the attacker allready has level 6, and doesnt need more XP, and if he is, stop the function.
  113. //You can remove this if you want, and let the player get as much XP he want. But we wont get more than level 6 anyway.
  114. if(PlayerLevel[attacker] == 6) {
  115. return PLUGIN_HANDLED
  116. }
  117.  
  118. //Now we can add XP to the attacker.
  119. PlayerXP[attacker] += get_cvar_num("XP_per_kill") //Add the amout of XP you have on the "XP_per_kill" cvar.
  120.  
  121. //Now we check if the attacker has enough XP for a new level. And if he has, we add it.
  122. if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {
  123.  
  124. //Add his level...
  125. PlayerLevel[attacker] += 1
  126.  
  127. //Now you can make a "congratualtions" message if you want...
  128. client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are now level %i!", PlayerLevel[attacker])
  129.  
  130. //Lets save his XP every time he gets a level incase the server crashes or something. So they wont loose it all.
  131. if(get_cvar_num("SaveXP") == 1) {
  132.  
  133. SaveXP(attacker)
  134. }
  135.  
  136.  
  137. //Show His New Level on the HUD message.
  138. //Ill get back to this later...
  139. ShowHUD(attacker)
  140. }
  141.  
  142. //Show new HUD if you didnt get level too. (To show the new XP)
  143. //Ill get back to this later...
  144. ShowHUD(attacker)
  145.  
  146. return PLUGIN_CONTINUE
  147. }
  148.  
  149. public ShowHUD(id)
  150. {
  151. new HUD[51]
  152.  
  153. //This is the stuff that will actually show in game.
  154. format(HUD, 50, "Level: %i XP: %i", PlayerLevel[id], PlayerXP[id])
  155.  
  156. message_begin(MSG_ONE, msgtext, {0,0,0}, id)
  157. write_byte(0)
  158. write_string(HUD)
  159. message_end()
  160. return
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement