HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4.  
  5. #define PLUGIN "Ricochet Spectate"
  6. #define VERSION "1.1"
  7.  
  8. new isSpectating[33]
  9. new hEyes[33]
  10. new Float:Origin[3], Float:vAngle[3], Float:Angles[3]
  11. new hid
  12.  
  13. public plugin_init()
  14. {
  15. register_plugin(PLUGIN,VERSION,"Tony Angione")
  16.  
  17. register_clcmd("spec","spec_player",0,"[authid, nev vagy #jatekosid]")
  18.  
  19. register_forward(FM_PlayerPostThink, "PostThink")
  20. register_forward(FM_AddToFullPack,"AddToFullPack")
  21. }
  22.  
  23. public client_connect(id)
  24. {
  25. isSpectating[id] = 0
  26. }
  27.  
  28. public client_disconnect(id)
  29. {
  30. if (isSpectating[id])
  31. {
  32. stop_spectating(id)
  33. }
  34. }
  35.  
  36. public plugin_precache()
  37. {
  38. precache_model("models/rpgrocket.mdl")
  39. }
  40.  
  41. public spec_player(id,level,cid)
  42. {
  43. if (!cmd_access(id,level,cid,1))
  44. return PLUGIN_HANDLED
  45.  
  46. new numbargs = read_argc()
  47.  
  48. if (numbargs == 1 && isSpectating[id])
  49. {
  50. stop_spectating(id)
  51. }
  52. else if (numbargs == 2)
  53. {
  54. if (isSpectating[id])
  55. {
  56. stop_spectating(id)
  57. }
  58.  
  59. new arg[32]
  60. read_argv(1,arg,31)
  61. hid = cmd_target(id,arg,0)
  62. if (!hid)
  63. return PLUGIN_HANDLED
  64.  
  65. console_print(id, "[RS] A nezobol kiallashoz ird be ujra a parancsot, paramterek nelkul.")
  66.  
  67. start_spectating(id, hid)
  68. }
  69. else
  70. {
  71. console_print(id, "[RS] Hasznalat: spec [authid, nev vagy #jatekosid]")
  72. return PLUGIN_HANDLED
  73. }
  74.  
  75. return PLUGIN_HANDLED
  76. }
  77.  
  78. public start_spectating(id, hid)
  79. {
  80. hEyes[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
  81. set_pev(hEyes[id],pev_classname,"spec_eyes")
  82. engfunc(EngFunc_SetModel,hEyes[id],"models/rpgrocket.mdl")
  83. set_pev(hEyes[id],pev_movetype,MOVETYPE_NOCLIP)
  84. engfunc(EngFunc_SetSize,hEyes[id],Float:{0.0, 0.0, 0.0}, Float:{0.0, 0.0, 0.0})
  85. set_pev(hEyes[id],pev_solid,SOLID_NOT)
  86. set_pev(hEyes[id], pev_takedamage, 0.0)
  87. set_pev(hEyes[id], pev_gravity, 0.0)
  88. set_pev(hEyes[id],pev_owner,id)
  89. set_pev(hEyes[id], pev_rendermode, kRenderTransColor)
  90. set_pev(hEyes[id], pev_renderamt, 0.0)
  91. set_pev(hEyes[id], pev_renderfx, kRenderFxNone)
  92.  
  93. dllfunc(DLLFunc_Think, hEyes[id])
  94.  
  95. engfunc(EngFunc_SetView, id, hEyes[id])
  96.  
  97. isSpectating[id] = hid
  98. }
  99.  
  100. public stop_spectating(id)
  101. {
  102. engfunc(EngFunc_SetView, id, id)
  103. engfunc(EngFunc_RemoveEntity, hEyes[id])
  104.  
  105. isSpectating[id] = 0
  106. hEyes[id] = 0
  107. }
  108.  
  109. public PostThink(id)
  110. {
  111. if (isSpectating[id])
  112. {
  113. pev(hid, pev_origin, Origin)
  114. pev(hid, pev_v_angle, vAngle)
  115. pev(hid, pev_angles, Angles)
  116.  
  117. Origin[2] += 28.0
  118. vAngle[0] = (vAngle[0] * (0-1)) * 2
  119. Angles[0] = (Angles[0] * (0-1)) * 2
  120.  
  121. set_pev(hEyes[id], pev_origin, Origin)
  122. set_pev(hEyes[id], pev_v_angle, vAngle)
  123. set_pev(hEyes[id], pev_angles, Angles)
  124.  
  125. return FMRES_HANDLED
  126. }
  127.  
  128. return FMRES_IGNORED
  129. }
  130.  
  131. public AddToFullPack(ent_state,e,edict_t_ent,host,hostflags,player,pSet)
  132. {
  133. if (is_user_connected(e) && is_user_connected(host))
  134. {
  135. if(is_user_alive(host) && isSpectating[host])
  136. {
  137. console_print(host, "[RS] Ujra eledrel, a nezesnek vege.")
  138. stop_spectating(host)
  139. }
  140. else if (isSpectating[host] == e)
  141. {
  142. set_pev(e, pev_rendermode, 1)
  143. return FMRES_HANDLED
  144. }
  145. else
  146. {
  147. set_pev(e, pev_rendermode, 0)
  148. return FMRES_HANDLED
  149. }
  150. }
  151.  
  152. return FMRES_IGNORED
  153. }