HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <zombieplague>
  5.  
  6. #define PLUGIN "[ZP] Respawn Menu"
  7. #define VERSION "0.2"
  8. #define AUTHOR "Phantom"
  9.  
  10. new cvar_respawn_humans_cost, cvar_respawn_zombies_cost
  11. new SayText
  12. new const g_sound_spawn[] = "zombie_plague/resurrecttarget.wav"
  13.  
  14. public plugin_init()
  15. {
  16. register_plugin(PLUGIN, VERSION, AUTHOR)
  17.  
  18. register_clcmd("res", "respawn", ADMIN_ALL, "respawn")
  19.  
  20. cvar_respawn_humans_cost = register_cvar("zp_respawn_humans_cost", "5")
  21. cvar_respawn_zombies_cost = register_cvar("zp_respawn_zombies_cost", "3")
  22.  
  23. SayText = get_user_msgid("SayText")
  24.  
  25. register_dictionary("respawn_ammo.txt")
  26. }
  27.  
  28. public plugin_precache()
  29. {
  30. precache_sound( g_sound_spawn )
  31. }
  32. public respawn(id)
  33. {
  34. new szMenuMulti[64]
  35.  
  36. formatex(szMenuMulti, 63, "%L", id, "TITLE_MENU")
  37. new menu = menu_create( szMenuMulti, "menu_handler")
  38.  
  39. formatex(szMenuMulti, 63, "%L", id, "HUMAN_TEAM")
  40. menu_additem(menu, szMenuMulti, "1",0)
  41.  
  42. formatex(szMenuMulti, 63, "%L", id, "ZOMBIE_TEAM")
  43. menu_additem(menu, szMenuMulti , "2",0)
  44.  
  45. formatex(szMenuMulti,63, "%L", id, "EXIT")
  46. menu_setprop(menu, MPROP_EXIT, szMenuMulti)
  47.  
  48. menu_display(id, menu, 0);
  49.  
  50. return PLUGIN_HANDLED
  51. }
  52.  
  53. public menu_handler(id, menu, item)
  54. {
  55. if( item == MENU_EXIT )
  56. {
  57. menu_destroy(menu);
  58. return PLUGIN_HANDLED;
  59. }
  60.  
  61. new data[6], iName[64];
  62. new access, callback;
  63.  
  64. menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
  65.  
  66. new key = str_to_num(data);
  67.  
  68. switch(key)
  69. {
  70. case 1:
  71. {
  72. if(zp_get_user_ammo_packs(id)< get_pcvar_num(cvar_respawn_humans_cost))
  73. {
  74. print_color(id, "%L", id, "NO_MONEY")
  75. return PLUGIN_HANDLED
  76. }
  77.  
  78. if(zp_is_survivor_round() && !is_user_alive(id))
  79. {
  80. print_color(id, "%L", id, "ZOMBIES_ONLY")
  81. return PLUGIN_HANDLED
  82. }
  83.  
  84. if(!is_user_alive(id))
  85. {
  86. zp_respawn_user(id, ZP_TEAM_HUMAN)
  87. client_cmd(0, "spk %s", g_sound_spawn)
  88. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - get_pcvar_num(cvar_respawn_humans_cost))
  89. print_color(id, "%L", id, "USER_RESPAWN")
  90. set_task(1.0, "respawn1_message", id )
  91. }
  92.  
  93.  
  94. menu_destroy(menu);
  95. return PLUGIN_HANDLED
  96. }
  97.  
  98. case 2:
  99. {
  100. if(zp_get_user_ammo_packs(id)< get_pcvar_num(cvar_respawn_zombies_cost))
  101. {
  102. print_color(id, "%L", id, "NO_MONEY")
  103. return PLUGIN_HANDLED
  104. }
  105.  
  106. if(zp_is_nemesis_round() && !is_user_alive(id))
  107. {
  108. print_color(id, "%L", id, "HUMANS_ONLY")
  109. return PLUGIN_HANDLED
  110. }
  111.  
  112. if(!is_user_alive(id))
  113. {
  114. zp_respawn_user(id, ZP_TEAM_ZOMBIE)
  115. client_cmd(0, "spk %s", g_sound_spawn)
  116. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - get_pcvar_num(cvar_respawn_zombies_cost))
  117. print_color(id, "%L", id, "PLAYER_RESPAWN")
  118. set_task( 1.0 , "respawn2_message", id )
  119. return PLUGIN_HANDLED
  120. }
  121.  
  122.  
  123. menu_destroy(menu);
  124. return PLUGIN_HANDLED
  125. }
  126.  
  127. }
  128. menu_destroy(menu);
  129. return PLUGIN_HANDLED
  130. }
  131.  
  132. public respawn1_message( id )
  133. {
  134. new szName[ 32 ]
  135. get_user_name( id, szName, 31 )
  136. set_hudmessage( 255, 0, 0, 0.05, 0.45, 1, 0.0, 5.0, 1.0, 1.0, -1 )
  137. show_hudmessage( 0, "%s %L", szName, LANG_PLAYER, "RESPAWN" )
  138. }
  139.  
  140. public respawn2_message( id )
  141. {
  142. new szName[ 32 ]
  143. get_user_name( id, szName, 31 )
  144. set_hudmessage( 255, 0, 0, 0.05, 0.45, 1, 0.0, 5.0, 1.0, 1.0, -1 )
  145. show_hudmessage( 0, "%s %L", szName, LANG_PLAYER, "RESPAWN" )
  146. }
  147.  
  148. stock print_color(const id, const input[], any:...)
  149. {
  150. new count = 1, players[32];
  151. static msg[191];
  152. vformat(msg, 190, input, 3);
  153. replace_all(msg, 190, "!g", "^4"); // Green Color
  154. replace_all(msg, 190, "!y", "^1"); // Default Color
  155. replace_all(msg, 190, "!t", "^3"); // Team Color
  156. if (id) players[0] = id; else get_players(players, count, "ch");
  157. {
  158. for ( new i = 0; i < count; i++ )
  159. {
  160. if ( is_user_connected(players[i]) )
  161. {
  162. message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);
  163. write_byte(players[i]);
  164. write_string(msg);
  165. message_end();
  166. }
  167. }
  168. }
  169. }