hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.04.27. 13:00



Jelenlévő felhasználók

Jelenleg 541 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 541 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: nincs regisztrált felhasználó az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 12 hozzászólás ]  Oldal 1 2 Következő
Szerző Üzenet
 Hozzászólás témája: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 16:52 
Offline
Senior Tag
Avatar

Csatlakozott: 2013.12.06. 18:38
Hozzászólások: 229
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 16 alkalommal
Azt szeretném kérni hogy ugyebár a hook Adminoknak van de én szeretném hogy ne csak admin használhassa hanem játékos is de a játékosok közül is csak a ctk használhatják, fontos lenne! :)

Röviden: Csak ct admin,sima játékos "akinek nincs adminja"! Ez legyen!

Aki meg csinálja + Gomb!!!


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 17:13 
Offline
Őskövület
Avatar

Csatlakozott: 2012.03.22. 18:22
Hozzászólások: 2978
Megköszönt másnak: 115 alkalommal
Megköszönték neki: 368 alkalommal
Küld el a hook forrását,mert 2 féle van.

_________________
Blasenkampfwagen

https://discord.gg/uBYnNnZP
GTA:PURSUIT MTA


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 17:15 
Offline
Tiszteletbeli
Avatar

Csatlakozott: 2011.08.15. 14:42
Hozzászólások: 1345
Megköszönt másnak: 10 alkalommal
Megköszönték neki: 277 alkalommal
A plugint belinkelem, az átalakítást, majd egy hozzáértő végzi el. :)

https://forums.alliedmods.net/showthread.php?p=151022

_________________
Üdvözlettel: BBk
[AmxModX] Általam fordított pluginok
Death of Legend Fun Server History
NetMozi.com - Filmes fórum Badboy.killer
foximaxi


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 17:19 
Offline
Őskövület
Avatar

Csatlakozott: 2012.03.22. 18:22
Hozzászólások: 2978
Megköszönt másnak: 115 alkalommal
Megköszönték neki: 368 alkalommal
Próbáld meg:


SMA Forráskód: [ Mindet kijelol ]
  1. /**************************************************************************************************
  2.  
  3. **** CVARS (FEATURES) ****
  4. sv_adminhook = Turn Plugin On/off
  5. **** ADMIN COMMANDS ****
  6. ADMIN_LEVEL_A (flag="m")
  7. Granting Hook/Rope = amx_granthook <authid, nick, @team, @all or #userid> <on/off>
  8.  
  9. ADMIN_LEVEL_E (flag="q") || Granted by admin
  10. Ninja Rope by Spacedude (slightly modified) & Hook thingy
  11. Attaching Rope = +rope
  12. Deattaching Rope = -rope
  13. Attaching Hook = +hook
  14. Deattaching Hook = -hook
  15.  
  16. **************************************************************************************************/
  17. #define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX
  18.  
  19. #if USING_AMX
  20. #include <amxmod>
  21. #include <amxmisc>
  22. #include <VexdUM>
  23. #include <fun>
  24. new gModName[32] = "AMX"
  25. #else
  26. #include <amxmodx>
  27. #include <amxmisc>
  28. #include <fun>
  29. #include <engine>
  30. new gModName[32] = "AMXX"
  31. #endif
  32. #include <cstrike>
  33. #define TE_BEAMENTPOINT 1
  34. #define TE_KILLBEAM 99
  35. #define DELTA_T 0.1 // seconds
  36. #define BEAMLIFE 100 // deciseconds
  37. #define MOVEACCELERATION 150 // units per second^2
  38. #define REELSPEED 300 // units per second
  39.  
  40. /* Hook Stuff */
  41. new gHookLocation[33][3]
  42. new gHookLenght[33]
  43. new bool:gIsHooked[33]
  44. new gAllowedHook[33]
  45. new Float:gBeamIsCreated[33]
  46. new global_gravity
  47. new beam
  48.  
  49. /************************************************************************************************************************/
  50. public plugin_init() //Called on plugin start
  51. {
  52. // Plugin Info
  53. register_plugin("Admin Hook","1.0","AssKicR")
  54.  
  55. //CVARS
  56. register_cvar("sv_adminhook", "1" )
  57.  
  58. //ADMIN CMDS
  59. register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
  60.  
  61. //USER COMMANDS
  62. register_clcmd("+rope", "hook_on",ADMIN_LEVEL_E)
  63. register_clcmd("-rope", "hook_off",ADMIN_LEVEL_E)
  64. register_clcmd("+hook", "hook_on",ADMIN_LEVEL_E)
  65. register_clcmd("-hook", "hook_off",ADMIN_LEVEL_E)
  66.  
  67. //HOOKED EVENTS
  68. register_event("ResetHUD", "ResetHUD", "b")
  69. }
  70. /************************************************************************************************************************/
  71. public plugin_precache()
  72. {
  73. beam = precache_model("sprites/zbeam4.spr")
  74. precache_sound("weapons/xbow_hit2.wav")
  75. }
  76. /*************************************************************************************************************************/
  77. /************************************************** USP/SCOUT REMOVE *****************************************************/
  78. /*************************************************************************************************************************/
  79.  
  80. /*************************************************************************************************************************/
  81. /**************************************************** HOOKED EVENTS ******************************************************/
  82. /*************************************************************************************************************************/
  83. public ResetHUD(id) {
  84. //Check if he is hooked to something
  85. if (gIsHooked[id]) RopeRelease(id)
  86. }
  87. /************************************************************************************************************************/
  88. stock kz_velocity_set(id,vel[3]) {
  89. //Set Their Velocity to 0 so that they they fall straight down from
  90. new Float:Ivel[3]
  91. Ivel[0]=float(vel[0])
  92. Ivel[1]=float(vel[1])
  93. Ivel[2]=float(vel[2])
  94. entity_set_vector(id, EV_VEC_velocity, Ivel)
  95. }
  96.  
  97. stock kz_velocity_get(id,vel[3]) {
  98. //Set Their Velocity to 0 so that they they fall straight down from
  99. new Float:Ivel[3]
  100.  
  101. entity_get_vector(id, EV_VEC_velocity, Ivel)
  102. vel[0]=floatround(Ivel[0])
  103. vel[1]=floatround(Ivel[1])
  104. vel[2]=floatround(Ivel[2])
  105. }
  106.  
  107. /************************************************************************************************************************/
  108. /**************************************************** ADMIN COMMANDS ****************************************************/
  109. /************************************************************************************************************************/
  110. public AdminGrantHook(id,level,cid)
  111. {
  112. if ( !cmd_access(id,level,cid,1) )
  113. return PLUGIN_HANDLED
  114.  
  115. new arg1[32],arg2[32]
  116. read_argv(1,arg1,31)
  117. read_argv(2,arg2,31)
  118. new onoff = str_to_num(arg2)
  119.  
  120. if ( equali(arg1,"@all") )
  121. {
  122. new plist[32],pnum
  123. get_players(plist,pnum,"a")
  124. if (pnum==0)
  125. {
  126. console_print(id,"[%s] There are no clients",gModName)
  127. return PLUGIN_HANDLED
  128. }
  129. for (new i=0; i<pnum; i++) {
  130. gAllowedHook[plist[i]]=onoff
  131. if (gIsHooked[plist[i]]==true && onoff==0)
  132. {
  133. RopeRelease(plist[i])
  134. }
  135. }
  136.  
  137. console_print(id,"[%s] %s all players access to hook/rope",gModName,onoff ? "Gave":"Removed")
  138. }
  139. else if ( arg1[0]=='@' )
  140. {
  141. new plist[32],pnum
  142. get_players(plist,pnum,"ae",arg1[1])
  143. if ( pnum==0 )
  144. {
  145. console_print(id,"[%s] No clients in such team",gModName)
  146. return PLUGIN_HANDLED
  147. }
  148. for (new i=0; i<pnum; i++) {
  149. gAllowedHook[plist[i]]=onoff
  150. if (gIsHooked[plist[i]]==true && onoff==0)
  151. {
  152. RopeRelease(plist[i])
  153. }
  154. }
  155. console_print(id,"[%s] %s all %ss access to hook/rope",onoff ? "Gave":"Removed",arg1[1])
  156. }
  157. else
  158. {
  159. new pName[32]
  160. new player = cmd_target(id,arg1,6)
  161. if (!player) return PLUGIN_HANDLED
  162.  
  163. gAllowedHook[player]=onoff
  164. if (gAllowedHook[player]==0 && onoff==0)
  165. {
  166. RopeRelease(player)
  167. }
  168.  
  169.  
  170. get_user_name(player,pName,31)
  171. console_print(id,"[%s] %s ^"%s^" access to hook/rope",onoff ? "Gave":"Removed",pName)
  172. }
  173.  
  174. return PLUGIN_HANDLED
  175. }
  176.  
  177. /************************************************************************************************************************/
  178. /****************************************************** NINJAROPE *******************************************************/
  179. /************************************************************************************************************************/
  180.  
  181. public ropetask(parm[])
  182. {
  183. new id = parm[0]
  184. new user_origin[3], user_look[3], user_direction[3], move_direction[3]
  185. new A[3], D[3], buttonadjust[3]
  186. new acceleration, velocity_towards_A, desired_velocity_towards_A
  187. new velocity[3], null[3]
  188.  
  189. if (!is_user_alive(id))
  190. {
  191. RopeRelease(id)
  192. return
  193. }
  194.  
  195. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  196. {
  197. beamentpoint(id)
  198. }
  199.  
  200. null[0] = 0
  201. null[1] = 0
  202. null[2] = 0
  203.  
  204. get_user_origin(id, user_origin)
  205. get_user_origin(id, user_look,2)
  206. kz_velocity_get(id, velocity)
  207.  
  208. buttonadjust[0]=0
  209. buttonadjust[1]=0
  210.  
  211. if (get_user_button(id)&IN_FORWARD) buttonadjust[0]+=1
  212. if (get_user_button(id)&IN_BACK) buttonadjust[0]-=1
  213. if (get_user_button(id)&IN_MOVERIGHT) buttonadjust[1]+=1
  214. if (get_user_button(id)&IN_MOVELEFT) buttonadjust[1]-=1
  215. if (get_user_button(id)&IN_JUMP) buttonadjust[2]+=1
  216. if (get_user_button(id)&IN_DUCK) buttonadjust[2]-=1
  217.  
  218. if (buttonadjust[0] || buttonadjust[1])
  219. {
  220. user_direction[0] = user_look[0] - user_origin[0]
  221. user_direction[1] = user_look[1] - user_origin[1]
  222.  
  223. move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]
  224. move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]
  225. move_direction[2] = 0
  226.  
  227. velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  228. velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  229. }
  230.  
  231. if (buttonadjust[2]) gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)
  232. if (gHookLenght[id] < 100) gHookLenght[id] = 100
  233.  
  234. A[0] = gHookLocation[id][0] - user_origin[0]
  235. A[1] = gHookLocation[id][1] - user_origin[1]
  236. A[2] = gHookLocation[id][2] - user_origin[2]
  237.  
  238. D[0] = A[0]*A[2] / get_distance(null,A)
  239. D[1] = A[1]*A[2] / get_distance(null,A)
  240. D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)
  241.  
  242. acceleration = - global_gravity * D[2] / get_distance(null,D)
  243.  
  244. velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)
  245. desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4
  246.  
  247. if (get_distance(null,D)>10)
  248. {
  249. velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))
  250. velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))
  251. velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))
  252. }
  253.  
  254. velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)
  255. velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)
  256. velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)
  257.  
  258. kz_velocity_set(id, velocity)
  259. }
  260.  
  261. public hooktask(parm[])
  262. {
  263. new id = parm[0]
  264. new velocity[3]
  265.  
  266. if ( !gIsHooked[id] ) return
  267.  
  268. new user_origin[3],oldvelocity[3]
  269. parm[0] = id
  270.  
  271. if (!is_user_alive(id))
  272. {
  273. RopeRelease(id)
  274. return
  275. }
  276.  
  277. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  278. {
  279. beamentpoint(id)
  280. }
  281.  
  282. get_user_origin(id, user_origin)
  283. kz_velocity_get(id, oldvelocity)
  284. new distance=get_distance( gHookLocation[id], user_origin )
  285. if ( distance > 10 )
  286. {
  287. velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )
  288. velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )
  289. velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )
  290. }
  291. else
  292. {
  293. velocity[0]=0
  294. velocity[1]=0
  295. velocity[2]=0
  296. }
  297.  
  298. kz_velocity_set(id, velocity)
  299.  
  300. }
  301.  
  302. public hook_on(id)
  303. {
  304. if (get_cvar_num("sv_adminhook")==1)
  305. {
  306. if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E) || cs_get_user_team(id) == CS_TEAM_CT) {
  307. if (!gIsHooked[id] && is_user_alive(id))
  308. {
  309. new cmd[32]
  310. read_argv(0,cmd,31)
  311. if(equal(cmd,"+rope")) RopeAttach(id,0)
  312. if(equal(cmd,"+hook")) RopeAttach(id,1)
  313. }
  314. }else{
  315. client_print(id,print_chat,"[%s] You have no access to that command",gModName)
  316. return PLUGIN_HANDLED
  317. }
  318. }else{
  319. client_print(id,print_chat,"[%s] This command is deativated",gModName)
  320. }
  321. return PLUGIN_HANDLED
  322. }
  323.  
  324. public hook_off(id)
  325. {
  326. if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E)) {
  327. if (gIsHooked[id])
  328. {
  329. RopeRelease(id)
  330. }
  331. }else{
  332. client_print(id,print_chat,"[%s] You have no access to that command",gModName)
  333. return PLUGIN_HANDLED
  334. }
  335. return PLUGIN_HANDLED
  336. }
  337.  
  338. public RopeAttach(id,hook)
  339. {
  340. new parm[1], user_origin[3]
  341. parm[0] = id
  342. gIsHooked[id] = true
  343. get_user_origin(id,user_origin)
  344. get_user_origin(id,gHookLocation[id], 3)
  345. gHookLenght[id] = get_distance(gHookLocation[id],user_origin)
  346. global_gravity = get_cvar_num("sv_gravity")
  347. set_user_gravity(id,0.001)
  348. beamentpoint(id)
  349. emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  350. if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")
  351. else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")
  352. }
  353.  
  354. public RopeRelease(id)
  355. {
  356. gIsHooked[id] = false
  357. killbeam(id)
  358. set_user_gravity(id)
  359. remove_task(200+id)
  360. }
  361.  
  362. public beamentpoint(id)
  363. {
  364. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  365. write_byte( TE_BEAMENTPOINT )
  366. write_short( id )
  367. write_coord( gHookLocation[id][0] )
  368. write_coord( gHookLocation[id][1] )
  369. write_coord( gHookLocation[id][2] )
  370. write_short( beam ) // sprite index
  371. write_byte( 0 ) // start frame
  372. write_byte( 0 ) // framerate
  373. write_byte( BEAMLIFE ) // life
  374. write_byte( 10 ) // width
  375. write_byte( 0 ) // noise
  376. if (get_user_team(id)==1) // Terrorist
  377. {
  378. write_byte( 255 ) // r, g, b
  379. write_byte( 0 ) // r, g, b
  380. write_byte( 0 ) // r, g, b
  381. }
  382. else // Counter-Terrorist
  383. {
  384. write_byte( 0 ) // r, g, b
  385. write_byte( 0 ) // r, g, b
  386. write_byte( 255 ) // r, g, b
  387. }
  388. write_byte( 150 ) // brightness
  389. write_byte( 0 ) // speed
  390. message_end( )
  391. gBeamIsCreated[id] = get_gametime()
  392. }
  393.  
  394. public killbeam(id)
  395. {
  396. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  397. write_byte( TE_KILLBEAM )
  398. write_short( id )
  399. message_end()
  400. }
  401.  
  402. /************************************************************************************************************************/
  403. /******************************************************* FORWARDS *******************************************************/
  404. /************************************************************************************************************************/
  405.  
  406. public client_disconnect(id) {
  407. gAllowedHook[id]=0
  408. }
  409.  
  410. /************************************************************************************************************************/
  411. /************************************************** AMXX -> AMX funcs ***************************************************/
  412. /************************************************************************************************************************/
  413. #if USING_AMX
  414. stock get_user_button(id) return entity_get_int(id, EV_INT_button)
  415. #endif
  416.  

_________________
Blasenkampfwagen

https://discord.gg/uBYnNnZP
GTA:PURSUIT MTA


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 17:51 
Offline
Senior Tag
Avatar

Csatlakozott: 2013.12.06. 18:38
Hozzászólások: 229
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 16 alkalommal
Erre gondoltam csak az a baj van hogy ct csak egyet bír hookolni és be ragad a falba és el kezd rezegni es ki irja hogy nem használhato a hook angolul! ez az egy hibája ha ezt ki javítod télleg megy a gomb!


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 18:25 
Offline
Őskövület
Avatar

Csatlakozott: 2012.03.22. 18:22
Hozzászólások: 2978
Megköszönt másnak: 115 alkalommal
Megköszönték neki: 368 alkalommal
Próba szerencse :)

most próbáld

SMA Forráskód: [ Mindet kijelol ]
  1. /**************************************************************************************************
  2.  
  3. **** CVARS (FEATURES) ****
  4. sv_adminhook = Turn Plugin On/off
  5. **** ADMIN COMMANDS ****
  6. ADMIN_LEVEL_A (flag="m")
  7. Granting Hook/Rope = amx_granthook <authid, nick, @team, @all or #userid> <on/off>
  8.  
  9. ADMIN_LEVEL_E (flag="q") || Granted by admin
  10. Ninja Rope by Spacedude (slightly modified) & Hook thingy
  11. Attaching Rope = +rope
  12. Deattaching Rope = -rope
  13. Attaching Hook = +hook
  14. Deattaching Hook = -hook
  15.  
  16. **************************************************************************************************/
  17. #define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX
  18.  
  19. #if USING_AMX
  20. #include <amxmod>
  21. #include <amxmisc>
  22. #include <VexdUM>
  23. #include <fun>
  24. new gModName[32] = "AMX"
  25. #else
  26. #include <amxmodx>
  27. #include <amxmisc>
  28. #include <fun>
  29. #include <engine>
  30. new gModName[32] = "AMXX"
  31. #endif
  32. #include <cstrike>
  33. #define TE_BEAMENTPOINT 1
  34. #define TE_KILLBEAM 99
  35. #define DELTA_T 0.1 // seconds
  36. #define BEAMLIFE 100 // deciseconds
  37. #define MOVEACCELERATION 150 // units per second^2
  38. #define REELSPEED 300 // units per second
  39.  
  40. /* Hook Stuff */
  41. new gHookLocation[33][3]
  42. new gHookLenght[33]
  43. new bool:gIsHooked[33]
  44. new gAllowedHook[33]
  45. new Float:gBeamIsCreated[33]
  46. new global_gravity
  47. new beam
  48.  
  49. /************************************************************************************************************************/
  50. public plugin_init() //Called on plugin start
  51. {
  52. // Plugin Info
  53. register_plugin("Admin Hook","1.0","AssKicR")
  54.  
  55. //CVARS
  56. register_cvar("sv_adminhook", "1" )
  57.  
  58. //ADMIN CMDS
  59. register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
  60.  
  61. //USER COMMANDS
  62. register_clcmd("+rope", "hook_on",ADMIN_LEVEL_E)
  63. register_clcmd("-rope", "hook_off",ADMIN_LEVEL_E)
  64. register_clcmd("+hook", "hook_on",ADMIN_LEVEL_E)
  65. register_clcmd("-hook", "hook_off",ADMIN_LEVEL_E)
  66.  
  67. //HOOKED EVENTS
  68. register_event("ResetHUD", "ResetHUD", "b")
  69. }
  70. /************************************************************************************************************************/
  71. public plugin_precache()
  72. {
  73. beam = precache_model("sprites/zbeam4.spr")
  74. precache_sound("weapons/xbow_hit2.wav")
  75. }
  76. /*************************************************************************************************************************/
  77. /************************************************** USP/SCOUT REMOVE *****************************************************/
  78. /*************************************************************************************************************************/
  79.  
  80. /*************************************************************************************************************************/
  81. /**************************************************** HOOKED EVENTS ******************************************************/
  82. /*************************************************************************************************************************/
  83. public ResetHUD(id) {
  84. //Check if he is hooked to something
  85. if (gIsHooked[id]) RopeRelease(id)
  86. }
  87. /************************************************************************************************************************/
  88. stock kz_velocity_set(id,vel[3]) {
  89. //Set Their Velocity to 0 so that they they fall straight down from
  90. new Float:Ivel[3]
  91. Ivel[0]=float(vel[0])
  92. Ivel[1]=float(vel[1])
  93. Ivel[2]=float(vel[2])
  94. entity_set_vector(id, EV_VEC_velocity, Ivel)
  95. }
  96.  
  97. stock kz_velocity_get(id,vel[3]) {
  98. //Set Their Velocity to 0 so that they they fall straight down from
  99. new Float:Ivel[3]
  100.  
  101. entity_get_vector(id, EV_VEC_velocity, Ivel)
  102. vel[0]=floatround(Ivel[0])
  103. vel[1]=floatround(Ivel[1])
  104. vel[2]=floatround(Ivel[2])
  105. }
  106.  
  107. /************************************************************************************************************************/
  108. /**************************************************** ADMIN COMMANDS ****************************************************/
  109. /************************************************************************************************************************/
  110. public AdminGrantHook(id,level,cid)
  111. {
  112. if ( !cmd_access(id,level,cid,1) )
  113. return PLUGIN_HANDLED
  114.  
  115. new arg1[32],arg2[32]
  116. read_argv(1,arg1,31)
  117. read_argv(2,arg2,31)
  118. new onoff = str_to_num(arg2)
  119.  
  120. if ( equali(arg1,"@all") )
  121. {
  122. new plist[32],pnum
  123. get_players(plist,pnum,"a")
  124. if (pnum==0)
  125. {
  126. console_print(id,"[%s] There are no clients",gModName)
  127. return PLUGIN_HANDLED
  128. }
  129. for (new i=0; i<pnum; i++) {
  130. gAllowedHook[plist[i]]=onoff
  131. if (gIsHooked[plist[i]]==true && onoff==0)
  132. {
  133. RopeRelease(plist[i])
  134. }
  135. }
  136.  
  137. console_print(id,"[%s] %s all players access to hook/rope",gModName,onoff ? "Gave":"Removed")
  138. }
  139. else if ( arg1[0]=='@' )
  140. {
  141. new plist[32],pnum
  142. get_players(plist,pnum,"ae",arg1[1])
  143. if ( pnum==0 )
  144. {
  145. console_print(id,"[%s] No clients in such team",gModName)
  146. return PLUGIN_HANDLED
  147. }
  148. for (new i=0; i<pnum; i++) {
  149. gAllowedHook[plist[i]]=onoff
  150. if (gIsHooked[plist[i]]==true && onoff==0)
  151. {
  152. RopeRelease(plist[i])
  153. }
  154. }
  155. console_print(id,"[%s] %s all %ss access to hook/rope",onoff ? "Gave":"Removed",arg1[1])
  156. }
  157. else
  158. {
  159. new pName[32]
  160. new player = cmd_target(id,arg1,6)
  161. if (!player) return PLUGIN_HANDLED
  162.  
  163. gAllowedHook[player]=onoff
  164. if (gAllowedHook[player]==0 && onoff==0)
  165. {
  166. RopeRelease(player)
  167. }
  168.  
  169.  
  170. get_user_name(player,pName,31)
  171. console_print(id,"[%s] %s ^"%s^" access to hook/rope",onoff ? "Gave":"Removed",pName)
  172. }
  173.  
  174. return PLUGIN_HANDLED
  175. }
  176.  
  177. /************************************************************************************************************************/
  178. /****************************************************** NINJAROPE *******************************************************/
  179. /************************************************************************************************************************/
  180.  
  181. public ropetask(parm[])
  182. {
  183. new id = parm[0]
  184. new user_origin[3], user_look[3], user_direction[3], move_direction[3]
  185. new A[3], D[3], buttonadjust[3]
  186. new acceleration, velocity_towards_A, desired_velocity_towards_A
  187. new velocity[3], null[3]
  188.  
  189. if (!is_user_alive(id))
  190. {
  191. RopeRelease(id)
  192. return
  193. }
  194.  
  195. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  196. {
  197. beamentpoint(id)
  198. }
  199.  
  200. null[0] = 0
  201. null[1] = 0
  202. null[2] = 0
  203.  
  204. get_user_origin(id, user_origin)
  205. get_user_origin(id, user_look,2)
  206. kz_velocity_get(id, velocity)
  207.  
  208. buttonadjust[0]=0
  209. buttonadjust[1]=0
  210.  
  211. if (get_user_button(id)&IN_FORWARD) buttonadjust[0]+=1
  212. if (get_user_button(id)&IN_BACK) buttonadjust[0]-=1
  213. if (get_user_button(id)&IN_MOVERIGHT) buttonadjust[1]+=1
  214. if (get_user_button(id)&IN_MOVELEFT) buttonadjust[1]-=1
  215. if (get_user_button(id)&IN_JUMP) buttonadjust[2]+=1
  216. if (get_user_button(id)&IN_DUCK) buttonadjust[2]-=1
  217.  
  218. if (buttonadjust[0] || buttonadjust[1])
  219. {
  220. user_direction[0] = user_look[0] - user_origin[0]
  221. user_direction[1] = user_look[1] - user_origin[1]
  222.  
  223. move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]
  224. move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]
  225. move_direction[2] = 0
  226.  
  227. velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  228. velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  229. }
  230.  
  231. if (buttonadjust[2]) gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)
  232. if (gHookLenght[id] < 100) gHookLenght[id] = 100
  233.  
  234. A[0] = gHookLocation[id][0] - user_origin[0]
  235. A[1] = gHookLocation[id][1] - user_origin[1]
  236. A[2] = gHookLocation[id][2] - user_origin[2]
  237.  
  238. D[0] = A[0]*A[2] / get_distance(null,A)
  239. D[1] = A[1]*A[2] / get_distance(null,A)
  240. D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)
  241.  
  242. acceleration = - global_gravity * D[2] / get_distance(null,D)
  243.  
  244. velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)
  245. desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4
  246.  
  247. if (get_distance(null,D)>10)
  248. {
  249. velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))
  250. velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))
  251. velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))
  252. }
  253.  
  254. velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)
  255. velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)
  256. velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)
  257.  
  258. kz_velocity_set(id, velocity)
  259. }
  260.  
  261. public hooktask(parm[])
  262. {
  263. new id = parm[0]
  264. new velocity[3]
  265.  
  266. if ( !gIsHooked[id] ) return
  267.  
  268. new user_origin[3],oldvelocity[3]
  269. parm[0] = id
  270.  
  271. if (!is_user_alive(id))
  272. {
  273. RopeRelease(id)
  274. return
  275. }
  276.  
  277. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  278. {
  279. beamentpoint(id)
  280. }
  281.  
  282. get_user_origin(id, user_origin)
  283. kz_velocity_get(id, oldvelocity)
  284. new distance=get_distance( gHookLocation[id], user_origin )
  285. if ( distance > 10 )
  286. {
  287. velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )
  288. velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )
  289. velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )
  290. }
  291. else
  292. {
  293. velocity[0]=0
  294. velocity[1]=0
  295. velocity[2]=0
  296. }
  297.  
  298. kz_velocity_set(id, velocity)
  299.  
  300. }
  301.  
  302. public hook_on(id)
  303. {
  304. if (get_cvar_num("sv_adminhook")==1)
  305. {
  306. if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E) || cs_get_user_team(id) == CS_TEAM_CT) {
  307. if (!gIsHooked[id] && is_user_alive(id))
  308. {
  309. new cmd[32]
  310. read_argv(0,cmd,31)
  311. if(equal(cmd,"+rope")) RopeAttach(id,0)
  312. if(equal(cmd,"+hook")) RopeAttach(id,1)
  313. }
  314. }else{
  315. client_print(id,print_chat,"[%s] You have no access to that command",gModName)
  316. return PLUGIN_HANDLED
  317. }
  318. }else{
  319. client_print(id,print_chat,"[%s] This command is deativated",gModName)
  320. }
  321. return PLUGIN_HANDLED
  322. }
  323.  
  324. public hook_off(id)
  325. {
  326. if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E) || cs_get_user_team(id) == CS_TEAM_CT) {
  327. if (gIsHooked[id])
  328. {
  329. RopeRelease(id)
  330. }
  331. }else{
  332. client_print(id,print_chat,"[%s] You have no access to that command",gModName)
  333. return PLUGIN_HANDLED
  334. }
  335. return PLUGIN_HANDLED
  336. }
  337.  
  338. public RopeAttach(id,hook)
  339. {
  340. new parm[1], user_origin[3]
  341. parm[0] = id
  342. gIsHooked[id] = true
  343. get_user_origin(id,user_origin)
  344. get_user_origin(id,gHookLocation[id], 3)
  345. gHookLenght[id] = get_distance(gHookLocation[id],user_origin)
  346. global_gravity = get_cvar_num("sv_gravity")
  347. set_user_gravity(id,0.001)
  348. beamentpoint(id)
  349. emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  350. if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")
  351. else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")
  352. }
  353.  
  354. public RopeRelease(id)
  355. {
  356. gIsHooked[id] = false
  357. killbeam(id)
  358. set_user_gravity(id)
  359. remove_task(200+id)
  360. }
  361.  
  362. public beamentpoint(id)
  363. {
  364. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  365. write_byte( TE_BEAMENTPOINT )
  366. write_short( id )
  367. write_coord( gHookLocation[id][0] )
  368. write_coord( gHookLocation[id][1] )
  369. write_coord( gHookLocation[id][2] )
  370. write_short( beam ) // sprite index
  371. write_byte( 0 ) // start frame
  372. write_byte( 0 ) // framerate
  373. write_byte( BEAMLIFE ) // life
  374. write_byte( 10 ) // width
  375. write_byte( 0 ) // noise
  376. if (get_user_team(id)==1) // Terrorist
  377. {
  378. write_byte( 255 ) // r, g, b
  379. write_byte( 0 ) // r, g, b
  380. write_byte( 0 ) // r, g, b
  381. }
  382. else // Counter-Terrorist
  383. {
  384. write_byte( 0 ) // r, g, b
  385. write_byte( 0 ) // r, g, b
  386. write_byte( 255 ) // r, g, b
  387. }
  388. write_byte( 150 ) // brightness
  389. write_byte( 0 ) // speed
  390. message_end( )
  391. gBeamIsCreated[id] = get_gametime()
  392. }
  393.  
  394. public killbeam(id)
  395. {
  396. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  397. write_byte( TE_KILLBEAM )
  398. write_short( id )
  399. message_end()
  400. }
  401.  
  402. /************************************************************************************************************************/
  403. /******************************************************* FORWARDS *******************************************************/
  404. /************************************************************************************************************************/
  405.  
  406. public client_disconnect(id) {
  407. gAllowedHook[id]=0
  408. }
  409.  
  410. /************************************************************************************************************************/
  411. /************************************************** AMXX -> AMX funcs ***************************************************/
  412. /************************************************************************************************************************/
  413. #if USING_AMX
  414. stock get_user_button(id) return entity_get_int(id, EV_INT_button)
  415. #endif
  416.  

_________________
Blasenkampfwagen

https://discord.gg/uBYnNnZP
GTA:PURSUIT MTA


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 18:41 
Offline
Tiszteletbeli
Avatar

Csatlakozott: 2011.08.15. 14:42
Hozzászólások: 1345
Megköszönt másnak: 10 alkalommal
Megköszönték neki: 277 alkalommal
Lefordítottam magyarra.

SMA Forráskód: [ Mindet kijelol ]
  1. /**************************************************************************************************
  2.  
  3. **** CVARS (FEATURES) ****
  4. sv_adminhook = Turn Plugin On/off
  5. **** ADMIN COMMANDS ****
  6. ADMIN_LEVEL_A (flag="m")
  7. Granting Hook/Rope = amx_granthook <authid, nick, @team, @all or #userid> <on/off>
  8.  
  9. ADMIN_LEVEL_E (flag="q") || Granted by admin
  10. Ninja Rope by Spacedude (slightly modified) & Hook thingy
  11. Attaching Rope = +rope
  12. Deattaching Rope = -rope
  13. Attaching Hook = +hook
  14. Deattaching Hook = -hook
  15.  
  16. Fordította: BBk - Death of Legend
  17. **************************************************************************************************/
  18. #define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX
  19.  
  20. #if USING_AMX
  21. #include <amxmod>
  22. #include <amxmisc>
  23. #include <VexdUM>
  24. #include <fun>
  25. new gModName[32] = "AMX"
  26. #else
  27. #include <amxmodx>
  28. #include <amxmisc>
  29. #include <fun>
  30. #include <engine>
  31. new gModName[32] = "AMXX"
  32. #endif
  33.  
  34. #define TE_BEAMENTPOINT 1
  35. #define TE_KILLBEAM 99
  36. #define DELTA_T 0.1 // seconds
  37. #define BEAMLIFE 100 // deciseconds
  38. #define MOVEACCELERATION 150 // units per second^2
  39. #define REELSPEED 300 // units per second
  40.  
  41. /* Hook Stuff */
  42. new gHookLocation[33][3]
  43. new gHookLenght[33]
  44. new bool:gIsHooked[33]
  45. new gAllowedHook[33]
  46. new Float:gBeamIsCreated[33]
  47. new global_gravity
  48. new beam
  49.  
  50. /************************************************************************************************************************/
  51. public plugin_init() //Called on plugin start
  52. {
  53. // Plugin Info
  54. register_plugin("Admin Hook","1.0","AssKicR")
  55.  
  56. //CVARS
  57. register_cvar("sv_adminhook", "1" )
  58.  
  59. //ADMIN CMDS
  60. register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
  61.  
  62. //USER COMMANDS
  63. register_clcmd("+rope", "hook_on",ADMIN_LEVEL_E)
  64. register_clcmd("-rope", "hook_off",ADMIN_LEVEL_E)
  65. register_clcmd("+hook", "hook_on",ADMIN_LEVEL_E)
  66. register_clcmd("-hook", "hook_off",ADMIN_LEVEL_E)
  67.  
  68. //HOOKED EVENTS
  69. register_event("ResetHUD", "ResetHUD", "b")
  70. }
  71. /************************************************************************************************************************/
  72. public plugin_precache()
  73. {
  74. beam = precache_model("sprites/zbeam4.spr")
  75. precache_sound("weapons/xbow_hit2.wav")
  76. }
  77. /*************************************************************************************************************************/
  78. /************************************************** USP/SCOUT REMOVE *****************************************************/
  79. /*************************************************************************************************************************/
  80.  
  81. /*************************************************************************************************************************/
  82. /**************************************************** HOOKED EVENTS ******************************************************/
  83. /*************************************************************************************************************************/
  84. public ResetHUD(id) {
  85. //Check if he is hooked to something
  86. if (gIsHooked[id]) RopeRelease(id)
  87. }
  88. /************************************************************************************************************************/
  89. stock kz_velocity_set(id,vel[3]) {
  90. //Set Their Velocity to 0 so that they they fall straight down from
  91. new Float:Ivel[3]
  92. Ivel[0]=float(vel[0])
  93. Ivel[1]=float(vel[1])
  94. Ivel[2]=float(vel[2])
  95. entity_set_vector(id, EV_VEC_velocity, Ivel)
  96. }
  97.  
  98. stock kz_velocity_get(id,vel[3]) {
  99. //Set Their Velocity to 0 so that they they fall straight down from
  100. new Float:Ivel[3]
  101.  
  102. entity_get_vector(id, EV_VEC_velocity, Ivel)
  103. vel[0]=floatround(Ivel[0])
  104. vel[1]=floatround(Ivel[1])
  105. vel[2]=floatround(Ivel[2])
  106. }
  107.  
  108. /************************************************************************************************************************/
  109. /**************************************************** ADMIN COMMANDS ****************************************************/
  110. /************************************************************************************************************************/
  111. public AdminGrantHook(id,level,cid)
  112. {
  113. if ( !cmd_access(id,level,cid,1) )
  114. return PLUGIN_HANDLED
  115.  
  116. new arg1[32],arg2[32]
  117. read_argv(1,arg1,31)
  118. read_argv(2,arg2,31)
  119. new onoff = str_to_num(arg2)
  120.  
  121. if ( equali(arg1,"@all") )
  122. {
  123. new plist[32],pnum
  124. get_players(plist,pnum,"a")
  125. if (pnum==0)
  126. {
  127. console_print(id,"[%s] Nincsenek kliensek",gModName)
  128. return PLUGIN_HANDLED
  129. }
  130. for (new i=0; i<pnum; i++) {
  131. gAllowedHook[plist[i]]=onoff
  132. if (gIsHooked[plist[i]]==true && onoff==0)
  133. {
  134. RopeRelease(plist[i])
  135. }
  136. }
  137.  
  138. console_print(id,"[%s] %s minden jatekosnal aktivalta a hook/rope parancsot",gModName,onoff ? "Adva":"Torolve")
  139. }
  140. else if ( arg1[0]=='@' )
  141. {
  142. new plist[32],pnum
  143. get_players(plist,pnum,"ae",arg1[1])
  144. if ( pnum==0 )
  145. {
  146. console_print(id,"[%s] Nincs kliens ebben a csapatban",gModName)
  147. return PLUGIN_HANDLED
  148. }
  149. for (new i=0; i<pnum; i++) {
  150. gAllowedHook[plist[i]]=onoff
  151. if (gIsHooked[plist[i]]==true && onoff==0)
  152. {
  153. RopeRelease(plist[i])
  154. }
  155. }
  156. console_print(id,"[%s] %s minden %ss -nek aktivalta a hook/rope parancsot",onoff ? "Adva":"Torolve",arg1[1])
  157. }
  158. else
  159. {
  160. new pName[32]
  161. new player = cmd_target(id,arg1,6)
  162. if (!player) return PLUGIN_HANDLED
  163.  
  164. gAllowedHook[player]=onoff
  165. if (gAllowedHook[player]==0 && onoff==0)
  166. {
  167. RopeRelease(player)
  168. }
  169.  
  170.  
  171. get_user_name(player,pName,31)
  172. console_print(id,"[%s] %s ^"%s^" -nak aktivalta a hook/rope parancsot",onoff ? "Adva":"Torolve",pName)
  173. }
  174.  
  175. return PLUGIN_HANDLED
  176. }
  177.  
  178. /************************************************************************************************************************/
  179. /****************************************************** NINJAROPE *******************************************************/
  180. /************************************************************************************************************************/
  181.  
  182. public ropetask(parm[])
  183. {
  184. new id = parm[0]
  185. new user_origin[3], user_look[3], user_direction[3], move_direction[3]
  186. new A[3], D[3], buttonadjust[3]
  187. new acceleration, velocity_towards_A, desired_velocity_towards_A
  188. new velocity[3], null[3]
  189.  
  190. if (!is_user_alive(id))
  191. {
  192. RopeRelease(id)
  193. return
  194. }
  195.  
  196. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  197. {
  198. beamentpoint(id)
  199. }
  200.  
  201. null[0] = 0
  202. null[1] = 0
  203. null[2] = 0
  204.  
  205. get_user_origin(id, user_origin)
  206. get_user_origin(id, user_look,2)
  207. kz_velocity_get(id, velocity)
  208.  
  209. buttonadjust[0]=0
  210. buttonadjust[1]=0
  211.  
  212. if (get_user_button(id)&IN_FORWARD) buttonadjust[0]+=1
  213. if (get_user_button(id)&IN_BACK) buttonadjust[0]-=1
  214. if (get_user_button(id)&IN_MOVERIGHT) buttonadjust[1]+=1
  215. if (get_user_button(id)&IN_MOVELEFT) buttonadjust[1]-=1
  216. if (get_user_button(id)&IN_JUMP) buttonadjust[2]+=1
  217. if (get_user_button(id)&IN_DUCK) buttonadjust[2]-=1
  218.  
  219. if (buttonadjust[0] || buttonadjust[1])
  220. {
  221. user_direction[0] = user_look[0] - user_origin[0]
  222. user_direction[1] = user_look[1] - user_origin[1]
  223.  
  224. move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]
  225. move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]
  226. move_direction[2] = 0
  227.  
  228. velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  229. velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  230. }
  231.  
  232. if (buttonadjust[2]) gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)
  233. if (gHookLenght[id] < 100) gHookLenght[id] = 100
  234.  
  235. A[0] = gHookLocation[id][0] - user_origin[0]
  236. A[1] = gHookLocation[id][1] - user_origin[1]
  237. A[2] = gHookLocation[id][2] - user_origin[2]
  238.  
  239. D[0] = A[0]*A[2] / get_distance(null,A)
  240. D[1] = A[1]*A[2] / get_distance(null,A)
  241. D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)
  242.  
  243. acceleration = - global_gravity * D[2] / get_distance(null,D)
  244.  
  245. velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)
  246. desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4
  247.  
  248. if (get_distance(null,D)>10)
  249. {
  250. velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))
  251. velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))
  252. velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))
  253. }
  254.  
  255. velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)
  256. velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)
  257. velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)
  258.  
  259. kz_velocity_set(id, velocity)
  260. }
  261.  
  262. public hooktask(parm[])
  263. {
  264. new id = parm[0]
  265. new velocity[3]
  266.  
  267. if ( !gIsHooked[id] ) return
  268.  
  269. new user_origin[3],oldvelocity[3]
  270. parm[0] = id
  271.  
  272. if (!is_user_alive(id))
  273. {
  274. RopeRelease(id)
  275. return
  276. }
  277.  
  278. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  279. {
  280. beamentpoint(id)
  281. }
  282.  
  283. get_user_origin(id, user_origin)
  284. kz_velocity_get(id, oldvelocity)
  285. new distance=get_distance( gHookLocation[id], user_origin )
  286. if ( distance > 10 )
  287. {
  288. velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )
  289. velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )
  290. velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )
  291. }
  292. else
  293. {
  294. velocity[0]=0
  295. velocity[1]=0
  296. velocity[2]=0
  297. }
  298.  
  299. kz_velocity_set(id, velocity)
  300.  
  301. }
  302.  
  303. public hook_on(id)
  304. {
  305. if (get_cvar_num("sv_adminhook")==1)
  306. {
  307. if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E)) {
  308. if (!gIsHooked[id] && is_user_alive(id))
  309. {
  310. new cmd[32]
  311. read_argv(0,cmd,31)
  312. if(equal(cmd,"+rope")) RopeAttach(id,0)
  313. if(equal(cmd,"+hook")) RopeAttach(id,1)
  314. }
  315. }else{
  316. client_print(id,print_chat,"[%s] Nincs hozzaferesed ehhez a parancshoz",gModName)
  317. return PLUGIN_HANDLED
  318. }
  319. }else{
  320. client_print(id,print_chat,"[%s] Ez a parancs inaktiv",gModName)
  321. }
  322. return PLUGIN_HANDLED
  323. }
  324.  
  325. public hook_off(id)
  326. {
  327. if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E)) {
  328. if (gIsHooked[id])
  329. {
  330. RopeRelease(id)
  331. }
  332. }else{
  333. client_print(id,print_chat,"[%s] Nincs hozzaferesed ehhez a parancshoz",gModName)
  334. return PLUGIN_HANDLED
  335. }
  336. return PLUGIN_HANDLED
  337. }
  338.  
  339. public RopeAttach(id,hook)
  340. {
  341. new parm[1], user_origin[3]
  342. parm[0] = id
  343. gIsHooked[id] = true
  344. get_user_origin(id,user_origin)
  345. get_user_origin(id,gHookLocation[id], 3)
  346. gHookLenght[id] = get_distance(gHookLocation[id],user_origin)
  347. global_gravity = get_cvar_num("sv_gravity")
  348. set_user_gravity(id,0.001)
  349. beamentpoint(id)
  350. emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  351. if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")
  352. else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")
  353. }
  354.  
  355. public RopeRelease(id)
  356. {
  357. gIsHooked[id] = false
  358. killbeam(id)
  359. set_user_gravity(id)
  360. remove_task(200+id)
  361. }
  362.  
  363. public beamentpoint(id)
  364. {
  365. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  366. write_byte( TE_BEAMENTPOINT )
  367. write_short( id )
  368. write_coord( gHookLocation[id][0] )
  369. write_coord( gHookLocation[id][1] )
  370. write_coord( gHookLocation[id][2] )
  371. write_short( beam ) // sprite index
  372. write_byte( 0 ) // start frame
  373. write_byte( 0 ) // framerate
  374. write_byte( BEAMLIFE ) // life
  375. write_byte( 10 ) // width
  376. write_byte( 0 ) // noise
  377. if (get_user_team(id)==1) // Terrorist
  378. {
  379. write_byte( 255 ) // r, g, b
  380. write_byte( 0 ) // r, g, b
  381. write_byte( 0 ) // r, g, b
  382. }
  383. else // Counter-Terrorist
  384. {
  385. write_byte( 0 ) // r, g, b
  386. write_byte( 0 ) // r, g, b
  387. write_byte( 255 ) // r, g, b
  388. }
  389. write_byte( 150 ) // brightness
  390. write_byte( 0 ) // speed
  391. message_end( )
  392. gBeamIsCreated[id] = get_gametime()
  393. }
  394.  
  395. public killbeam(id)
  396. {
  397. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  398. write_byte( TE_KILLBEAM )
  399. write_short( id )
  400. message_end()
  401. }
  402.  
  403. /************************************************************************************************************************/
  404. /******************************************************* FORWARDS *******************************************************/
  405. /************************************************************************************************************************/
  406.  
  407. public client_disconnect(id) {
  408. gAllowedHook[id]=0
  409. }
  410.  
  411. /************************************************************************************************************************/
  412. /************************************************** AMXX -> AMX funcs ***************************************************/
  413. /************************************************************************************************************************/
  414. #if USING_AMX
  415. stock get_user_button(id) return entity_get_int(id, EV_INT_button)
  416. #endif

_________________
Üdvözlettel: BBk
[AmxModX] Általam fordított pluginok
Death of Legend Fun Server History
NetMozi.com - Filmes fórum Badboy.killer
foximaxi


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 20:20 
Offline
Őskövület
Avatar

Csatlakozott: 2012.02.27. 09:42
Hozzászólások: 2588
Megköszönt másnak: 25 alkalommal
Megköszönték neki: 418 alkalommal
tessék angol verziót írtam át próbáld ki

csak az használhatja aki CT be van

SMA Forráskód: [ Mindet kijelol ]
  1. /**************************************************************************************************
  2.  
  3. **** CVARS (FEATURES) ****
  4. sv_adminhook = Turn Plugin On/off
  5. **** ADMIN COMMANDS ****
  6. ADMIN_LEVEL_A (flag="m")
  7. Granting Hook/Rope = amx_granthook <authid, nick, @team, @all or #userid> <on/off>
  8.  
  9. ADMIN_LEVEL_E (flag="q") || Granted by admin
  10. Ninja Rope by Spacedude (slightly modified) & Hook thingy
  11. Attaching Rope = +rope
  12. Deattaching Rope = -rope
  13. Attaching Hook = +hook
  14. Deattaching Hook = -hook
  15.  
  16. **************************************************************************************************/
  17. #define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX
  18.  
  19. #if USING_AMX
  20. #include <amxmod>
  21. #include <amxmisc>
  22. #include <VexdUM>
  23. #include <fun>
  24. #include <cstrike>
  25. new gModName[32] = "AMX"
  26. #else
  27. #include <amxmodx>
  28. #include <amxmisc>
  29. #include <fun>
  30. #include <engine>
  31. #include <cstrike>
  32. new gModName[32] = "AMXX"
  33. #endif
  34.  
  35. #define TE_BEAMENTPOINT 1
  36. #define TE_KILLBEAM 99
  37. #define DELTA_T 0.1 // seconds
  38. #define BEAMLIFE 100 // deciseconds
  39. #define MOVEACCELERATION 150 // units per second^2
  40. #define REELSPEED 300 // units per second
  41.  
  42. /* Hook Stuff */
  43. new gHookLocation[33][3]
  44. new gHookLenght[33]
  45. new bool:gIsHooked[33]
  46. new gAllowedHook[33]
  47. new Float:gBeamIsCreated[33]
  48. new global_gravity
  49. new beam
  50.  
  51. /************************************************************************************************************************/
  52. public plugin_init() //Called on plugin start
  53. {
  54. // Plugin Info
  55. register_plugin("Admin Hook","1.0","AssKicR")
  56.  
  57. //CVARS
  58. register_cvar("sv_adminhook", "1" )
  59.  
  60. //ADMIN CMDS
  61. register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
  62.  
  63. //USER COMMANDS
  64. register_clcmd("+rope", "hook_on")
  65. register_clcmd("-rope", "hook_off")
  66. register_clcmd("+hook", "hook_on")
  67. register_clcmd("-hook", "hook_off")
  68.  
  69. //HOOKED EVENTS
  70. register_event("ResetHUD", "ResetHUD", "b")
  71. }
  72. /************************************************************************************************************************/
  73. public plugin_precache()
  74. {
  75. beam = precache_model("sprites/zbeam4.spr")
  76. precache_sound("weapons/xbow_hit2.wav")
  77. }
  78. /*************************************************************************************************************************/
  79. /************************************************** USP/SCOUT REMOVE *****************************************************/
  80. /*************************************************************************************************************************/
  81.  
  82. /*************************************************************************************************************************/
  83. /**************************************************** HOOKED EVENTS ******************************************************/
  84. /*************************************************************************************************************************/
  85. public ResetHUD(id) {
  86. //Check if he is hooked to something
  87. if (gIsHooked[id]) RopeRelease(id)
  88. }
  89. /************************************************************************************************************************/
  90. stock kz_velocity_set(id,vel[3]) {
  91. //Set Their Velocity to 0 so that they they fall straight down from
  92. new Float:Ivel[3]
  93. Ivel[0]=float(vel[0])
  94. Ivel[1]=float(vel[1])
  95. Ivel[2]=float(vel[2])
  96. entity_set_vector(id, EV_VEC_velocity, Ivel)
  97. }
  98.  
  99. stock kz_velocity_get(id,vel[3]) {
  100. //Set Their Velocity to 0 so that they they fall straight down from
  101. new Float:Ivel[3]
  102.  
  103. entity_get_vector(id, EV_VEC_velocity, Ivel)
  104. vel[0]=floatround(Ivel[0])
  105. vel[1]=floatround(Ivel[1])
  106. vel[2]=floatround(Ivel[2])
  107. }
  108.  
  109. /************************************************************************************************************************/
  110. /**************************************************** ADMIN COMMANDS ****************************************************/
  111. /************************************************************************************************************************/
  112. public AdminGrantHook(id,level,cid)
  113. {
  114. if ( !cmd_access(id,level,cid,1) )
  115. return PLUGIN_HANDLED
  116.  
  117. new arg1[32],arg2[32]
  118. read_argv(1,arg1,31)
  119. read_argv(2,arg2,31)
  120. new onoff = str_to_num(arg2)
  121.  
  122. if ( equali(arg1,"@all") )
  123. {
  124. new plist[32],pnum
  125. get_players(plist,pnum,"a")
  126. if (pnum==0)
  127. {
  128. console_print(id,"[%s] There are no clients",gModName)
  129. return PLUGIN_HANDLED
  130. }
  131. for (new i=0; i<pnum; i++) {
  132. gAllowedHook[plist[i]]=onoff
  133. if (gIsHooked[plist[i]]==true && onoff==0)
  134. {
  135. RopeRelease(plist[i])
  136. }
  137. }
  138.  
  139. console_print(id,"[%s] %s all players access to hook/rope",gModName,onoff ? "Gave":"Removed")
  140. }
  141. else if ( arg1[0]=='@' )
  142. {
  143. new plist[32],pnum
  144. get_players(plist,pnum,"ae",arg1[1])
  145. if ( pnum==0 )
  146. {
  147. console_print(id,"[%s] No clients in such team",gModName)
  148. return PLUGIN_HANDLED
  149. }
  150. for (new i=0; i<pnum; i++) {
  151. gAllowedHook[plist[i]]=onoff
  152. if (gIsHooked[plist[i]]==true && onoff==0)
  153. {
  154. RopeRelease(plist[i])
  155. }
  156. }
  157. console_print(id,"[%s] %s all %ss access to hook/rope",onoff ? "Gave":"Removed",arg1[1])
  158. }
  159. else
  160. {
  161. new pName[32]
  162. new player = cmd_target(id,arg1,6)
  163. if (!player) return PLUGIN_HANDLED
  164.  
  165. gAllowedHook[player]=onoff
  166. if (gAllowedHook[player]==0 && onoff==0)
  167. {
  168. RopeRelease(player)
  169. }
  170.  
  171.  
  172. get_user_name(player,pName,31)
  173. console_print(id,"[%s] %s ^"%s^" access to hook/rope",onoff ? "Gave":"Removed",pName)
  174. }
  175.  
  176. return PLUGIN_HANDLED
  177. }
  178.  
  179. /************************************************************************************************************************/
  180. /****************************************************** NINJAROPE *******************************************************/
  181. /************************************************************************************************************************/
  182.  
  183. public ropetask(parm[])
  184. {
  185. new id = parm[0]
  186. new user_origin[3], user_look[3], user_direction[3], move_direction[3]
  187. new A[3], D[3], buttonadjust[3]
  188. new acceleration, velocity_towards_A, desired_velocity_towards_A
  189. new velocity[3], null[3]
  190.  
  191. if (!is_user_alive(id))
  192. {
  193. RopeRelease(id)
  194. return
  195. }
  196.  
  197. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  198. {
  199. beamentpoint(id)
  200. }
  201.  
  202. null[0] = 0
  203. null[1] = 0
  204. null[2] = 0
  205.  
  206. get_user_origin(id, user_origin)
  207. get_user_origin(id, user_look,2)
  208. kz_velocity_get(id, velocity)
  209.  
  210. buttonadjust[0]=0
  211. buttonadjust[1]=0
  212.  
  213. if (get_user_button(id)&IN_FORWARD) buttonadjust[0]+=1
  214. if (get_user_button(id)&IN_BACK) buttonadjust[0]-=1
  215. if (get_user_button(id)&IN_MOVERIGHT) buttonadjust[1]+=1
  216. if (get_user_button(id)&IN_MOVELEFT) buttonadjust[1]-=1
  217. if (get_user_button(id)&IN_JUMP) buttonadjust[2]+=1
  218. if (get_user_button(id)&IN_DUCK) buttonadjust[2]-=1
  219.  
  220. if (buttonadjust[0] || buttonadjust[1])
  221. {
  222. user_direction[0] = user_look[0] - user_origin[0]
  223. user_direction[1] = user_look[1] - user_origin[1]
  224.  
  225. move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]
  226. move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]
  227. move_direction[2] = 0
  228.  
  229. velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  230. velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  231. }
  232.  
  233. if (buttonadjust[2]) gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)
  234. if (gHookLenght[id] < 100) gHookLenght[id] = 100
  235.  
  236. A[0] = gHookLocation[id][0] - user_origin[0]
  237. A[1] = gHookLocation[id][1] - user_origin[1]
  238. A[2] = gHookLocation[id][2] - user_origin[2]
  239.  
  240. D[0] = A[0]*A[2] / get_distance(null,A)
  241. D[1] = A[1]*A[2] / get_distance(null,A)
  242. D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)
  243.  
  244. acceleration = - global_gravity * D[2] / get_distance(null,D)
  245.  
  246. velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)
  247. desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4
  248.  
  249. if (get_distance(null,D)>10)
  250. {
  251. velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))
  252. velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))
  253. velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))
  254. }
  255.  
  256. velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)
  257. velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)
  258. velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)
  259.  
  260. kz_velocity_set(id, velocity)
  261. }
  262.  
  263. public hooktask(parm[])
  264. {
  265. new id = parm[0]
  266. new velocity[3]
  267.  
  268. if ( !gIsHooked[id] ) return
  269.  
  270. new user_origin[3],oldvelocity[3]
  271. parm[0] = id
  272.  
  273. if (!is_user_alive(id))
  274. {
  275. RopeRelease(id)
  276. return
  277. }
  278.  
  279. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  280. {
  281. beamentpoint(id)
  282. }
  283.  
  284. get_user_origin(id, user_origin)
  285. kz_velocity_get(id, oldvelocity)
  286. new distance=get_distance( gHookLocation[id], user_origin )
  287. if ( distance > 10 )
  288. {
  289. velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )
  290. velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )
  291. velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )
  292. }
  293. else
  294. {
  295. velocity[0]=0
  296. velocity[1]=0
  297. velocity[2]=0
  298. }
  299.  
  300. kz_velocity_set(id, velocity)
  301.  
  302. }
  303.  
  304. public hook_on(id)
  305. {
  306. if (get_cvar_num("sv_adminhook")==1)
  307. {
  308. if(cs_get_user_team(id) == CS_TEAM_CT)
  309. {
  310. if (gAllowedHook[id]) {
  311. if (!gIsHooked[id] && is_user_alive(id))
  312. {
  313. new cmd[32]
  314. read_argv(0,cmd,31)
  315. if(equal(cmd,"+rope")) RopeAttach(id,0)
  316. if(equal(cmd,"+hook")) RopeAttach(id,1)
  317. }
  318. }
  319. }
  320. }
  321. return PLUGIN_HANDLED
  322. }
  323.  
  324. public hook_off(id)
  325. {
  326. if(cs_get_user_team(id) == CS_TEAM_CT)
  327. {
  328. if (gAllowedHook[id]) {
  329. if (gIsHooked[id])
  330. {
  331. RopeRelease(id)
  332. }
  333. }
  334. }
  335. return PLUGIN_HANDLED
  336. }
  337.  
  338. public RopeAttach(id,hook)
  339. {
  340. new parm[1], user_origin[3]
  341. parm[0] = id
  342. gIsHooked[id] = true
  343. get_user_origin(id,user_origin)
  344. get_user_origin(id,gHookLocation[id], 3)
  345. gHookLenght[id] = get_distance(gHookLocation[id],user_origin)
  346. global_gravity = get_cvar_num("sv_gravity")
  347. set_user_gravity(id,0.001)
  348. beamentpoint(id)
  349. emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  350. if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")
  351. else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")
  352. }
  353.  
  354. public RopeRelease(id)
  355. {
  356. gIsHooked[id] = false
  357. killbeam(id)
  358. set_user_gravity(id)
  359. remove_task(200+id)
  360. }
  361.  
  362. public beamentpoint(id)
  363. {
  364. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  365. write_byte( TE_BEAMENTPOINT )
  366. write_short( id )
  367. write_coord( gHookLocation[id][0] )
  368. write_coord( gHookLocation[id][1] )
  369. write_coord( gHookLocation[id][2] )
  370. write_short( beam ) // sprite index
  371. write_byte( 0 ) // start frame
  372. write_byte( 0 ) // framerate
  373. write_byte( BEAMLIFE ) // life
  374. write_byte( 10 ) // width
  375. write_byte( 0 ) // noise
  376. if (get_user_team(id)==1) // Terrorist
  377. {
  378. write_byte( 255 ) // r, g, b
  379. write_byte( 0 ) // r, g, b
  380. write_byte( 0 ) // r, g, b
  381. }
  382. else // Counter-Terrorist
  383. {
  384. write_byte( 0 ) // r, g, b
  385. write_byte( 0 ) // r, g, b
  386. write_byte( 255 ) // r, g, b
  387. }
  388. write_byte( 150 ) // brightness
  389. write_byte( 0 ) // speed
  390. message_end( )
  391. gBeamIsCreated[id] = get_gametime()
  392. }
  393.  
  394. public killbeam(id)
  395. {
  396. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  397. write_byte( TE_KILLBEAM )
  398. write_short( id )
  399. message_end()
  400. }
  401.  
  402. /************************************************************************************************************************/
  403. /******************************************************* FORWARDS *******************************************************/
  404. /************************************************************************************************************************/
  405.  
  406. public client_disconnect(id) {
  407. gAllowedHook[id]=0
  408. }
  409.  
  410. /************************************************************************************************************************/
  411. /************************************************** AMXX -> AMX funcs ***************************************************/
  412. /************************************************************************************************************************/
  413. #if USING_AMX
  414. stock get_user_button(id) return entity_get_int(id, EV_INT_button)
  415. #endif

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 20:59 
Offline
Senior Tag
Avatar

Csatlakozott: 2013.12.06. 18:38
Hozzászólások: 229
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 16 alkalommal
Nem müködik ez most még annyira se nem lehet hookolni játékosnak Elöbbibe lehetett csak egyet :S


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Egyedi Hook
HozzászólásElküldve: 2014.01.16. 21:55 
Offline
Őskövület
Avatar

Csatlakozott: 2012.03.22. 18:22
Hozzászólások: 2978
Megköszönt másnak: 115 alkalommal
Megköszönték neki: 368 alkalommal
Próbáld ezt:

SMA Forráskód: [ Mindet kijelol ]
  1. /**************************************************************************************************
  2.  
  3. **** CVARS (FEATURES) ****
  4. sv_adminhook = Turn Plugin On/off
  5. **** ADMIN COMMANDS ****
  6. ADMIN_LEVEL_A (flag="m")
  7. Granting Hook/Rope = amx_granthook <authid, nick, @team, @all or #userid> <on/off>
  8.  
  9. ADMIN_LEVEL_E (flag="q") || Granted by admin
  10. Ninja Rope by Spacedude (slightly modified) & Hook thingy
  11. Attaching Rope = +rope
  12. Deattaching Rope = -rope
  13. Attaching Hook = +hook
  14. Deattaching Hook = -hook
  15.  
  16. **************************************************************************************************/
  17. #define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX
  18.  
  19. #if USING_AMX
  20. #include <amxmod>
  21. #include <amxmisc>
  22. #include <VexdUM>
  23. #include <fun>
  24. new gModName[32] = "AMX"
  25. #else
  26. #include <amxmodx>
  27. #include <amxmisc>
  28. #include <fun>
  29. #include <engine>
  30. new gModName[32] = "AMXX"
  31. #endif
  32. #include <cstrike>
  33. #define TE_BEAMENTPOINT 1
  34. #define TE_KILLBEAM 99
  35. #define DELTA_T 0.1 // seconds
  36. #define BEAMLIFE 100 // deciseconds
  37. #define MOVEACCELERATION 150 // units per second^2
  38. #define REELSPEED 300 // units per second
  39.  
  40. /* Hook Stuff */
  41. new gHookLocation[33][3]
  42. new gHookLenght[33]
  43. new bool:gIsHooked[33]
  44. new gAllowedHook[33]
  45. new Float:gBeamIsCreated[33]
  46. new global_gravity
  47. new beam
  48.  
  49. /************************************************************************************************************************/
  50. public plugin_init() //Called on plugin start
  51. {
  52. // Plugin Info
  53. register_plugin("Admin Hook","1.0","AssKicR")
  54.  
  55. //CVARS
  56. register_cvar("sv_adminhook", "1" )
  57.  
  58. //ADMIN CMDS
  59. register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
  60.  
  61. //USER COMMANDS
  62. register_clcmd("+rope", "hook_on",ADMIN_LEVEL_E)
  63. register_clcmd("-rope", "hook_off",ADMIN_LEVEL_E)
  64. register_clcmd("+hook", "hook_on",ADMIN_LEVEL_E)
  65. register_clcmd("-hook", "hook_off",ADMIN_LEVEL_E)
  66.  
  67. //HOOKED EVENTS
  68. register_event("ResetHUD", "ResetHUD", "b")
  69. }
  70. /************************************************************************************************************************/
  71. public plugin_precache()
  72. {
  73. beam = precache_model("sprites/zbeam4.spr")
  74. precache_sound("weapons/xbow_hit2.wav")
  75. }
  76. /*************************************************************************************************************************/
  77. /************************************************** USP/SCOUT REMOVE *****************************************************/
  78. /*************************************************************************************************************************/
  79.  
  80. /*************************************************************************************************************************/
  81. /**************************************************** HOOKED EVENTS ******************************************************/
  82. /*************************************************************************************************************************/
  83. public ResetHUD(id) {
  84. //Check if he is hooked to something
  85. if (gIsHooked[id]) RopeRelease(id)
  86. }
  87. /************************************************************************************************************************/
  88. stock kz_velocity_set(id,vel[3]) {
  89. //Set Their Velocity to 0 so that they they fall straight down from
  90. new Float:Ivel[3]
  91. Ivel[0]=float(vel[0])
  92. Ivel[1]=float(vel[1])
  93. Ivel[2]=float(vel[2])
  94. entity_set_vector(id, EV_VEC_velocity, Ivel)
  95. }
  96.  
  97. stock kz_velocity_get(id,vel[3]) {
  98. //Set Their Velocity to 0 so that they they fall straight down from
  99. new Float:Ivel[3]
  100.  
  101. entity_get_vector(id, EV_VEC_velocity, Ivel)
  102. vel[0]=floatround(Ivel[0])
  103. vel[1]=floatround(Ivel[1])
  104. vel[2]=floatround(Ivel[2])
  105. }
  106. public client_PreThink(id){
  107. if(cs_get_user_team(id) == CS_TEAM_CT){
  108. gAllowedHook[id]=true
  109. }
  110. else gAllowedHook[id]=true
  111. }
  112.  
  113. /************************************************************************************************************************/
  114. /**************************************************** ADMIN COMMANDS ****************************************************/
  115. /************************************************************************************************************************/
  116. public AdminGrantHook(id,level,cid)
  117. {
  118. if ( !cmd_access(id,level,cid,1) )
  119. return PLUGIN_HANDLED
  120.  
  121. new arg1[32],arg2[32]
  122. read_argv(1,arg1,31)
  123. read_argv(2,arg2,31)
  124. new onoff = str_to_num(arg2)
  125.  
  126. if ( equali(arg1,"@all") )
  127. {
  128. new plist[32],pnum
  129. get_players(plist,pnum,"a")
  130. if (pnum==0)
  131. {
  132. console_print(id,"[%s] There are no clients",gModName)
  133. return PLUGIN_HANDLED
  134. }
  135. for (new i=0; i<pnum; i++) {
  136. gAllowedHook[plist[i]]=onoff
  137. if (gIsHooked[plist[i]]==true && onoff==0)
  138. {
  139. RopeRelease(plist[i])
  140. }
  141. }
  142.  
  143. console_print(id,"[%s] %s all players access to hook/rope",gModName,onoff ? "Gave":"Removed")
  144. }
  145. else if ( arg1[0]=='@' )
  146. {
  147. new plist[32],pnum
  148. get_players(plist,pnum,"ae",arg1[1])
  149. if ( pnum==0 )
  150. {
  151. console_print(id,"[%s] No clients in such team",gModName)
  152. return PLUGIN_HANDLED
  153. }
  154. for (new i=0; i<pnum; i++) {
  155. gAllowedHook[plist[i]]=onoff
  156. if (gIsHooked[plist[i]]==true && onoff==0)
  157. {
  158. RopeRelease(plist[i])
  159. }
  160. }
  161. console_print(id,"[%s] %s all %ss access to hook/rope",onoff ? "Gave":"Removed",arg1[1])
  162. }
  163. else
  164. {
  165. new pName[32]
  166. new player = cmd_target(id,arg1,6)
  167. if (!player) return PLUGIN_HANDLED
  168.  
  169. gAllowedHook[player]=onoff
  170. if (gAllowedHook[player]==0 && onoff==0)
  171. {
  172. RopeRelease(player)
  173. }
  174.  
  175.  
  176. get_user_name(player,pName,31)
  177. console_print(id,"[%s] %s ^"%s^" access to hook/rope",onoff ? "Gave":"Removed",pName)
  178. }
  179.  
  180. return PLUGIN_HANDLED
  181. }
  182.  
  183. /************************************************************************************************************************/
  184. /****************************************************** NINJAROPE *******************************************************/
  185. /************************************************************************************************************************/
  186.  
  187. public ropetask(parm[])
  188. {
  189. new id = parm[0]
  190. new user_origin[3], user_look[3], user_direction[3], move_direction[3]
  191. new A[3], D[3], buttonadjust[3]
  192. new acceleration, velocity_towards_A, desired_velocity_towards_A
  193. new velocity[3], null[3]
  194.  
  195. if (!is_user_alive(id))
  196. {
  197. RopeRelease(id)
  198. return
  199. }
  200.  
  201. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  202. {
  203. beamentpoint(id)
  204. }
  205.  
  206. null[0] = 0
  207. null[1] = 0
  208. null[2] = 0
  209.  
  210. get_user_origin(id, user_origin)
  211. get_user_origin(id, user_look,2)
  212. kz_velocity_get(id, velocity)
  213.  
  214. buttonadjust[0]=0
  215. buttonadjust[1]=0
  216.  
  217. if (get_user_button(id)&IN_FORWARD) buttonadjust[0]+=1
  218. if (get_user_button(id)&IN_BACK) buttonadjust[0]-=1
  219. if (get_user_button(id)&IN_MOVERIGHT) buttonadjust[1]+=1
  220. if (get_user_button(id)&IN_MOVELEFT) buttonadjust[1]-=1
  221. if (get_user_button(id)&IN_JUMP) buttonadjust[2]+=1
  222. if (get_user_button(id)&IN_DUCK) buttonadjust[2]-=1
  223.  
  224. if (buttonadjust[0] || buttonadjust[1])
  225. {
  226. user_direction[0] = user_look[0] - user_origin[0]
  227. user_direction[1] = user_look[1] - user_origin[1]
  228.  
  229. move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]
  230. move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]
  231. move_direction[2] = 0
  232.  
  233. velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  234. velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
  235. }
  236.  
  237. if (buttonadjust[2]) gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)
  238. if (gHookLenght[id] < 100) gHookLenght[id] = 100
  239.  
  240. A[0] = gHookLocation[id][0] - user_origin[0]
  241. A[1] = gHookLocation[id][1] - user_origin[1]
  242. A[2] = gHookLocation[id][2] - user_origin[2]
  243.  
  244. D[0] = A[0]*A[2] / get_distance(null,A)
  245. D[1] = A[1]*A[2] / get_distance(null,A)
  246. D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)
  247.  
  248. acceleration = - global_gravity * D[2] / get_distance(null,D)
  249.  
  250. velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)
  251. desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4
  252.  
  253. if (get_distance(null,D)>10)
  254. {
  255. velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))
  256. velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))
  257. velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))
  258. }
  259.  
  260. velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)
  261. velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)
  262. velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)
  263.  
  264. kz_velocity_set(id, velocity)
  265. }
  266.  
  267. public hooktask(parm[])
  268. {
  269. new id = parm[0]
  270. new velocity[3]
  271.  
  272. if ( !gIsHooked[id] ) return
  273.  
  274. new user_origin[3],oldvelocity[3]
  275. parm[0] = id
  276.  
  277. if (!is_user_alive(id))
  278. {
  279. RopeRelease(id)
  280. return
  281. }
  282.  
  283. if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
  284. {
  285. beamentpoint(id)
  286. }
  287.  
  288. get_user_origin(id, user_origin)
  289. kz_velocity_get(id, oldvelocity)
  290. new distance=get_distance( gHookLocation[id], user_origin )
  291. if ( distance > 10 )
  292. {
  293. velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )
  294. velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )
  295. velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )
  296. }
  297. else
  298. {
  299. velocity[0]=0
  300. velocity[1]=0
  301. velocity[2]=0
  302. }
  303.  
  304. kz_velocity_set(id, velocity)
  305.  
  306. }
  307.  
  308. public hook_on(id)
  309. {
  310. if (get_cvar_num("sv_adminhook")==1)
  311. {
  312. if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E)) {
  313. if (!gIsHooked[id] && is_user_alive(id))
  314. {
  315. new cmd[32]
  316. read_argv(0,cmd,31)
  317. if(equal(cmd,"+rope")) RopeAttach(id,0)
  318. if(equal(cmd,"+hook")) RopeAttach(id,1)
  319. }
  320. }else{
  321. client_print(id,print_chat,"[%s] You have no access to that command",gModName)
  322. return PLUGIN_HANDLED
  323. }
  324. }else{
  325. client_print(id,print_chat,"[%s] This command is deativated",gModName)
  326. }
  327. return PLUGIN_HANDLED
  328. }
  329.  
  330. public hook_off(id)
  331. {
  332. if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E)) {
  333. if (gIsHooked[id])
  334. {
  335. RopeRelease(id)
  336. }
  337. }else{
  338. client_print(id,print_chat,"[%s] You have no access to that command",gModName)
  339. return PLUGIN_HANDLED
  340. }
  341. return PLUGIN_HANDLED
  342. }
  343.  
  344. public RopeAttach(id,hook)
  345. {
  346. new parm[1], user_origin[3]
  347. parm[0] = id
  348. gIsHooked[id] = true
  349. get_user_origin(id,user_origin)
  350. get_user_origin(id,gHookLocation[id], 3)
  351. gHookLenght[id] = get_distance(gHookLocation[id],user_origin)
  352. global_gravity = get_cvar_num("sv_gravity")
  353. set_user_gravity(id,0.001)
  354. beamentpoint(id)
  355. emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  356. if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")
  357. else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")
  358. }
  359.  
  360. public RopeRelease(id)
  361. {
  362. gIsHooked[id] = false
  363. killbeam(id)
  364. set_user_gravity(id)
  365. remove_task(200+id)
  366. }
  367.  
  368. public beamentpoint(id)
  369. {
  370. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  371. write_byte( TE_BEAMENTPOINT )
  372. write_short( id )
  373. write_coord( gHookLocation[id][0] )
  374. write_coord( gHookLocation[id][1] )
  375. write_coord( gHookLocation[id][2] )
  376. write_short( beam ) // sprite index
  377. write_byte( 0 ) // start frame
  378. write_byte( 0 ) // framerate
  379. write_byte( BEAMLIFE ) // life
  380. write_byte( 10 ) // width
  381. write_byte( 0 ) // noise
  382. if (get_user_team(id)==1) // Terrorist
  383. {
  384. write_byte( 255 ) // r, g, b
  385. write_byte( 0 ) // r, g, b
  386. write_byte( 0 ) // r, g, b
  387. }
  388. else // Counter-Terrorist
  389. {
  390. write_byte( 0 ) // r, g, b
  391. write_byte( 0 ) // r, g, b
  392. write_byte( 255 ) // r, g, b
  393. }
  394. write_byte( 150 ) // brightness
  395. write_byte( 0 ) // speed
  396. message_end( )
  397. gBeamIsCreated[id] = get_gametime()
  398. }
  399.  
  400. public killbeam(id)
  401. {
  402. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  403. write_byte( TE_KILLBEAM )
  404. write_short( id )
  405. message_end()
  406. }
  407.  
  408. /************************************************************************************************************************/
  409. /******************************************************* FORWARDS *******************************************************/
  410. /************************************************************************************************************************/
  411.  
  412. public client_disconnect(id) {
  413. gAllowedHook[id]=0
  414. }
  415.  
  416. /************************************************************************************************************************/
  417. /************************************************** AMXX -> AMX funcs ***************************************************/
  418. /************************************************************************************************************************/
  419. #if USING_AMX
  420. stock get_user_button(id) return entity_get_int(id, EV_INT_button)
  421. #endif

_________________
Blasenkampfwagen

https://discord.gg/uBYnNnZP
GTA:PURSUIT MTA


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 12 hozzászólás ]  Oldal 1 2 Következő


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 37 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole