HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <zombieplague>
  4.  
  5. #define PLUGIN "[ZP] 3rd person view"
  6. #define VERSION "1.1"
  7. #define AUTHOR "The_Thing"
  8.  
  9.  
  10. new g_item_name[] = { "3D Szemely Nezet" }
  11. new g_itemid_view, g_view_toggle, g_view_cost, g_thirdperson_mode
  12.  
  13. new bool:g_hasView[33]
  14.  
  15.  
  16. public plugin_init()
  17. {
  18. register_plugin(PLUGIN, VERSION, AUTHOR)
  19.  
  20. g_view_toggle = register_cvar("zp_3rdview", "1")
  21. g_view_cost = register_cvar("zp_view_cost", "6")
  22. g_thirdperson_mode = register_cvar("zp_thirdperson_mode", "1")
  23.  
  24. register_clcmd("say /3d", "fnView_Thirdperson")
  25. register_clcmd("say_team /3d", "fnView_Thirdperson")
  26.  
  27. g_itemid_view = zp_register_extra_item(g_item_name, get_pcvar_num(g_view_cost), ZP_TEAM_HUMAN & ZP_TEAM_ZOMBIE)
  28.  
  29. register_event("DeathMsg", "Death", "a")
  30. }
  31.  
  32. public client_connect(id)
  33. {
  34. g_hasView[id] = false
  35. }
  36.  
  37. public client_disconnect(id)
  38. {
  39. g_hasView[id] = false
  40. }
  41.  
  42. public Death()
  43. {
  44. new id = read_data( 2 )
  45. if ( g_hasView[id] )
  46. set_view(id, CAMERA_NONE)
  47. }
  48.  
  49. public Event(id)
  50. {
  51. if ( get_pcvar_num(g_thirdperson_mode) == 1 )
  52. set_task(0.5, "fnView_Thirdperson", id)
  53. }
  54.  
  55.  
  56. public zp_extra_item_selected(player, itemid)
  57. {
  58. if (itemid == g_itemid_view)
  59. {
  60. if ( is_user_alive(player) )
  61. {
  62. set_view(player, CAMERA_3RDPERSON)
  63. set_task(0.5, "fnView_Thirdperson", player)
  64. }
  65. }
  66. }
  67.  
  68. public fnView_Thirdperson(id)
  69. {
  70. if ( !get_pcvar_num(g_view_toggle) )
  71. {
  72. client_print(id, print_chat, "[ZP] A plugin jelenleg nem aktiv.")
  73. return PLUGIN_HANDLED
  74. }
  75.  
  76. if ( !is_user_alive(id) )
  77. {
  78. client_print(id, print_chat, "[ZP] A halottak nem vehetik meg ezt a cuccot !")
  79. return PLUGIN_HANDLED
  80. }
  81.  
  82. if ( g_hasView[id] )
  83. {
  84. client_print(id, print_chat, "[ZP] Te mar megvetted 1x ezt a cuccot !")
  85. return PLUGIN_HANDLED
  86. }
  87.  
  88. new money = zp_get_user_ammo_packs(id)
  89.  
  90. if ( money < get_pcvar_num(g_view_cost) )
  91. {
  92. client_print(id, print_chat, "[ZP] Nincs eleg Loszer Csomagod !")
  93. return PLUGIN_HANDLED
  94. }
  95.  
  96. if ( is_user_alive(id) )
  97. {
  98. set_view(id, CAMERA_3RDPERSON)
  99. set_task(0.5, "fnView_Thirdperson", id)
  100. }
  101.  
  102. zp_set_user_ammo_packs(id, money - get_pcvar_num(g_view_cost))
  103. client_print(id, print_chat, "[ZP] Sikeresen megvetted a 3D Nezetet !")
  104.  
  105. return PLUGIN_CONTINUE
  106. }
  107.  
  108. public plugin_precache()
  109. {
  110. precache_model("models/rpgrocket.mdl")
  111. }
  112.