hlmod.hu

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



Jelenlévő felhasználók

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

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

Regisztrált felhasználók: Bing [Bot] 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  [ 4 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Grab minden játékosnak
HozzászólásElküldve: 2015.03.29. 14:49 
Offline
Jómunkásember
Avatar

Csatlakozott: 2014.04.14. 16:23
Hozzászólások: 475
Megköszönt másnak: 97 alkalommal
Megköszönték neki: 4 alkalommal
Sziasztok
Azt szeretném kérni,hogy a grab minden játékos számára elérhető legyen,azaz ne kelljen hozzá semmilyen jog.
Kérlek valaki írja át úgy nekem.
A plugin:
SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. /*
  3. Grab+ v1.2.3
  4. Copyright (C) 2007 Ian (Juan) Cammarata
  5.  
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Affero General Public License as
  8. published by the Free Software Foundation, either version 3 of the
  9. License, or (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Affero General Public License for more details.
  15.  
  16. You should have received a copy of the GNU Affero General Public License
  17. along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. --------------------------------------------------------------------------------
  19.  
  20. Nov 21 11:03
  21.  
  22.  
  23. Description:
  24. This is a remake from scratch of SpaceDude's Jedi Force Grab plugin. It has many additional features and optimizations, is less spammy, multilingual and requires fewer binds.
  25.  
  26.  
  27. Features:
  28. Multilingual
  29. Screenfade to indicate grab activity instead of chat spam.
  30. Can grab players off a ladder.
  31. Automatically choke by holding down +pull while at min distance.
  32. Choke with use key.
  33. Throw with drop.
  34. Can't have mutliple admins grabbing the same player.
  35. Auto drop on death.
  36. Grab entities other than players, such as bombs, weapons, and hostages.
  37.  
  38.  
  39. Commands:
  40.  
  41. +grab : Grab something for as long as you hold down the key.
  42. grab_toggle : Same as +grab but toggles.
  43. amx_grab <name> : Grab client by name or id and teleport them to you. Use +grab or grab_toggle key to release.
  44.  
  45. +pull/+push (or invnext/invprev): Pulls/pushes the grabbed towards/away from you as you hold the button.
  46.  
  47. +use : Chokes the grabbed (it damages the grabbed with 5 (cvar: gp_choke_dmg) hp per 1.5 (cvar: gp_choke_time) seconds)
  48. drop - Throws the grabbed with 1500 velocity. (cvar: gp_throw_force)
  49.  
  50.  
  51. Cvars (First value is default):
  52. gp_enabled <1|0> Enables all plugin functionality.
  53. gp_players_only <0|1> Disables admins grabbing entities other than players.
  54.  
  55. gp_min_dist <90|...> Min distance between the grabber and grabbed.
  56. gp_grab_force <8|...> Sets the amount of force used when grabbing players.
  57. gp_throw_force <1500|...> Sets the power used when throwing players.
  58. gp_speed <5|...> How fast the grabbed moves when using push and pull.
  59.  
  60. gp_choke_time <1.5|...> Time frequency for choking.
  61. gp_choke_dmg <5|...> Amount of damage done with each choke.
  62. gp_auto_choke <1|0> Enable/disable choking automatically with +pull command.
  63.  
  64. gp_screen_fade <1|0> Enables/disables screenfade when grabbing.
  65. gp_glow <1|0> Enables/disables glowing for grabbed objects.
  66.  
  67. gp_glow_r <50|0-255> Sets red amount for glow and screenfade.
  68. gp_glow_g <0|0-255> Sets green amount for glow and screenfade.
  69. gp_glow_b <0|0-255> Sets blue amount for glow and screenfade.
  70. gp_glow_a <0|0-255> Sets alpha for glow and screenfade.
  71.  
  72.  
  73. Notes:
  74. Make sure you place the grab_plus.txt file in addons\amxmodx\data\lang
  75.  
  76.  
  77. Credits:
  78. Thanks to vittu for contributing code (changed all engine/fun module stuff to fakemeta).
  79.  
  80. Thanks to all the coders who worked on the original Jedi Force Grab plugin for all their ideas:
  81. SpaceDude
  82. KCE
  83. KRoTaL
  84. BOB_SLAYER
  85. kosmo111
  86.  
  87.  
  88. Supported Languages:
  89. 1337 (100%) - Thanks to l337newb
  90. Brazilian Portuguese (100%) - Thanks to Arion
  91. Danish (100%) - Thanks to nellerbabz
  92. Dutch (100%) - Thanks to BlackMilk
  93. English (100%)
  94. Finnish (100%) - Thanks to Pro Patria Finland
  95. French (100%) - Thanks to connorr
  96. German (100%) - Thanks to SchlumPF*
  97. Russian (100%) - Thanks to `666
  98. Spanish (100%) - Hope these don't suck.
  99. Swedish (100%) - Thanks to Bend3r
  100.  
  101.  
  102. Change Log:
  103. Key (+ added | - removed | c changed | f fixed)
  104.  
  105. v1.2.3 (Nov 21, 2007)
  106. c: A few more small optimizations.
  107. f: Bloodstream for choke wasn't aligned with player.
  108. f: Bad message disconnect error when players were choked. ( stupid SVC_DAMAGE define )
  109.  
  110. v1.2.2 (Nov 16, 2007)
  111. c: A few small code optimizations.
  112.  
  113. v1.2.1 (Nov 12, 2007)
  114. f: Eliminated two run time warnings in the player prethink function.
  115.  
  116. v1.2 (Nov 06, 2007)
  117. +: Cvars gp_screen_fade and gp_glow to enable/disable these features.
  118. +: Cvar gp_glow_a controls to control alpha of screenfade and glow.
  119. +: Cvar gp_auto_choke to enable/disable choking automatically with +pull command.
  120. c: Removed dependency of engine and fun modules. Thanks to vittu for doing most of the work.
  121. c: Made cvar names more consistent by adding more underscores.
  122. f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7.x as well).
  123.  
  124. v1.1 (Oct 16, 2007)
  125. +: Grab a few types of entities other than players.
  126. +: Cvar gp_players_only.
  127.  
  128. v1.0 (Oct 13, 2007)
  129. !: Initial release
  130.  
  131. */
  132.  
  133. #include <amxmodx>
  134. #include <amxmisc>
  135. #include <fakemeta>
  136.  
  137. new const VERSION[ ] = "1.2.3"
  138. new const TRKCVAR[ ] = "grab_plus_version"
  139. #define ADMIN ADMIN_LEVEL_A
  140.  
  141. #define TSK_CHKE 50
  142.  
  143. #define SF_FADEOUT 0
  144.  
  145. new client_data[33][4]
  146. #define GRABBED 0
  147. #define GRABBER 1
  148. #define GRAB_LEN 2
  149. #define FLAGS 3
  150.  
  151. #define CDF_IN_PUSH (1<<0)
  152. #define CDF_IN_PULL (1<<1)
  153. #define CDF_NO_CHOKE (1<<2)
  154.  
  155. //Cvar Pointers
  156. new p_enabled, p_players_only
  157. new p_throw_force, p_min_dist, p_speed, p_grab_force
  158. new p_choke_time, p_choke_dmg, p_auto_choke
  159. new p_glow_r, p_glow_b, p_glow_g, p_glow_a
  160. new p_fade, p_glow
  161.  
  162. //Pseudo Constants
  163. new MAXPLAYERS
  164. new SVC_SCREENFADE, SVC_SCREENSHAKE, WTF_DAMAGE
  165.  
  166. public plugin_init( )
  167. {
  168. register_plugin( "Grab+", VERSION, "Ian Cammarata" )
  169. register_cvar( TRKCVAR, VERSION, FCVAR_SERVER )
  170. set_cvar_string( TRKCVAR, VERSION )
  171.  
  172. p_enabled = register_cvar( "gp_enabled", "1" )
  173. p_players_only = register_cvar( "gp_players_only", "0" )
  174.  
  175. p_min_dist = register_cvar ( "gp_min_dist", "90" )
  176. p_throw_force = register_cvar( "gp_throw_force", "1500" )
  177. p_grab_force = register_cvar( "gp_grab_force", "8" )
  178. p_speed = register_cvar( "gp_speed", "5" )
  179.  
  180. p_choke_time = register_cvar( "gp_choke_time", "1.5" )
  181. p_choke_dmg = register_cvar( "gp_choke_dmg", "5" )
  182. p_auto_choke = register_cvar( "gp_auto_choke", "1" )
  183.  
  184. p_glow_r = register_cvar( "gp_glow_r", "50" )
  185. p_glow_g = register_cvar( "gp_glow_g", "0" )
  186. p_glow_b = register_cvar( "gp_glow_b", "0" )
  187. p_glow_a = register_cvar( "gp_glow_a", "200" )
  188.  
  189. p_fade = register_cvar( "gp_screen_fade", "1" )
  190. p_glow = register_cvar( "gp_glow", "1" )
  191.  
  192. register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." )
  193. register_clcmd( "grab_toggle", "grab_toggle", ADMIN, "press once to grab and again to release" )
  194. register_clcmd( "+grab", "grab", ADMIN, "bind a key to +grab" )
  195. register_clcmd( "-grab", "unset_grabbed" )
  196.  
  197. register_clcmd( "+push", "push", ADMIN, "bind a key to +push" )
  198. register_clcmd( "-push", "push" )
  199. register_clcmd( "+pull", "pull", ADMIN, "bind a key to +pull" )
  200. register_clcmd( "-pull", "pull" )
  201. register_clcmd( "push", "push2" )
  202. register_clcmd( "pull", "pull2" )
  203.  
  204. register_clcmd( "drop" ,"throw" )
  205.  
  206. register_event( "DeathMsg", "DeathMsg", "a" )
  207.  
  208. register_forward( FM_PlayerPreThink, "fm_player_prethink" )
  209.  
  210. register_dictionary( "grab_plus.txt" )
  211.  
  212. MAXPLAYERS = get_maxplayers()
  213.  
  214. SVC_SCREENFADE = get_user_msgid( "ScreenFade" )
  215. SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" )
  216. WTF_DAMAGE = get_user_msgid( "Damage" )
  217. }
  218.  
  219. public plugin_precache( )
  220. {
  221. precache_sound( "player/PL_PAIN2.WAV" )
  222. }
  223.  
  224. public fm_player_prethink( id )
  225. {
  226. new target
  227. //Search for a target
  228. if ( client_data[id][GRABBED] == -1 )
  229. {
  230. new Float:orig[3], Float:ret[3]
  231. get_view_pos( id, orig )
  232. ret = vel_by_aim( id, 9999 )
  233.  
  234. ret[0] += orig[0]
  235. ret[1] += orig[1]
  236. ret[2] += orig[2]
  237.  
  238. target = traceline( orig, ret, id, ret )
  239.  
  240. if( 0 < target <= MAXPLAYERS )
  241. {
  242. if( is_grabbed( target, id ) ) return FMRES_IGNORED
  243. set_grabbed( id, target )
  244. }
  245. else if( !get_pcvar_num( p_players_only ) )
  246. {
  247. new movetype
  248. if( target && pev_valid( target ) )
  249. {
  250. movetype = pev( target, pev_movetype )
  251. if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) )
  252. return FMRES_IGNORED
  253. }
  254. else
  255. {
  256. target = 0
  257. new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 )
  258. while( !target && ent > 0 )
  259. {
  260. movetype = pev( ent, pev_movetype )
  261. if( ( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS )
  262. && ent != id )
  263. target = ent
  264. ent = engfunc( EngFunc_FindEntityInSphere, ent, ret, 12.0 )
  265. }
  266. }
  267. if( target )
  268. {
  269. if( is_grabbed( target, id ) ) return FMRES_IGNORED
  270. set_grabbed( id, target )
  271. }
  272. }
  273. }
  274.  
  275. target = client_data[id][GRABBED]
  276. //If they've grabbed something
  277. if( target > 0 )
  278. {
  279. if( !pev_valid( target ) || ( pev( target, pev_health ) < 1 && pev( target, pev_max_health ) ) )
  280. {
  281. unset_grabbed( id )
  282. return FMRES_IGNORED
  283. }
  284.  
  285. //Use key choke
  286. if( pev( id, pev_button ) & IN_USE )
  287. do_choke( id )
  288.  
  289. //Push and pull
  290. new cdf = client_data[id][FLAGS]
  291. if ( cdf & CDF_IN_PULL )
  292. do_pull( id )
  293. else if ( cdf & CDF_IN_PUSH )
  294. do_push( id )
  295.  
  296. if( target > MAXPLAYERS ) grab_think( id )
  297. }
  298.  
  299. //If they're grabbed
  300. target = client_data[id][GRABBER]
  301. if( target > 0 ) grab_think( target )
  302.  
  303. return FMRES_IGNORED
  304. }
  305.  
  306. public grab_think( id ) //id of the grabber
  307. {
  308. new target = client_data[id][GRABBED]
  309.  
  310. //Keep grabbed clients from sticking to ladders
  311. if( pev( target, pev_movetype ) == MOVETYPE_FLY && !(pev( target, pev_button ) & IN_JUMP ) ) client_cmd( target, "+jump;wait;-jump" )
  312.  
  313. //Move targeted client
  314. new Float:tmpvec[3], Float:tmpvec2[3], Float:torig[3], Float:tvel[3]
  315.  
  316. get_view_pos( id, tmpvec )
  317.  
  318. tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] )
  319.  
  320. torig = get_target_origin_f( target )
  321.  
  322. new force = get_pcvar_num( p_grab_force )
  323.  
  324. tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force
  325. tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force
  326. tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force
  327.  
  328. set_pev( target, pev_velocity, tvel )
  329. }
  330.  
  331. stock Float:get_target_origin_f( id )
  332. {
  333. new Float:orig[3]
  334. pev( id, pev_origin, orig )
  335.  
  336. //If grabbed is not a player, move origin to center
  337. if( id > MAXPLAYERS )
  338. {
  339. new Float:mins[3], Float:maxs[3]
  340. pev( id, pev_mins, mins )
  341. pev( id, pev_maxs, maxs )
  342.  
  343. if( !mins[2] ) orig[2] += maxs[2] / 2
  344. }
  345.  
  346. return orig
  347. }
  348.  
  349. public grab_toggle( id, level, cid )
  350. {
  351. if( !client_data[id][GRABBED] ) grab( id, level, cid )
  352. else unset_grabbed( id )
  353.  
  354. return PLUGIN_HANDLED
  355. }
  356.  
  357. public grab( id, level, cid )
  358. {
  359. if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED
  360.  
  361. if ( !client_data[id][GRABBED] ) client_data[id][GRABBED] = -1
  362. screenfade_in( id )
  363.  
  364. return PLUGIN_HANDLED
  365. }
  366.  
  367. public screenfade_in( id )
  368. {
  369. if( get_pcvar_num( p_fade ) )
  370. {
  371. message_begin( MSG_ONE, SVC_SCREENFADE, _, id )
  372. write_short( 10000 ) //duration
  373. write_short( 0 ) //hold
  374. write_short( SF_FADE_IN + SF_FADE_ONLYONE ) //flags
  375. write_byte( get_pcvar_num( p_glow_r ) ) //r
  376. write_byte( get_pcvar_num( p_glow_g ) ) //g
  377. write_byte( get_pcvar_num( p_glow_b ) ) //b
  378. write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a
  379. message_end( )
  380. }
  381. }
  382.  
  383. public throw( id )
  384. {
  385. new target = client_data[id][GRABBED]
  386. if( target > 0 )
  387. {
  388. set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) )
  389. unset_grabbed( id )
  390. return PLUGIN_HANDLED
  391. }
  392.  
  393. return PLUGIN_CONTINUE
  394. }
  395.  
  396. public unset_grabbed( id )
  397. {
  398. new target = client_data[id][GRABBED]
  399. if( target > 0 && pev_valid( target ) )
  400. {
  401. set_pev( target, pev_renderfx, kRenderFxNone )
  402. set_pev( target, pev_rendercolor, {255.0, 255.0, 255.0} )
  403. set_pev( target, pev_rendermode, kRenderNormal )
  404. set_pev( target, pev_renderamt, 16.0 )
  405.  
  406. if( 0 < target <= MAXPLAYERS )
  407. client_data[target][GRABBER] = 0
  408. }
  409. client_data[id][GRABBED] = 0
  410.  
  411. if( get_pcvar_num( p_fade ) )
  412. {
  413. message_begin( MSG_ONE, SVC_SCREENFADE, _, id )
  414. write_short( 10000 ) //duration
  415. write_short( 0 ) //hold
  416. write_short( SF_FADEOUT ) //flags
  417. write_byte( get_pcvar_num( p_glow_r ) ) //r
  418. write_byte( get_pcvar_num( p_glow_g ) ) //g
  419. write_byte( get_pcvar_num( p_glow_b ) ) //b
  420. write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a
  421. message_end( )
  422. }
  423. }
  424.  
  425. //Grabs onto someone
  426. public set_grabbed( id, target )
  427. {
  428. if( get_pcvar_num( p_glow ) )
  429. {
  430. new Float:color[3]
  431. color[0] = get_pcvar_float( p_glow_r )
  432. color[1] = get_pcvar_float( p_glow_g )
  433. color[2] = get_pcvar_float( p_glow_b )
  434. set_pev( target, pev_renderfx, kRenderFxGlowShell )
  435. set_pev( target, pev_rendercolor, color )
  436. set_pev( target, pev_rendermode, kRenderTransColor )
  437. set_pev( target, pev_renderamt, get_pcvar_float( p_glow_a ) )
  438. }
  439.  
  440. if( 0 < target <= MAXPLAYERS )
  441. client_data[target][GRABBER] = id
  442. client_data[id][FLAGS] = 0
  443. client_data[id][GRABBED] = target
  444. new Float:torig[3], Float:orig[3]
  445. pev( target, pev_origin, torig )
  446. pev( id, pev_origin, orig )
  447. client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) )
  448. if( client_data[id][GRAB_LEN] < get_pcvar_num( p_min_dist ) ) client_data[id][GRAB_LEN] = get_pcvar_num( p_min_dist )
  449. }
  450.  
  451. public push( id )
  452. {
  453. client_data[id][FLAGS] ^= CDF_IN_PUSH
  454. return PLUGIN_HANDLED
  455. }
  456.  
  457. public pull( id )
  458. {
  459. client_data[id][FLAGS] ^= CDF_IN_PULL
  460. return PLUGIN_HANDLED
  461. }
  462.  
  463. public push2( id )
  464. {
  465. if( client_data[id][GRABBED] > 0 )
  466. {
  467. do_push( id )
  468. return PLUGIN_HANDLED
  469. }
  470. return PLUGIN_CONTINUE
  471. }
  472.  
  473. public pull2( id )
  474. {
  475. if( client_data[id][GRABBED] > 0 )
  476. {
  477. do_pull( id )
  478. return PLUGIN_HANDLED
  479. }
  480. return PLUGIN_CONTINUE
  481. }
  482.  
  483. public do_push( id )
  484. if( client_data[id][GRAB_LEN] < 9999 )
  485. client_data[id][GRAB_LEN] += get_pcvar_num( p_speed )
  486.  
  487. public do_pull( id )
  488. {
  489. new mindist = get_pcvar_num( p_min_dist )
  490. new len = client_data[id][GRAB_LEN]
  491.  
  492. if( len > mindist )
  493. {
  494. len -= get_pcvar_num( p_speed )
  495. if( len < mindist ) len = mindist
  496. client_data[id][GRAB_LEN] = len
  497. }
  498. else if( get_pcvar_num( p_auto_choke ) )
  499. do_choke( id )
  500. }
  501.  
  502. public do_choke( id )
  503. {
  504. new target = client_data[id][GRABBED]
  505. if( client_data[id][FLAGS] & CDF_NO_CHOKE || id == target || target > MAXPLAYERS) return
  506.  
  507. new dmg = get_pcvar_num( p_choke_dmg )
  508. new vec[3]
  509. FVecIVec( get_target_origin_f( target ), vec )
  510.  
  511. message_begin( MSG_ONE, SVC_SCREENSHAKE, _, target )
  512. write_short( 999999 ) //amount
  513. write_short( 9999 ) //duration
  514. write_short( 999 ) //frequency
  515. message_end( )
  516.  
  517. message_begin( MSG_ONE, SVC_SCREENFADE, _, target )
  518. write_short( 9999 ) //duration
  519. write_short( 100 ) //hold
  520. write_short( SF_FADE_MODULATE ) //flags
  521. write_byte( get_pcvar_num( p_glow_r ) ) //r
  522. write_byte( get_pcvar_num( p_glow_g ) ) //g
  523. write_byte( get_pcvar_num( p_glow_b ) ) //b
  524. write_byte( 200 ) //a
  525. message_end( )
  526.  
  527. message_begin( MSG_ONE, WTF_DAMAGE, _, target )
  528. write_byte( 0 ) //damage armor
  529. write_byte( dmg ) //damage health
  530. write_long( DMG_CRUSH ) //damage type
  531. write_coord( vec[0] ) //origin[x]
  532. write_coord( vec[1] ) //origin[y]
  533. write_coord( vec[2] ) //origin[z]
  534. message_end( )
  535.  
  536. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  537. write_byte( TE_BLOODSTREAM )
  538. write_coord( vec[0] ) //pos.x
  539. write_coord( vec[1] ) //pos.y
  540. write_coord( vec[2] + 15 ) //pos.z
  541. write_coord( random_num( 0, 255 ) ) //vec.x
  542. write_coord( random_num( 0, 255 ) ) //vec.y
  543. write_coord( random_num( 0, 255 ) ) //vec.z
  544. write_byte( 70 ) //col index
  545. write_byte( random_num( 50, 250 ) ) //speed
  546. message_end( )
  547.  
  548. new health = pev( target, pev_health ) - dmg
  549. set_pev( target, pev_health, float( health ) )
  550. if( health < 1 ) dllfunc( DLLFunc_ClientKill, target )
  551.  
  552. emit_sound( target, CHAN_BODY, "player/PL_PAIN2.WAV", VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  553.  
  554. client_data[id][FLAGS] ^= CDF_NO_CHOKE
  555. set_task( get_pcvar_float( p_choke_time ), "clear_no_choke", TSK_CHKE + id )
  556. }
  557.  
  558. public clear_no_choke( tskid )
  559. {
  560. new id = tskid - TSK_CHKE
  561. client_data[id][FLAGS] ^= CDF_NO_CHOKE
  562. }
  563.  
  564. //Grabs the client and teleports them to the admin
  565. public force_grab(id, level, cid)
  566. {
  567. if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED
  568.  
  569. new arg[33]
  570. read_argv( 1, arg, 32 )
  571.  
  572. new targetid = cmd_target( id, arg, 1 )
  573.  
  574. if( is_grabbed( targetid, id ) ) return PLUGIN_HANDLED
  575. if( !is_user_alive( targetid ) )
  576. {
  577. client_print( id, print_console, "[AMXX] %L", id, "COULDNT" )
  578. return PLUGIN_HANDLED
  579. }
  580.  
  581. //Safe to tp target to aim spot?
  582. new Float:tmpvec[3], Float:orig[3], Float:torig[3], Float:trace_ret[3]
  583. new bool:safe = false, i
  584.  
  585. get_view_pos( id, orig )
  586. tmpvec = vel_by_aim( id, get_pcvar_num( p_min_dist ) )
  587.  
  588. for( new j = 1; j < 11 && !safe; j++ )
  589. {
  590. torig[0] = orig[0] + tmpvec[i] * j
  591. torig[1] = orig[1] + tmpvec[i] * j
  592. torig[2] = orig[2] + tmpvec[i] * j
  593.  
  594. traceline( tmpvec, torig, id, trace_ret )
  595.  
  596. if( get_distance_f( trace_ret, torig ) ) break
  597.  
  598. engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
  599. if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) )
  600. safe = true
  601. }
  602.  
  603. //Still not safe? Then find another safe spot somewhere around the grabber
  604. pev( id, pev_origin, orig )
  605. new try[3]
  606. orig[2] += 2
  607. while( try[2] < 3 && !safe )
  608. {
  609. for( i = 0; i < 3; i++ )
  610. switch( try[i] )
  611. {
  612. case 0 : torig[i] = orig[i] + ( i == 2 ? 80 : 40 )
  613. case 1 : torig[i] = orig[i]
  614. case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )
  615. }
  616.  
  617. traceline( tmpvec, torig, id, trace_ret )
  618.  
  619. engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
  620. if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen )
  621. && !get_distance_f( trace_ret, torig ) ) safe = true
  622.  
  623. try[0]++
  624. if( try[0] == 3 )
  625. {
  626. try[0] = 0
  627. try[1]++
  628. if( try[1] == 3 )
  629. {
  630. try[1] = 0
  631. try[2]++
  632. }
  633. }
  634. }
  635.  
  636. if( safe )
  637. {
  638. set_pev( targetid, pev_origin, torig )
  639. set_grabbed( id, targetid )
  640. screenfade_in( id )
  641. }
  642. else client_print( id, print_chat, "[AMXX] %L", id, "COULDNT" )
  643.  
  644. return PLUGIN_HANDLED
  645. }
  646.  
  647. public is_grabbed( target, grabber )
  648. {
  649. for( new i = 1; i <= MAXPLAYERS; i++ )
  650. if( client_data[i][GRABBED] == target )
  651. {
  652. client_print( grabber, print_chat, "[AMXX] %L", grabber, "ALREADY" )
  653. unset_grabbed( grabber )
  654. return true
  655. }
  656. return false
  657. }
  658.  
  659. public DeathMsg( )
  660. kill_grab( read_data( 2 ) )
  661.  
  662. public client_disconnect( id )
  663. {
  664. kill_grab( id )
  665. return PLUGIN_CONTINUE
  666. }
  667.  
  668. public kill_grab( id )
  669. {
  670. //If given client has grabbed, or has a grabber, unset it
  671. if( client_data[id][GRABBED] )
  672. unset_grabbed( id )
  673. else if( client_data[id][GRABBER] )
  674. unset_grabbed( client_data[id][GRABBER] )
  675. }
  676.  
  677. stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] )
  678. {
  679. engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 )
  680. get_tr2( 0, TR_vecEndPos, vHitPos )
  681. return get_tr2( 0, TR_pHit )
  682. }
  683.  
  684. stock get_view_pos( const id, Float:vViewPos[3] )
  685. {
  686. new Float:vOfs[3]
  687. pev( id, pev_origin, vViewPos )
  688. pev( id, pev_view_ofs, vOfs )
  689.  
  690. vViewPos[0] += vOfs[0]
  691. vViewPos[1] += vOfs[1]
  692. vViewPos[2] += vOfs[2]
  693. }
  694.  
  695. stock Float:vel_by_aim( id, speed = 1 )
  696. {
  697. new Float:v1[3], Float:vBlah[3]
  698. pev( id, pev_v_angle, v1 )
  699. engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah )
  700.  
  701. v1[0] *= speed
  702. v1[1] *= speed
  703. v1[2] *= speed
  704.  
  705. return v1
  706. }
  707.  

_________________
Kép
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Grab minden játékosnak
HozzászólásElküldve: 2015.03.29. 14:57 
Offline
Senior Tag
Avatar

Csatlakozott: 2014.07.03. 00:07
Hozzászólások: 297
Megköszönt másnak: 37 alkalommal
Megköszönték neki: 35 alkalommal
TRY
SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. /*
  3. Grab+ v1.2.3
  4. Copyright (C) 2007 Ian (Juan) Cammarata
  5.  
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Affero General Public License as
  8. published by the Free Software Foundation, either version 3 of the
  9. License, or (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Affero General Public License for more details.
  15.  
  16. You should have received a copy of the GNU Affero General Public License
  17. along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. --------------------------------------------------------------------------------
  19.  
  20. Nov 21 11:03
  21.  
  22.  
  23. Description:
  24. This is a remake from scratch of SpaceDude's Jedi Force Grab plugin. It has many additional features and optimizations, is less spammy, multilingual and requires fewer binds.
  25.  
  26.  
  27. Features:
  28. Multilingual
  29. Screenfade to indicate grab activity instead of chat spam.
  30. Can grab players off a ladder.
  31. Automatically choke by holding down +pull while at min distance.
  32. Choke with use key.
  33. Throw with drop.
  34. Can't have mutliple admins grabbing the same player.
  35. Auto drop on death.
  36. Grab entities other than players, such as bombs, weapons, and hostages.
  37.  
  38.  
  39. Commands:
  40.  
  41. +grab : Grab something for as long as you hold down the key.
  42. grab_toggle : Same as +grab but toggles.
  43. amx_grab <name> : Grab client by name or id and teleport them to you. Use +grab or grab_toggle key to release.
  44.  
  45. +pull/+push (or invnext/invprev): Pulls/pushes the grabbed towards/away from you as you hold the button.
  46.  
  47. +use : Chokes the grabbed (it damages the grabbed with 5 (cvar: gp_choke_dmg) hp per 1.5 (cvar: gp_choke_time) seconds)
  48. drop - Throws the grabbed with 1500 velocity. (cvar: gp_throw_force)
  49.  
  50.  
  51. Cvars (First value is default):
  52. gp_enabled <1|0> Enables all plugin functionality.
  53. gp_players_only <0|1> Disables admins grabbing entities other than players.
  54.  
  55. gp_min_dist <90|...> Min distance between the grabber and grabbed.
  56. gp_grab_force <8|...> Sets the amount of force used when grabbing players.
  57. gp_throw_force <1500|...> Sets the power used when throwing players.
  58. gp_speed <5|...> How fast the grabbed moves when using push and pull.
  59.  
  60. gp_choke_time <1.5|...> Time frequency for choking.
  61. gp_choke_dmg <5|...> Amount of damage done with each choke.
  62. gp_auto_choke <1|0> Enable/disable choking automatically with +pull command.
  63.  
  64. gp_screen_fade <1|0> Enables/disables screenfade when grabbing.
  65. gp_glow <1|0> Enables/disables glowing for grabbed objects.
  66.  
  67. gp_glow_r <50|0-255> Sets red amount for glow and screenfade.
  68. gp_glow_g <0|0-255> Sets green amount for glow and screenfade.
  69. gp_glow_b <0|0-255> Sets blue amount for glow and screenfade.
  70. gp_glow_a <0|0-255> Sets alpha for glow and screenfade.
  71.  
  72.  
  73. Notes:
  74. Make sure you place the grab_plus.txt file in addons\amxmodx\data\lang
  75.  
  76.  
  77. Credits:
  78. Thanks to vittu for contributing code (changed all engine/fun module stuff to fakemeta).
  79.  
  80. Thanks to all the coders who worked on the original Jedi Force Grab plugin for all their ideas:
  81. SpaceDude
  82. KCE
  83. KRoTaL
  84. BOB_SLAYER
  85. kosmo111
  86.  
  87.  
  88. Supported Languages:
  89. 1337 (100%) - Thanks to l337newb
  90. Brazilian Portuguese (100%) - Thanks to Arion
  91. Danish (100%) - Thanks to nellerbabz
  92. Dutch (100%) - Thanks to BlackMilk
  93. English (100%)
  94. Finnish (100%) - Thanks to Pro Patria Finland
  95. French (100%) - Thanks to connorr
  96. German (100%) - Thanks to SchlumPF*
  97. Russian (100%) - Thanks to `666
  98. Spanish (100%) - Hope these don't suck.
  99. Swedish (100%) - Thanks to Bend3r
  100.  
  101.  
  102. Change Log:
  103. Key (+ added | - removed | c changed | f fixed)
  104.  
  105. v1.2.3 (Nov 21, 2007)
  106. c: A few more small optimizations.
  107. f: Bloodstream for choke wasn't aligned with player.
  108. f: Bad message disconnect error when players were choked. ( stupid SVC_DAMAGE define )
  109.  
  110. v1.2.2 (Nov 16, 2007)
  111. c: A few small code optimizations.
  112.  
  113. v1.2.1 (Nov 12, 2007)
  114. f: Eliminated two run time warnings in the player prethink function.
  115.  
  116. v1.2 (Nov 06, 2007)
  117. +: Cvars gp_screen_fade and gp_glow to enable/disable these features.
  118. +: Cvar gp_glow_a controls to control alpha of screenfade and glow.
  119. +: Cvar gp_auto_choke to enable/disable choking automatically with +pull command.
  120. c: Removed dependency of engine and fun modules. Thanks to vittu for doing most of the work.
  121. c: Made cvar names more consistent by adding more underscores.
  122. f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7.x as well).
  123.  
  124. v1.1 (Oct 16, 2007)
  125. +: Grab a few types of entities other than players.
  126. +: Cvar gp_players_only.
  127.  
  128. v1.0 (Oct 13, 2007)
  129. !: Initial release
  130.  
  131. */
  132.  
  133. #include <amxmodx>
  134. #include <amxmisc>
  135. #include <fakemeta>
  136.  
  137. new const VERSION[ ] = "1.2.3"
  138. new const TRKCVAR[ ] = "grab_plus_version"
  139. #define ADMIN ADMIN_PLAYER
  140.  
  141. #define TSK_CHKE 50
  142.  
  143. #define SF_FADEOUT 0
  144.  
  145. new client_data[33][4]
  146. #define GRABBED 0
  147. #define GRABBER 1
  148. #define GRAB_LEN 2
  149. #define FLAGS 3
  150.  
  151. #define CDF_IN_PUSH (1<<0)
  152. #define CDF_IN_PULL (1<<1)
  153. #define CDF_NO_CHOKE (1<<2)
  154.  
  155. //Cvar Pointers
  156. new p_enabled, p_players_only
  157. new p_throw_force, p_min_dist, p_speed, p_grab_force
  158. new p_choke_time, p_choke_dmg, p_auto_choke
  159. new p_glow_r, p_glow_b, p_glow_g, p_glow_a
  160. new p_fade, p_glow
  161.  
  162. //Pseudo Constants
  163. new MAXPLAYERS
  164. new SVC_SCREENFADE, SVC_SCREENSHAKE, WTF_DAMAGE
  165.  
  166. public plugin_init( )
  167. {
  168. register_plugin( "Grab+", VERSION, "Ian Cammarata" )
  169. register_cvar( TRKCVAR, VERSION, FCVAR_SERVER )
  170. set_cvar_string( TRKCVAR, VERSION )
  171.  
  172. p_enabled = register_cvar( "gp_enabled", "1" )
  173. p_players_only = register_cvar( "gp_players_only", "0" )
  174.  
  175. p_min_dist = register_cvar ( "gp_min_dist", "90" )
  176. p_throw_force = register_cvar( "gp_throw_force", "1500" )
  177. p_grab_force = register_cvar( "gp_grab_force", "8" )
  178. p_speed = register_cvar( "gp_speed", "5" )
  179.  
  180. p_choke_time = register_cvar( "gp_choke_time", "1.5" )
  181. p_choke_dmg = register_cvar( "gp_choke_dmg", "5" )
  182. p_auto_choke = register_cvar( "gp_auto_choke", "1" )
  183.  
  184. p_glow_r = register_cvar( "gp_glow_r", "50" )
  185. p_glow_g = register_cvar( "gp_glow_g", "0" )
  186. p_glow_b = register_cvar( "gp_glow_b", "0" )
  187. p_glow_a = register_cvar( "gp_glow_a", "200" )
  188.  
  189. p_fade = register_cvar( "gp_screen_fade", "1" )
  190. p_glow = register_cvar( "gp_glow", "1" )
  191.  
  192. register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." )
  193. register_clcmd( "grab_toggle", "grab_toggle", ADMIN, "press once to grab and again to release" )
  194. register_clcmd( "+grab", "grab", ADMIN, "bind a key to +grab" )
  195. register_clcmd( "-grab", "unset_grabbed" )
  196.  
  197. register_clcmd( "+push", "push", ADMIN, "bind a key to +push" )
  198. register_clcmd( "-push", "push" )
  199. register_clcmd( "+pull", "pull", ADMIN, "bind a key to +pull" )
  200. register_clcmd( "-pull", "pull" )
  201. register_clcmd( "push", "push2" )
  202. register_clcmd( "pull", "pull2" )
  203.  
  204. register_clcmd( "drop" ,"throw" )
  205.  
  206. register_event( "DeathMsg", "DeathMsg", "a" )
  207.  
  208. register_forward( FM_PlayerPreThink, "fm_player_prethink" )
  209.  
  210. register_dictionary( "grab_plus.txt" )
  211.  
  212. MAXPLAYERS = get_maxplayers()
  213.  
  214. SVC_SCREENFADE = get_user_msgid( "ScreenFade" )
  215. SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" )
  216. WTF_DAMAGE = get_user_msgid( "Damage" )
  217. }
  218.  
  219. public plugin_precache( )
  220. {
  221. precache_sound( "player/PL_PAIN2.WAV" )
  222. }
  223.  
  224. public fm_player_prethink( id )
  225. {
  226. new target
  227. //Search for a target
  228. if ( client_data[id][GRABBED] == -1 )
  229. {
  230. new Float:orig[3], Float:ret[3]
  231. get_view_pos( id, orig )
  232. ret = vel_by_aim( id, 9999 )
  233.  
  234. ret[0] += orig[0]
  235. ret[1] += orig[1]
  236. ret[2] += orig[2]
  237.  
  238. target = traceline( orig, ret, id, ret )
  239.  
  240. if( 0 < target <= MAXPLAYERS )
  241. {
  242. if( is_grabbed( target, id ) ) return FMRES_IGNORED
  243. set_grabbed( id, target )
  244. }
  245. else if( !get_pcvar_num( p_players_only ) )
  246. {
  247. new movetype
  248. if( target && pev_valid( target ) )
  249. {
  250. movetype = pev( target, pev_movetype )
  251. if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) )
  252. return FMRES_IGNORED
  253. }
  254. else
  255. {
  256. target = 0
  257. new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 )
  258. while( !target && ent > 0 )
  259. {
  260. movetype = pev( ent, pev_movetype )
  261. if( ( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS )
  262. && ent != id )
  263. target = ent
  264. ent = engfunc( EngFunc_FindEntityInSphere, ent, ret, 12.0 )
  265. }
  266. }
  267. if( target )
  268. {
  269. if( is_grabbed( target, id ) ) return FMRES_IGNORED
  270. set_grabbed( id, target )
  271. }
  272. }
  273. }
  274.  
  275. target = client_data[id][GRABBED]
  276. //If they've grabbed something
  277. if( target > 0 )
  278. {
  279. if( !pev_valid( target ) || ( pev( target, pev_health ) < 1 && pev( target, pev_max_health ) ) )
  280. {
  281. unset_grabbed( id )
  282. return FMRES_IGNORED
  283. }
  284.  
  285. //Use key choke
  286. if( pev( id, pev_button ) & IN_USE )
  287. do_choke( id )
  288.  
  289. //Push and pull
  290. new cdf = client_data[id][FLAGS]
  291. if ( cdf & CDF_IN_PULL )
  292. do_pull( id )
  293. else if ( cdf & CDF_IN_PUSH )
  294. do_push( id )
  295.  
  296. if( target > MAXPLAYERS ) grab_think( id )
  297. }
  298.  
  299. //If they're grabbed
  300. target = client_data[id][GRABBER]
  301. if( target > 0 ) grab_think( target )
  302.  
  303. return FMRES_IGNORED
  304. }
  305.  
  306. public grab_think( id ) //id of the grabber
  307. {
  308. new target = client_data[id][GRABBED]
  309.  
  310. //Keep grabbed clients from sticking to ladders
  311. if( pev( target, pev_movetype ) == MOVETYPE_FLY && !(pev( target, pev_button ) & IN_JUMP ) ) client_cmd( target, "+jump;wait;-jump" )
  312.  
  313. //Move targeted client
  314. new Float:tmpvec[3], Float:tmpvec2[3], Float:torig[3], Float:tvel[3]
  315.  
  316. get_view_pos( id, tmpvec )
  317.  
  318. tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] )
  319.  
  320. torig = get_target_origin_f( target )
  321.  
  322. new force = get_pcvar_num( p_grab_force )
  323.  
  324. tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force
  325. tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force
  326. tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force
  327.  
  328. set_pev( target, pev_velocity, tvel )
  329. }
  330.  
  331. stock Float:get_target_origin_f( id )
  332. {
  333. new Float:orig[3]
  334. pev( id, pev_origin, orig )
  335.  
  336. //If grabbed is not a player, move origin to center
  337. if( id > MAXPLAYERS )
  338. {
  339. new Float:mins[3], Float:maxs[3]
  340. pev( id, pev_mins, mins )
  341. pev( id, pev_maxs, maxs )
  342.  
  343. if( !mins[2] ) orig[2] += maxs[2] / 2
  344. }
  345.  
  346. return orig
  347. }
  348.  
  349. public grab_toggle( id, level, cid )
  350. {
  351. if( !client_data[id][GRABBED] ) grab( id, level, cid )
  352. else unset_grabbed( id )
  353.  
  354. return PLUGIN_HANDLED
  355. }
  356.  
  357. public grab( id, level, cid )
  358. {
  359. if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED
  360.  
  361. if ( !client_data[id][GRABBED] ) client_data[id][GRABBED] = -1
  362. screenfade_in( id )
  363.  
  364. return PLUGIN_HANDLED
  365. }
  366.  
  367. public screenfade_in( id )
  368. {
  369. if( get_pcvar_num( p_fade ) )
  370. {
  371. message_begin( MSG_ONE, SVC_SCREENFADE, _, id )
  372. write_short( 10000 ) //duration
  373. write_short( 0 ) //hold
  374. write_short( SF_FADE_IN + SF_FADE_ONLYONE ) //flags
  375. write_byte( get_pcvar_num( p_glow_r ) ) //r
  376. write_byte( get_pcvar_num( p_glow_g ) ) //g
  377. write_byte( get_pcvar_num( p_glow_b ) ) //b
  378. write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a
  379. message_end( )
  380. }
  381. }
  382.  
  383. public throw( id )
  384. {
  385. new target = client_data[id][GRABBED]
  386. if( target > 0 )
  387. {
  388. set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) )
  389. unset_grabbed( id )
  390. return PLUGIN_HANDLED
  391. }
  392.  
  393. return PLUGIN_CONTINUE
  394. }
  395.  
  396. public unset_grabbed( id )
  397. {
  398. new target = client_data[id][GRABBED]
  399. if( target > 0 && pev_valid( target ) )
  400. {
  401. set_pev( target, pev_renderfx, kRenderFxNone )
  402. set_pev( target, pev_rendercolor, {255.0, 255.0, 255.0} )
  403. set_pev( target, pev_rendermode, kRenderNormal )
  404. set_pev( target, pev_renderamt, 16.0 )
  405.  
  406. if( 0 < target <= MAXPLAYERS )
  407. client_data[target][GRABBER] = 0
  408. }
  409. client_data[id][GRABBED] = 0
  410.  
  411. if( get_pcvar_num( p_fade ) )
  412. {
  413. message_begin( MSG_ONE, SVC_SCREENFADE, _, id )
  414. write_short( 10000 ) //duration
  415. write_short( 0 ) //hold
  416. write_short( SF_FADEOUT ) //flags
  417. write_byte( get_pcvar_num( p_glow_r ) ) //r
  418. write_byte( get_pcvar_num( p_glow_g ) ) //g
  419. write_byte( get_pcvar_num( p_glow_b ) ) //b
  420. write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a
  421. message_end( )
  422. }
  423. }
  424.  
  425. //Grabs onto someone
  426. public set_grabbed( id, target )
  427. {
  428. if( get_pcvar_num( p_glow ) )
  429. {
  430. new Float:color[3]
  431. color[0] = get_pcvar_float( p_glow_r )
  432. color[1] = get_pcvar_float( p_glow_g )
  433. color[2] = get_pcvar_float( p_glow_b )
  434. set_pev( target, pev_renderfx, kRenderFxGlowShell )
  435. set_pev( target, pev_rendercolor, color )
  436. set_pev( target, pev_rendermode, kRenderTransColor )
  437. set_pev( target, pev_renderamt, get_pcvar_float( p_glow_a ) )
  438. }
  439.  
  440. if( 0 < target <= MAXPLAYERS )
  441. client_data[target][GRABBER] = id
  442. client_data[id][FLAGS] = 0
  443. client_data[id][GRABBED] = target
  444. new Float:torig[3], Float:orig[3]
  445. pev( target, pev_origin, torig )
  446. pev( id, pev_origin, orig )
  447. client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) )
  448. if( client_data[id][GRAB_LEN] < get_pcvar_num( p_min_dist ) ) client_data[id][GRAB_LEN] = get_pcvar_num( p_min_dist )
  449. }
  450.  
  451. public push( id )
  452. {
  453. client_data[id][FLAGS] ^= CDF_IN_PUSH
  454. return PLUGIN_HANDLED
  455. }
  456.  
  457. public pull( id )
  458. {
  459. client_data[id][FLAGS] ^= CDF_IN_PULL
  460. return PLUGIN_HANDLED
  461. }
  462.  
  463. public push2( id )
  464. {
  465. if( client_data[id][GRABBED] > 0 )
  466. {
  467. do_push( id )
  468. return PLUGIN_HANDLED
  469. }
  470. return PLUGIN_CONTINUE
  471. }
  472.  
  473. public pull2( id )
  474. {
  475. if( client_data[id][GRABBED] > 0 )
  476. {
  477. do_pull( id )
  478. return PLUGIN_HANDLED
  479. }
  480. return PLUGIN_CONTINUE
  481. }
  482.  
  483. public do_push( id )
  484. if( client_data[id][GRAB_LEN] < 9999 )
  485. client_data[id][GRAB_LEN] += get_pcvar_num( p_speed )
  486.  
  487. public do_pull( id )
  488. {
  489. new mindist = get_pcvar_num( p_min_dist )
  490. new len = client_data[id][GRAB_LEN]
  491.  
  492. if( len > mindist )
  493. {
  494. len -= get_pcvar_num( p_speed )
  495. if( len < mindist ) len = mindist
  496. client_data[id][GRAB_LEN] = len
  497. }
  498. else if( get_pcvar_num( p_auto_choke ) )
  499. do_choke( id )
  500. }
  501.  
  502. public do_choke( id )
  503. {
  504. new target = client_data[id][GRABBED]
  505. if( client_data[id][FLAGS] & CDF_NO_CHOKE || id == target || target > MAXPLAYERS) return
  506.  
  507. new dmg = get_pcvar_num( p_choke_dmg )
  508. new vec[3]
  509. FVecIVec( get_target_origin_f( target ), vec )
  510.  
  511. message_begin( MSG_ONE, SVC_SCREENSHAKE, _, target )
  512. write_short( 999999 ) //amount
  513. write_short( 9999 ) //duration
  514. write_short( 999 ) //frequency
  515. message_end( )
  516.  
  517. message_begin( MSG_ONE, SVC_SCREENFADE, _, target )
  518. write_short( 9999 ) //duration
  519. write_short( 100 ) //hold
  520. write_short( SF_FADE_MODULATE ) //flags
  521. write_byte( get_pcvar_num( p_glow_r ) ) //r
  522. write_byte( get_pcvar_num( p_glow_g ) ) //g
  523. write_byte( get_pcvar_num( p_glow_b ) ) //b
  524. write_byte( 200 ) //a
  525. message_end( )
  526.  
  527. message_begin( MSG_ONE, WTF_DAMAGE, _, target )
  528. write_byte( 0 ) //damage armor
  529. write_byte( dmg ) //damage health
  530. write_long( DMG_CRUSH ) //damage type
  531. write_coord( vec[0] ) //origin[x]
  532. write_coord( vec[1] ) //origin[y]
  533. write_coord( vec[2] ) //origin[z]
  534. message_end( )
  535.  
  536. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  537. write_byte( TE_BLOODSTREAM )
  538. write_coord( vec[0] ) //pos.x
  539. write_coord( vec[1] ) //pos.y
  540. write_coord( vec[2] + 15 ) //pos.z
  541. write_coord( random_num( 0, 255 ) ) //vec.x
  542. write_coord( random_num( 0, 255 ) ) //vec.y
  543. write_coord( random_num( 0, 255 ) ) //vec.z
  544. write_byte( 70 ) //col index
  545. write_byte( random_num( 50, 250 ) ) //speed
  546. message_end( )
  547.  
  548. new health = pev( target, pev_health ) - dmg
  549. set_pev( target, pev_health, float( health ) )
  550. if( health < 1 ) dllfunc( DLLFunc_ClientKill, target )
  551.  
  552. emit_sound( target, CHAN_BODY, "player/PL_PAIN2.WAV", VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  553.  
  554. client_data[id][FLAGS] ^= CDF_NO_CHOKE
  555. set_task( get_pcvar_float( p_choke_time ), "clear_no_choke", TSK_CHKE + id )
  556. }
  557.  
  558. public clear_no_choke( tskid )
  559. {
  560. new id = tskid - TSK_CHKE
  561. client_data[id][FLAGS] ^= CDF_NO_CHOKE
  562. }
  563.  
  564. //Grabs the client and teleports them to the admin
  565. public force_grab(id, level, cid)
  566. {
  567. if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED
  568.  
  569. new arg[33]
  570. read_argv( 1, arg, 32 )
  571.  
  572. new targetid = cmd_target( id, arg, 1 )
  573.  
  574. if( is_grabbed( targetid, id ) ) return PLUGIN_HANDLED
  575. if( !is_user_alive( targetid ) )
  576. {
  577. client_print( id, print_console, "[AMXX] %L", id, "COULDNT" )
  578. return PLUGIN_HANDLED
  579. }
  580.  
  581. //Safe to tp target to aim spot?
  582. new Float:tmpvec[3], Float:orig[3], Float:torig[3], Float:trace_ret[3]
  583. new bool:safe = false, i
  584.  
  585. get_view_pos( id, orig )
  586. tmpvec = vel_by_aim( id, get_pcvar_num( p_min_dist ) )
  587.  
  588. for( new j = 1; j < 11 && !safe; j++ )
  589. {
  590. torig[0] = orig[0] + tmpvec[i] * j
  591. torig[1] = orig[1] + tmpvec[i] * j
  592. torig[2] = orig[2] + tmpvec[i] * j
  593.  
  594. traceline( tmpvec, torig, id, trace_ret )
  595.  
  596. if( get_distance_f( trace_ret, torig ) ) break
  597.  
  598. engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
  599. if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) )
  600. safe = true
  601. }
  602.  
  603. //Still not safe? Then find another safe spot somewhere around the grabber
  604. pev( id, pev_origin, orig )
  605. new try[3]
  606. orig[2] += 2
  607. while( try[2] < 3 && !safe )
  608. {
  609. for( i = 0; i < 3; i++ )
  610. switch( try[i] )
  611. {
  612. case 0 : torig[i] = orig[i] + ( i == 2 ? 80 : 40 )
  613. case 1 : torig[i] = orig[i]
  614. case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )
  615. }
  616.  
  617. traceline( tmpvec, torig, id, trace_ret )
  618.  
  619. engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
  620. if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen )
  621. && !get_distance_f( trace_ret, torig ) ) safe = true
  622.  
  623. try[0]++
  624. if( try[0] == 3 )
  625. {
  626. try[0] = 0
  627. try[1]++
  628. if( try[1] == 3 )
  629. {
  630. try[1] = 0
  631. try[2]++
  632. }
  633. }
  634. }
  635.  
  636. if( safe )
  637. {
  638. set_pev( targetid, pev_origin, torig )
  639. set_grabbed( id, targetid )
  640. screenfade_in( id )
  641. }
  642. else client_print( id, print_chat, "[AMXX] %L", id, "COULDNT" )
  643.  
  644. return PLUGIN_HANDLED
  645. }
  646.  
  647. public is_grabbed( target, grabber )
  648. {
  649. for( new i = 1; i <= MAXPLAYERS; i++ )
  650. if( client_data[i][GRABBED] == target )
  651. {
  652. client_print( grabber, print_chat, "[AMXX] %L", grabber, "ALREADY" )
  653. unset_grabbed( grabber )
  654. return true
  655. }
  656. return false
  657. }
  658.  
  659. public DeathMsg( )
  660. kill_grab( read_data( 2 ) )
  661.  
  662. public client_disconnect( id )
  663. {
  664. kill_grab( id )
  665. return PLUGIN_CONTINUE
  666. }
  667.  
  668. public kill_grab( id )
  669. {
  670. //If given client has grabbed, or has a grabber, unset it
  671. if( client_data[id][GRABBED] )
  672. unset_grabbed( id )
  673. else if( client_data[id][GRABBER] )
  674. unset_grabbed( client_data[id][GRABBER] )
  675. }
  676.  
  677. stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] )
  678. {
  679. engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 )
  680. get_tr2( 0, TR_vecEndPos, vHitPos )
  681. return get_tr2( 0, TR_pHit )
  682. }
  683.  
  684. stock get_view_pos( const id, Float:vViewPos[3] )
  685. {
  686. new Float:vOfs[3]
  687. pev( id, pev_origin, vViewPos )
  688. pev( id, pev_view_ofs, vOfs )
  689.  
  690. vViewPos[0] += vOfs[0]
  691. vViewPos[1] += vOfs[1]
  692. vViewPos[2] += vOfs[2]
  693. }
  694.  
  695. stock Float:vel_by_aim( id, speed = 1 )
  696. {
  697. new Float:v1[3], Float:vBlah[3]
  698. pev( id, pev_v_angle, v1 )
  699. engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah )
  700.  
  701. v1[0] *= speed
  702. v1[1] *= speed
  703. v1[2] *= speed
  704.  
  705. return v1
  706. }
  707.  

_________________
http://www.subbass.hu

Admin Rendszer v1.3
http://csgoskins.net/?rid=76561198147396400


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Grab minden játékosnak
HozzászólásElküldve: 2015.03.30. 10:52 
Offline
Jómunkásember
Avatar

Csatlakozott: 2013.12.15. 19:13
Hozzászólások: 419
Megköszönt másnak: 212 alkalommal
Megköszönték neki: 13 alkalommal
Hali, vagy a configs mappa/cmdaccess.ini -ben megkeresed a +grab stb dolgokat es a pl "c"-t atirod erre: ""
ha nem mukodne akkor erre: "z"

_________________
2021.03.01-re rem. készen lesz az új SNIPER szerverem RENGETEG egyedi dologgal megfűszerezve.
De nem lövök le előre semmit :)

Ők köszönték meg ZiT3K nek ezt a hozzászólást: parodyshelf (2015.03.30. 16:55)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Grab minden játékosnak
HozzászólásElküldve: 2015.03.30. 16:57 
Offline
Jómunkásember
Avatar

Csatlakozott: 2014.04.14. 16:23
Hozzászólások: 475
Megköszönt másnak: 97 alkalommal
Megköszönték neki: 4 alkalommal
Lostlegend a te módszered nem vált be,de ZiT3K a tiéd viszont működik.Köszönöm,ment a gomb

_________________
Kép
Kép


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  [ 4 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 10 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