Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < nvault >
  3. #include < fakemeta >
  4.  
  5. #define PLUGIN_NAME "Level__System"
  6. #define PLUGIN_VERSION "0.1"
  7. #define PLUGIN_AUTHOR "Bos93 & FirsT"
  8.  
  9. #define MAX_CLIENTS 32
  10.  
  11. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  12.  
  13. enum (+= 100)
  14. {
  15. TASK_SHOWHUD = 10
  16. }
  17.  
  18. new const MAX_LEVELS[16] =
  19. {
  20. 0, //1
  21. 30, //2
  22. 50, //3
  23. 80, //4
  24. 120, //5
  25. 170, //6
  26. 280, //7
  27. 370, //8
  28. 490, //9
  29. 580, //10
  30. 800, //11
  31. 1000, //12
  32. 1400, //13
  33. 1900, //14
  34. 2600, //15
  35. 3500 //16
  36. }
  37. const Float:HUD_STATS_X = 0.02;
  38. const Float:HUD_STATS_Y = 0.9025;
  39. const Float:HUD_SPECT_X = -1.0;
  40. const Float:HUD_SPECT_Y = 0.8;
  41.  
  42. const PEV_SPEC_TARGET = pev_iuser2
  43.  
  44. new g_iLevel[ MAX_CLIENTS + 1 ],
  45. g_iExp[ MAX_CLIENTS + 1 ],
  46. g_playername[ MAX_CLIENTS + 1 ][ MAX_CLIENTS ];
  47.  
  48. new g_vault
  49.  
  50. public plugin_init( )
  51. {
  52. register_plugin ( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
  53.  
  54. register_event( "DeathMsg", "EV_DeathMsg", "a" );
  55.  
  56. g_vault = nvault_open("Levels__System")
  57.  
  58. }
  59.  
  60. public plugin_natives()
  61. {
  62.  
  63. register_native("zp_get_user_level", "native_get_user_level", 1)
  64. register_native("zp_set_user_level", "native_set_user_level", 1)
  65.  
  66. register_native("zp_get_user_exp", "native_get_user_exp", 1)
  67. register_native("zp_set_user_exp", "native_set_user_exp", 1)
  68. }
  69.  
  70.  
  71. public client_disconnect(id)
  72. {
  73. SaveData(id);
  74. }
  75.  
  76. public client_putinserver( iPlayer )
  77. {
  78. get_user_name(iPlayer, g_playername[iPlayer], charsmax(g_playername[]))
  79.  
  80. //set_task(1.0, "ShowHUD", iPlayer+TASK_SHOWHUD, _, _, "b")
  81.  
  82. LoadData( iPlayer );
  83. }
  84.  
  85. public plugin_end()
  86. {
  87. nvault_close(g_vault)
  88. }
  89.  
  90.  
  91. public EV_DeathMsg( )
  92. {
  93. static iVictim, iKiller;
  94. iVictim = read_data( 2 );
  95. iKiller = read_data( 1 );
  96.  
  97. if( !is_user_connected( iVictim ) )
  98. return;
  99.  
  100. if( iKiller == iVictim || !iKiller )
  101. return;
  102.  
  103. g_iExp[ iKiller ] += 1;
  104.  
  105. while( g_iExp[ iKiller ] >= MAX_LEVELS[ g_iLevel[ iKiller ] ] )
  106. {
  107. g_iLevel[ iKiller ] += 1;
  108. }
  109.  
  110.  
  111. }
  112.  
  113. public ShowHUD(taskid)
  114. {
  115.  
  116. static iPlayer
  117. iPlayer = ID_SHOWHUD;
  118.  
  119.  
  120. if (!is_user_alive( iPlayer ) )
  121. {
  122.  
  123. iPlayer = pev(iPlayer, PEV_SPEC_TARGET)
  124.  
  125. // Target not alive
  126. if (!is_user_alive(iPlayer) ) return;
  127. }
  128.  
  129. if (iPlayer != ID_SHOWHUD)
  130. {
  131. set_hudmessage( 100, 100, 100, HUD_SPECT_X, HUD_SPECT_Y, 0, 5.0, 3.0, 1.0, 1.0, -1 );
  132. show_hudmessage( ID_SHOWHUD , "Наблюдение за: %s^n[HP: %d] [Уровень: %d] [Опыт: %d / %d]", g_playername[ iPlayer ] , get_user_health(iPlayer), g_iLevel[ ID_SHOWHUD ] , g_iExp[ ID_SHOWHUD ] , (MAX_LEVELS[g_iLevel[ ID_SHOWHUD ]]) );
  133. }
  134. else
  135. {
  136. set_hudmessage( 0, 255, 0, HUD_STATS_X, HUD_STATS_Y, 0, 5.0, 3.0, 1.0, 1.0, -1 );
  137. show_hudmessage( ID_SHOWHUD , "[HP: %d] [Уровень: %d] [Опыт: %d / %d]", get_user_health(iPlayer), g_iLevel[ ID_SHOWHUD ] , g_iExp[ ID_SHOWHUD ] , (MAX_LEVELS[g_iLevel[ ID_SHOWHUD ]]));
  138. }
  139. }
  140.  
  141. public SaveData(id) {
  142. new AuthID[35]
  143. get_user_authid(id,AuthID,34)
  144.  
  145. new vaultkey[64],vaultdata[256]
  146. format(vaultkey,63,"%s-cso",AuthID)
  147. format(vaultdata,255,"%i#%i#",g_iLevel[id],g_iExp[id])
  148. nvault_set(g_vault,vaultkey,vaultdata)
  149.  
  150. return PLUGIN_CONTINUE
  151. }
  152.  
  153. public LoadData(id)
  154. {
  155. new AuthID[35]
  156. get_user_authid(id,AuthID,34)
  157.  
  158. new vaultkey[64],vaultdata[256]
  159. format(vaultkey,63,"%s-cso",AuthID)
  160. format(vaultdata,255,"%i#%i#",g_iLevel[id],g_iExp[id])
  161. nvault_get(g_vault,vaultkey,vaultdata,255)
  162.  
  163. replace_all(vaultdata, 255, "#", " ")
  164.  
  165. new experience[32], playerlevel[32]
  166.  
  167. parse(vaultdata, experience, 31, playerlevel, 31)
  168.  
  169. g_iLevel[id] = str_to_num(experience)
  170. g_iExp[id] = str_to_num(playerlevel)
  171.  
  172. return PLUGIN_CONTINUE
  173. }
  174.  
  175. public native_get_user_exp(id)
  176. {
  177. return g_iExp[id];
  178. }
  179.  
  180. public native_set_user_exp(id, amount)
  181. {
  182. g_iExp[id] = amount;
  183. }
  184.  
  185. public native_get_user_level(id)
  186. {
  187. return g_iLevel[id];
  188. }
  189.  
  190. public native_set_user_level(id, amount)
  191. {
  192. g_iLevel[id] = amount;
  193. }
  194.  
  195. stock color_print( const id , const input[], any:...)
  196. {
  197. new count = 1, players[32]
  198. static msg[191]
  199. vformat(msg, 190, input, 3)
  200.  
  201. replace_all(msg, 190, "!g", "^4" ) // Green Color
  202. replace_all(msg, 190, "!y", "^1" ) // Default Color
  203. replace_all(msg, 190, "!team", "^3" ) // Team Color
  204.  
  205. if (id) players[0] = id; else get_players(players, count, "ch")
  206. {
  207. for (new i = 0; i < count; i++)
  208. {
  209. if (is_user_connected(players[i]))
  210. {
  211. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText" ), _, players[i])
  212. write_byte(players[i]);
  213. write_string(msg);
  214. message_end();
  215. }
  216. }
  217. }
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement