Resolved [ZE] MG Grab problem compiling

Coding Help/Re-API Supported
Post Reply
Mystic Viper
Senior Member
Senior Member
Romania
Posts: 104
Joined: 11 Months Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

[ZE] MG Grab problem compiling

#1

Post by Mystic Viper » 4 Months Ago

ze_mg_grab.sma
(19.87 KiB) Downloaded 16 times
ze_mg_grab.sma
(19.87 KiB) Downloaded 16 times

I got more errors when i try to compile it . Please fix it for me :)

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#2

Post by Mark » 4 Months Ago

Mystic Viper wrote:
4 Months Ago
ze_mg_grab.sma


I got more errors when i try to compile it . Please fix it for me :)
Need to post errors if you want help to fix it?

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#3

Post by Raheem » 4 Months Ago

Our Mod using AMXMODX v1.9, dhudmessages already included in this AMXMODX so no need again to write: #include <dhudmessage> so this should be removed.

Also the usage of: Is wrong, it should match parameters that defined in the function header. So it should be: Also good to change: client_disconnect to client_disconnected.

Final thing is that the encoding of this file is wrong, you should make it:
  • screen.png
So final code, i uploaded file: Next time maybe to post more information about problem so anyone can help as mark said.
You don't know? Learn and you will know.

Mystic Viper
Senior Member
Senior Member
Romania
Posts: 104
Joined: 11 Months Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

#4

Post by Mystic Viper » 4 Months Ago

Ok i m sorry and thank u for help. Next time i will post more information about what thing has problems

Mystic Viper
Senior Member
Senior Member
Romania
Posts: 104
Joined: 11 Months Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

#5

Post by Mystic Viper » 4 Months Ago

Problem with compiling:

ze_mg_grab.sma(1) : error 10: invalid function or declaration
ze_mg_grab.sma(436) : warning 217: loose indentation
ze_mg_grab.sma(437) : warning 217: loose indentation
ze_mg_grab.sma(438) : warning 217: loose indentation
ze_mg_grab.sma(453) : warning 217: loose indentation
ze_mg_grab.sma(454) : warning 217: loose indentation
ze_mg_grab.sma(456) : warning 217: loose indentation

Mystic Viper
Senior Member
Senior Member
Romania
Posts: 104
Joined: 11 Months Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

#6

Post by Mystic Viper » 4 Months Ago

  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <fun>
  5. #include <hamsandwich>
  6.  
  7. #pragma tabsize 0
  8.  
  9. #define PLUGIN      "[ZE] MG Grab"
  10. #define VERSION     "2.5"
  11. #define AUTHOR      "LuXo KING Gaming + Legolas"
  12.  
  13. #define ADMIN       ADMIN_LEVEL_F
  14. #define RESON_KICK  "Kicked by Admin"
  15. #define GRAB_MENU
  16.  
  17. #define TSK_CHKE 50
  18.  
  19. #define SF_FADEOUT 0
  20.  
  21. new client_data[33][4]
  22. #define GRABBED  0
  23. #define GRABBER  1
  24. #define GRAB_LEN 2
  25. #define FLAGS    3
  26.  
  27. #define CDF_IN_PUSH   (1<<0)
  28. #define CDF_IN_PULL   (1<<1)
  29. #define CDF_NO_CHOKE  (1<<2)
  30.  
  31. enum
  32. {
  33.     r = 0.0,
  34.     g = 255.0,
  35.     b = 255.0,
  36.  
  37.     a = 200.0
  38. };
  39.  
  40. new const Menu[][] =
  41. {
  42.     "",
  43.     "MENU_1",
  44.     "MENU_2",
  45.     "MENU_3",
  46.     "MENU_4",
  47.     "MENU_5",
  48.     "MENU_6"
  49. };
  50.  
  51. new p_enabled, p_players_only
  52. new p_throw_force, p_min_dist, p_speed, p_grab_force
  53. new p_choke_time, p_choke_dmg, p_auto_choke
  54. new p_glow
  55. new speed_off[33]
  56. new g_short
  57. new model_gibs
  58. new MAXPLAYERS
  59. new SVC_SCREENSHAKE, SVC_SCREENFADE, WTF_DAMAGE
  60.  
  61. public plugin_init( )
  62. {
  63.     register_plugin(PLUGIN, VERSION, AUTHOR)
  64.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
  65.     RegisterHam(Ham_Spawn, "player", "SpawnPlayer")
  66.  
  67.     p_enabled = register_cvar( "gp_enabled", "1" )
  68.     p_players_only = register_cvar( "gp_players_only", "0" )
  69.    
  70.     p_min_dist = register_cvar ( "gp_min_dist", "90" )
  71.     p_throw_force = register_cvar( "gp_throw_force", "1500" )
  72.     p_grab_force = register_cvar( "gp_grab_force", "8" )
  73.     p_speed = register_cvar( "gp_speed", "5" )
  74.    
  75.     p_choke_time = register_cvar( "gp_choke_time", "1.5" )
  76.     p_choke_dmg = register_cvar( "gp_choke_dmg", "5" )
  77.     p_auto_choke = register_cvar( "gp_auto_choke", "1" )
  78.    
  79.     p_glow = register_cvar( "gp_glow", "1" )
  80.    
  81.     register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." )
  82.     register_clcmd( "+grab", "grab", ADMIN, "bind a key to +grab" )
  83.     register_clcmd( "-grab", "unset_grabbed" )
  84.    
  85.     register_clcmd( "+push", "push", ADMIN, "bind a key to +push" )
  86.     register_clcmd( "-push", "push" )
  87.     register_clcmd( "+pull", "pull", ADMIN, "bind a key to +pull" )
  88.     register_clcmd( "-pull", "pull" )
  89.     register_clcmd( "push", "push2" )
  90.     register_clcmd( "pull", "pull2" )
  91.    
  92.     register_clcmd( "drop" ,"throw" )
  93.    
  94.     register_event( "DeathMsg", "DeathMsg", "a" )
  95.    
  96.     register_forward( FM_PlayerPreThink, "fm_player_prethink" )
  97.    
  98.     register_dictionary( "grab_plus.txt" )
  99.    
  100.     MAXPLAYERS = get_maxplayers()
  101.    
  102.     SVC_SCREENFADE = get_user_msgid( "ScreenFade" )
  103.     SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" )
  104.     WTF_DAMAGE = get_user_msgid( "Damage" )
  105.  
  106.     register_dictionary("mg_grab.txt");
  107. }
  108.  
  109. public plugin_precache( )
  110. {
  111.     precache_sound("player/PL_PAIN2.WAV")
  112.     precache_sound("MG_grab/grab_victim_xa.wav")
  113.     precache_sound("MG_grab/grab_id_mine.wav")
  114.     precache_sound("MG_grab/grab_weapon.wav")
  115.     precache_sound("MG_grab/grab_bury.wav")
  116.     g_short = precache_model("sprites/MG_grab/energy_grab.spr");
  117.     model_gibs = precache_model("models/rockgibs.mdl")
  118. }
  119.  
  120. public fm_player_prethink( id )
  121. {
  122.     new target
  123.     //Search for a target
  124.     if ( client_data[id][GRABBED] == -1 )
  125.     {
  126.         new Float:orig[3], Float:ret[3]
  127.         get_view_pos( id, orig )
  128.         ret = vel_by_aim( id, 9999 )
  129.        
  130.         ret[0] += orig[0]
  131.         ret[1] += orig[1]
  132.         ret[2] += orig[2]
  133.        
  134.         target = traceline( orig, ret, id, ret )
  135.        
  136.         if( 0 < target <= MAXPLAYERS )
  137.         {
  138.             if( is_grabbed( target, id ) ) return FMRES_IGNORED
  139.             set_grabbed( id, target )
  140.         }
  141.         else if( !get_pcvar_num( p_players_only ) )
  142.         {
  143.             new movetype
  144.             if( target && pev_valid( target ) )
  145.             {
  146.                 movetype = pev( target, pev_movetype )
  147.                 if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) )
  148.                     return FMRES_IGNORED
  149.             }
  150.             else
  151.             {
  152.                 target = 0
  153.                 new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 )
  154.                 while( !target && ent > 0 )
  155.                 {
  156.                     movetype = pev( ent, pev_movetype )
  157.                     if( ( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS )
  158.                             && ent != id  )
  159.                         target = ent
  160.                     ent = engfunc( EngFunc_FindEntityInSphere, ent, ret, 12.0 )
  161.                 }
  162.             }
  163.             if( target )
  164.             {
  165.                 if( is_grabbed( target, id ) ) return FMRES_IGNORED
  166.                 set_grabbed( id, target )
  167.             }
  168.         }
  169.     }
  170.    
  171.     target = client_data[id][GRABBED]
  172.     //If they've grabbed something
  173.     if( target > 0 )
  174.     {
  175.         if( !pev_valid( target ) || ( pev( target, pev_health ) < 1 && pev( target, pev_max_health ) ) )
  176.         {
  177.             unset_grabbed( id )
  178.             return FMRES_IGNORED
  179.         }
  180.          
  181.         //Use key choke
  182.         if( pev( id, pev_button ) & IN_USE )
  183.             do_choke( id )
  184.        
  185.         //Push and pull
  186.         new cdf = client_data[id][FLAGS]
  187.         if ( cdf & CDF_IN_PULL )
  188.             do_pull( id )
  189.         else if ( cdf & CDF_IN_PUSH )
  190.             do_push( id )
  191.        
  192.         if( target > MAXPLAYERS ) grab_think( id )
  193.     }
  194.    
  195.     //If they're grabbed
  196.     target = client_data[id][GRABBER]
  197.     if( target > 0 ) grab_think( target )
  198.    
  199.     return FMRES_IGNORED
  200. }
  201.  
  202. public grab_think( id ) //id of the grabber
  203. {
  204.     new target = client_data[id][GRABBED]
  205.    
  206.     //Keep grabbed clients from sticking to ladders
  207.     if( pev( target, pev_movetype ) == MOVETYPE_FLY && !(pev( target, pev_button ) & IN_JUMP ) ) client_cmd( target, "+jump;wait;-jump" )
  208.    
  209.     //Move targeted client
  210.     new Float:tmpvec[3], Float:tmpvec2[3], Float:torig[3], Float:tvel[3]
  211.    
  212.     get_view_pos( id, tmpvec )
  213.    
  214.     tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] )
  215.    
  216.     torig = get_target_origin_f( target )
  217.    
  218.     new force = get_pcvar_num( p_grab_force )
  219.    
  220.     tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force
  221.     tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force
  222.     tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force
  223.    
  224.     set_pev( target, pev_velocity, tvel )
  225. }
  226.  
  227. stock Float:get_target_origin_f( id )
  228. {
  229.     new Float:orig[3]
  230.     pev( id, pev_origin, orig )
  231.    
  232.     //If grabbed is not a player, move origin to center
  233.     if( id > MAXPLAYERS )
  234.     {
  235.         new Float:mins[3], Float:maxs[3]
  236.         pev( id, pev_mins, mins )
  237.         pev( id, pev_maxs, maxs )
  238.        
  239.         if( !mins[2] ) orig[2] += maxs[2] / 2
  240.     }
  241.    
  242.     return orig
  243. }
  244.  
  245. public grab( id, level, cid )
  246. {
  247.     if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED
  248.    
  249.     if ( !client_data[id][GRABBED] ) client_data[id][GRABBED] = -1
  250.    
  251.     return PLUGIN_HANDLED
  252. }
  253.  
  254. public SpawnPlayer(id)
  255.     speed_off[id] = false
  256.  
  257. public CurrentWeapon(id)
  258. {
  259.     if(speed_off[id])
  260.         set_pev(id, pev_maxspeed, 00000.0)
  261. }
  262.  
  263. public grab_menu(id)
  264. {
  265.     new name[32]
  266.     new target = client_data[id][GRABBED]
  267.     if(target && is_user_alive(target))
  268.     {
  269.         get_user_name(target, name, charsmax(name))
  270.     }
  271.     new Item[512], Str[10], menu;
  272.  
  273.     formatex(Item, charsmax(Item), "%L", id, "MENU_NAME", name);
  274.     menu = menu_create(Item, "menu_handler")
  275.  
  276.     for(new i = 1; i <= charsmax(Menu); i++)
  277.     {
  278.         num_to_str(i, Str, charsmax(Str));
  279.  
  280.         formatex(Item, charsmax(Item), "%L", id, Menu[i]);
  281.         menu_additem(menu, Item, Str, 0);
  282.     }
  283.     formatex(Item, charsmax(Item), "%L", id, "MENU_EXIT");
  284.     menu_setprop(menu, MPROP_EXITNAME, Item);
  285.  
  286.     menu_display(id, menu, 0);
  287.  
  288.     return PLUGIN_HANDLED;
  289. }
  290.      
  291. public menu_handler(id, menu, item)
  292. {
  293.     if(item == MENU_EXIT)
  294.     {
  295.         menu_destroy(menu)
  296.         return PLUGIN_HANDLED
  297.     }
  298.          
  299.     new data[6], iName[64], access, callback
  300.     menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)
  301.          
  302.     new key = str_to_num(data)
  303.     new target = client_data[id][GRABBED]
  304.          
  305.     switch(key)
  306.     {
  307.         case 1:
  308.         {
  309.             if(target && is_user_alive(target))
  310.             {
  311.                 grab_eff_zd(id, target)
  312.                 server_cmd("kick #%d ^"%s^"", get_user_userid(target), RESON_KICK)
  313.             }
  314.         }
  315.         case 2:
  316.         {
  317.             if(target && is_user_alive(target))
  318.             {
  319.                 user_kill(target)
  320.             }
  321.         }
  322.         case 3:
  323.         {
  324.             if(target && is_user_alive(target))
  325.             {
  326.                 fm_strip_user_weapons(target)
  327.                 fm_give_item(target, "weapon_knife")               
  328.             }
  329.         }
  330.         case 4:
  331.         {
  332.             if(target && is_user_alive(target))
  333.             {
  334.                 Bury(id, target)
  335.             }
  336.         }
  337.         case 5:
  338.         {
  339.             if(target && is_user_alive(target))
  340.             {
  341.                 Bury_off(id, target)
  342.             }
  343.         }
  344.         case 6:
  345.         {
  346.             if(target && is_user_alive(target))
  347.             {
  348.                 pull(id)
  349.             }
  350.         }
  351.         case 7:
  352.         {
  353.             if(target && is_user_alive(target))
  354.             {
  355.                 set_pev(target, pev_punchangle, { 400.0, 999.0, 400.0 })
  356.             }
  357.         }
  358.     }
  359.     return PLUGIN_HANDLED
  360. }
  361.  
  362. public throw( id )
  363. {
  364.     new target = client_data[id][GRABBED]
  365.     if( target > 0 )
  366.     {
  367.         set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) )
  368.         unset_grabbed( id )
  369.         return PLUGIN_HANDLED
  370.     }
  371.  
  372.     return PLUGIN_CONTINUE
  373. }
  374.  
  375. public unset_grabbed( id )
  376. {
  377.     new target = client_data[id][GRABBED]
  378.     if( target > 0 && pev_valid( target ) )
  379.     {
  380.         set_pev( target, pev_renderfx, kRenderFxNone )
  381.         set_pev( target, pev_rendercolor, {255.0, 255.0, 255.0} )
  382.         set_pev( target, pev_rendermode, kRenderNormal )
  383.         set_pev( target, pev_renderamt, 16.0 )
  384.        
  385.         if( 0 < target <= MAXPLAYERS )
  386.             client_data[target][GRABBER] = 0
  387.     }
  388.     show_menu(id, 0, "^n", 1)
  389.     client_data[id][GRABBED] = 0
  390. }
  391.  
  392. //Grabs onto someone
  393. public set_grabbed( id, target )
  394. {
  395.     if( get_pcvar_num( p_glow ) )
  396.     {
  397.         set_pev( target, pev_renderfx, kRenderFxGlowShell )
  398.         set_pev( target, pev_rendercolor, {r, g, b})
  399.         set_pev( target, pev_rendermode, kRenderTransColor )
  400.         set_pev( target, pev_renderamt, a )
  401.     }
  402.    
  403.     if( 0 < target <= MAXPLAYERS )
  404.         client_data[target][GRABBER] = id
  405.     client_data[id][FLAGS] = 0
  406.     client_data[id][GRABBED] = target
  407.     new name[33], name2[33]
  408.     get_user_name(id, name, 32)
  409.     get_user_name(target, name2, 32)
  410.     if(get_user_team(target)==1 || get_user_team(target)==2)
  411.     {      
  412.         client_cmd(target, "spk MG_grab/grab_victim_xa.wav")
  413.         client_cmd(id, "spk MG_grab/grab_id_mine.wav")
  414.         ChatColor(target, "%L", target, "CHAT_1", name)  
  415.         ChatColor(id, "%L", id, "CHAT_2", name2)
  416.         grab_eff(target)
  417.         #if defined GRAB_MENU
  418.         grab_menu(id)
  419.         #endif
  420.     }
  421.     else
  422.     {
  423.         ChatColor(id, "%L", id, "CHAT_3")
  424.         client_cmd(0, "spk MG_grab/grab_weapon.wav")
  425.     }
  426.     new Float:torig[3], Float:orig[3]
  427.     pev( target, pev_origin, torig )
  428.     pev( id, pev_origin, orig )
  429.     client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) )
  430.     if( client_data[id][GRAB_LEN] < get_pcvar_num( p_min_dist ) ) client_data[id][GRAB_LEN] = get_pcvar_num( p_min_dist )
  431. }
  432.  
  433. public Bury(id, target)
  434. {
  435.     ChatColor(id, "%L", id, "CHAT_4")
  436.     set_dhudmessage(255, 0, 0, -1.0, 0.20, 0, 0.1, 3.0, 0.1, 2.0)
  437.     show_dhudmessage(id, "BURIED")
  438.     client_cmd(id, "spk MG_grab/grab_bury.wav")
  439.     grab_eff_zd(id, target)
  440.     if(is_user_alive(target))
  441.         {
  442.         new origin[3]
  443.         get_user_origin(target, origin)
  444.         origin[2] -= 30
  445.         set_user_origin(target, origin)
  446.     }
  447. }
  448.  
  449. public Bury_off(id, target)
  450. {
  451.     ChatColor(id, "%L", id, "CHAT_5")
  452.    
  453.     set_dhudmessage(255, 0, 0, -1.0, 0.20, 0, 0.1, 3.0, 0.1, 2.0)
  454.     show_dhudmessage(target, "UNBURIED")
  455.    
  456.     if(is_user_alive(target))
  457.         {
  458.         new origin[3]
  459.         get_user_origin(target, origin)
  460.         origin[2] += 30
  461.         set_user_origin(target, origin)
  462.     }
  463. }  
  464.  
  465. public grab_eff(target)
  466. {
  467.     new origin[3]
  468.    
  469.     get_user_origin(target,origin)
  470.    
  471.     message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},target)
  472.     write_byte(TE_SPRITETRAIL) //Спрайт захвата
  473.     write_coord(origin[0])
  474.     write_coord(origin[1])
  475.     write_coord(origin[2]+20)
  476.     write_coord(origin[0])
  477.     write_coord(origin[1])
  478.     write_coord(origin[2]+80)
  479.     write_short(g_short)
  480.     write_byte(20)
  481.     write_byte(20)
  482.     write_byte(4)
  483.     write_byte(20)
  484.     write_byte(10)
  485.     message_end()
  486. }
  487.  
  488. public grab_eff_zd(id, target)
  489. {
  490.     new origin[3]
  491.     get_user_origin(id, origin, 3)
  492.  
  493.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  494.     write_byte(TE_BREAKMODEL); // TE_
  495.     write_coord(origin[0]); // X
  496.     write_coord(origin[1]); // Y
  497.     write_coord(origin[2] + 24); // Z
  498.     write_coord(16); // size X
  499.     write_coord(16); // size Y
  500.     write_coord(16); // size Z
  501.     write_coord(random_num(-50,50)); // velocity X
  502.     write_coord(random_num(-50,50)); // velocity Y
  503.     write_coord(25); // velocity Z
  504.     write_byte(10); // random velocity
  505.     write_short(model_gibs); // sprite
  506.     write_byte(9); // count
  507.     write_byte(20); // life
  508.     write_byte(0x08); // flags
  509.     message_end();    
  510. }
  511.    
  512. public push(id)
  513. {
  514.     client_data[id][FLAGS] ^= CDF_IN_PUSH
  515.     return PLUGIN_HANDLED
  516. }
  517.  
  518. public pull(id)
  519. {
  520.     ChatColor(id, "%L", id, "CHAT_6")
  521.     client_data[id][FLAGS] ^= CDF_IN_PULL
  522.     return PLUGIN_HANDLED
  523. }
  524.  
  525. public push2( id )
  526. {
  527.     if( client_data[id][GRABBED] > 0 )
  528.     {
  529.         do_push( id )
  530.         return PLUGIN_HANDLED
  531.     }
  532.     return PLUGIN_CONTINUE
  533. }
  534.  
  535. public pull2( id )
  536. {
  537.     if( client_data[id][GRABBED] > 0 )
  538.     {
  539.         do_pull( id )
  540.         return PLUGIN_HANDLED
  541.     }
  542.     return PLUGIN_CONTINUE
  543. }
  544.  
  545. public do_push( id )
  546.     if( client_data[id][GRAB_LEN] < 9999 )
  547.         client_data[id][GRAB_LEN] += get_pcvar_num( p_speed )
  548.  
  549. public do_pull( id )
  550. {
  551.     new mindist = get_pcvar_num( p_min_dist )
  552.     new len = client_data[id][GRAB_LEN]
  553.    
  554.     if( len > mindist )
  555.     {
  556.         len -= get_pcvar_num( p_speed )
  557.         if( len < mindist ) len = mindist
  558.         client_data[id][GRAB_LEN] = len
  559.     }
  560.     else if( get_pcvar_num( p_auto_choke ) )
  561.         do_choke( id )
  562. }
  563.  
  564. public do_choke( id )
  565. {
  566.     new target = client_data[id][GRABBED]
  567.     if( client_data[id][FLAGS] & CDF_NO_CHOKE || id == target || target > MAXPLAYERS) return
  568.    
  569.     new dmg = get_pcvar_num( p_choke_dmg )
  570.     new vec[3]
  571.     FVecIVec( get_target_origin_f( target ), vec )
  572.    
  573.     message_begin( MSG_ONE, SVC_SCREENSHAKE, _, target )
  574.     write_short( 999999 ) //amount
  575.     write_short( 9999 ) //duration
  576.     write_short( 999 ) //frequency
  577.     message_end( )
  578.    
  579.     message_begin( MSG_ONE, SVC_SCREENFADE, _, target )
  580.     write_short( 9999 ) //duration
  581.     write_short( 100 ) //hold
  582.     write_short( SF_FADE_MODULATE ) //flags
  583.     write_byte( 200 ) //r
  584.     write_byte( 0 ) //g
  585.     write_byte( 0 ) //b
  586.     write_byte( 200 ) //a
  587.     message_end( )
  588.    
  589.     message_begin( MSG_ONE, WTF_DAMAGE, _, target )
  590.     write_byte( 0 ) //damage armor
  591.     write_byte( dmg ) //damage health
  592.     write_long( DMG_CRUSH ) //damage type
  593.     write_coord( vec[0] ) //origin[x]
  594.     write_coord( vec[1] ) //origin[y]
  595.     write_coord( vec[2] ) //origin[z]
  596.     message_end( )
  597.        
  598.     message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  599.     write_byte( TE_BLOODSTREAM )
  600.     write_coord( vec[0] ) //pos.x
  601.     write_coord( vec[1] ) //pos.y
  602.     write_coord( vec[2] + 15 ) //pos.z
  603.     write_coord( random_num( 0, 255 ) ) //vec.x
  604.     write_coord( random_num( 0, 255 ) ) //vec.y
  605.     write_coord( random_num( 0, 255 ) ) //vec.z
  606.     write_byte( 70 ) //col index
  607.     write_byte( random_num( 50, 250 ) ) //speed
  608.     message_end( )
  609.    
  610.     new health = pev( target, pev_health ) - dmg
  611.     set_pev( target, pev_health, float( health ) )
  612.     if( health < 1 ) dllfunc( DLLFunc_ClientKill, target )
  613.    
  614.     emit_sound( target, CHAN_BODY, "player/PL_PAIN2.WAV", VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  615.    
  616.     client_data[id][FLAGS] ^= CDF_NO_CHOKE
  617.     set_task( get_pcvar_float( p_choke_time ), "clear_no_choke", TSK_CHKE + id )
  618. }
  619.  
  620. public clear_no_choke( tskid )
  621. {
  622.     new id = tskid - TSK_CHKE
  623.     client_data[id][FLAGS] ^= CDF_NO_CHOKE
  624. }
  625.  
  626. //Grabs the client and teleports them to the admin
  627. public force_grab(id, level, cid)
  628. {
  629.     if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED
  630.  
  631.     new arg[33]
  632.     read_argv( 1, arg, 32 )
  633.  
  634.     new targetid = cmd_target( id, arg, 1 )
  635.    
  636.     if( is_grabbed( targetid, id ) ) return PLUGIN_HANDLED
  637.     if( !is_user_alive( targetid ) )
  638.     {
  639.         return PLUGIN_HANDLED
  640.     }
  641.    
  642.     //Safe to tp target to aim spot?
  643.     new Float:tmpvec[3], Float:orig[3], Float:torig[3], Float:trace_ret[3]
  644.     new bool:safe = false, i
  645.    
  646.     get_view_pos( id, orig )
  647.     tmpvec = vel_by_aim( id, get_pcvar_num( p_min_dist ) )
  648.    
  649.     for( new j = 1; j < 11 && !safe; j++ )
  650.     {
  651.         torig[0] = orig[0] + tmpvec[i] * j
  652.         torig[1] = orig[1] + tmpvec[i] * j
  653.         torig[2] = orig[2] + tmpvec[i] * j
  654.        
  655.         traceline( tmpvec, torig, id, trace_ret )
  656.        
  657.         if( get_distance_f( trace_ret, torig ) ) break
  658.        
  659.         engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
  660.         if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) )
  661.             safe = true
  662.     }
  663.    
  664.     //Still not safe? Then find another safe spot somewhere around the grabber
  665.     pev( id, pev_origin, orig )
  666.     new try[3]
  667.     orig[2] += 2
  668.     while( try[2] < 3 && !safe )
  669.     {
  670.         for( i = 0; i < 3; i++ )
  671.             switch( try[i] )
  672.             {
  673.                 case 0 : torig[i] = orig[i] + ( i == 2 ? 80 : 40 )
  674.                 case 1 : torig[i] = orig[i]
  675.                 case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )
  676.             }
  677.        
  678.         traceline( tmpvec, torig, id, trace_ret )
  679.        
  680.         engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
  681.         if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen )
  682.                 && !get_distance_f( trace_ret, torig ) ) safe = true
  683.        
  684.         try[0]++
  685.         if( try[0] == 3 )
  686.         {
  687.             try[0] = 0
  688.             try[1]++
  689.             if( try[1] == 3 )
  690.             {
  691.                 try[1] = 0
  692.                 try[2]++
  693.             }
  694.         }
  695.     }
  696.    
  697.     if( safe )
  698.     {
  699.         set_pev( targetid, pev_origin, torig )
  700.         set_grabbed( id, targetid )
  701.     }
  702.  
  703.     return PLUGIN_HANDLED
  704. }
  705.  
  706. public is_grabbed( target, grabber )
  707. {
  708.     for( new i = 1; i <= MAXPLAYERS; i++ )
  709.         if( client_data[i][GRABBED] == target )
  710.         {
  711.             unset_grabbed( grabber )
  712.             return true
  713.         }
  714.     return false
  715. }
  716.  
  717. public DeathMsg( )
  718.     kill_grab( read_data( 2 ) )
  719.  
  720. public client_disconnected( id )
  721. {
  722.     kill_grab( id )
  723.     speed_off[id] = false
  724.     return PLUGIN_CONTINUE
  725. }
  726.  
  727. public kill_grab( id )
  728. {
  729.     //If given client has grabbed, or has a grabber, unset it
  730.     if( client_data[id][GRABBED] )
  731.         unset_grabbed( id )
  732.     else if( client_data[id][GRABBER] )
  733.         unset_grabbed( client_data[id][GRABBER] )
  734. }
  735.  
  736. stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] )
  737. {
  738.     engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 )
  739.     get_tr2( 0, TR_vecEndPos, vHitPos )
  740.     return get_tr2( 0, TR_pHit )
  741. }
  742.  
  743. stock get_view_pos( const id, Float:vViewPos[3] )
  744. {
  745.     new Float:vOfs[3]
  746.     pev( id, pev_origin, vViewPos )
  747.     pev( id, pev_view_ofs, vOfs )      
  748.    
  749.     vViewPos[0] += vOfs[0]
  750.     vViewPos[1] += vOfs[1]
  751.     vViewPos[2] += vOfs[2]
  752. }
  753.  
  754. stock Float:vel_by_aim( id, speed = 1 )
  755. {
  756.     new Float:v1[3], Float:vBlah[3]
  757.     pev( id, pev_v_angle, v1 )
  758.     engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah )
  759.    
  760.     v1[0] *= speed
  761.     v1[1] *= speed
  762.     v1[2] *= speed
  763.    
  764.     return v1
  765. }
  766. stock fm_give_item(index, const item[])
  767. {
  768.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  769.         return 0
  770.  
  771.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  772.     if (!pev_valid(ent))
  773.         return 0
  774.  
  775.     new Float:origin[3];
  776.     pev(index, pev_origin, origin)
  777.     set_pev(ent, pev_origin, origin)
  778.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  779.     dllfunc(DLLFunc_Spawn, ent)
  780.  
  781.     new save = pev(ent, pev_solid)
  782.     dllfunc(DLLFunc_Touch, ent, index)
  783.     if (pev(ent, pev_solid) != save)
  784.         return ent
  785.  
  786.     engfunc(EngFunc_RemoveEntity, ent)
  787.  
  788.     return -1
  789. }
  790.  
  791. stock fm_strip_user_weapons(id)
  792. {
  793.         static ent
  794.         ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
  795.         if (!pev_valid(ent)) return;
  796.        
  797.         dllfunc(DLLFunc_Spawn, ent)
  798.         dllfunc(DLLFunc_Use, ent, id)
  799.         engfunc(EngFunc_RemoveEntity, ent)
  800. }
  801.  
  802. stock ChatColor(const id, const input[], any:...)
  803. {
  804.     new count = 1, players[32]
  805.     static msg[191]
  806.     vformat(msg, 190, input, 3)
  807.    
  808.     replace_all(msg, 190, "!g", "^4")
  809.     replace_all(msg, 190, "!y", "^1")
  810.     replace_all(msg, 190, "!team", "^3")
  811.    
  812.     if (id) players[0] = id; else get_players(players, count, "ch")
  813.     {
  814.         for (new i = 0; i < count; i++)
  815.         {
  816.             if (is_user_connected(players[i]))
  817.             {
  818.                 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
  819.                 write_byte(players[i]);
  820.                 write_string(msg);
  821.                 message_end();
  822.             }
  823.         }
  824.     }
  825. }
  826. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  827. *{\\ rtf1\\ fbidis\\ ansi\\ ansicpg1252\\ deff0{\\ fonttbl{\\ f0\\ fnil\\ fcharset0 Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ ltrpar\\ lang1025\\ f0\\ fs16 \n\\ par }
  828. */

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#7

Post by Mark » 4 Months Ago

Mystic Viper wrote:
4 Months Ago
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <fun>
  5. #include <hamsandwich>
  6.  
  7. #pragma tabsize 0
  8.  
  9. #define PLUGIN      "[ZE] MG Grab"
  10. #define VERSION     "2.5"
  11. #define AUTHOR      "LuXo KING Gaming + Legolas"
  12.  
  13. #define ADMIN       ADMIN_LEVEL_F
  14. #define RESON_KICK  "Kicked by Admin"
  15. #define GRAB_MENU
  16.  
  17. #define TSK_CHKE 50
  18.  
  19. #define SF_FADEOUT 0
  20.  
  21. new client_data[33][4]
  22. #define GRABBED  0
  23. #define GRABBER  1
  24. #define GRAB_LEN 2
  25. #define FLAGS    3
  26.  
  27. #define CDF_IN_PUSH   (1<<0)
  28. #define CDF_IN_PULL   (1<<1)
  29. #define CDF_NO_CHOKE  (1<<2)
  30.  
  31. enum
  32. {
  33.     r = 0.0,
  34.     g = 255.0,
  35.     b = 255.0,
  36.  
  37.     a = 200.0
  38. };
  39.  
  40. new const Menu[][] =
  41. {
  42.     "",
  43.     "MENU_1",
  44.     "MENU_2",
  45.     "MENU_3",
  46.     "MENU_4",
  47.     "MENU_5",
  48.     "MENU_6"
  49. };
  50.  
  51. new p_enabled, p_players_only
  52. new p_throw_force, p_min_dist, p_speed, p_grab_force
  53. new p_choke_time, p_choke_dmg, p_auto_choke
  54. new p_glow
  55. new speed_off[33]
  56. new g_short
  57. new model_gibs
  58. new MAXPLAYERS
  59. new SVC_SCREENSHAKE, SVC_SCREENFADE, WTF_DAMAGE
  60.  
  61. public plugin_init( )
  62. {
  63.     register_plugin(PLUGIN, VERSION, AUTHOR)
  64.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
  65.     RegisterHam(Ham_Spawn, "player", "SpawnPlayer")
  66.  
  67.     p_enabled = register_cvar( "gp_enabled", "1" )
  68.     p_players_only = register_cvar( "gp_players_only", "0" )
  69.    
  70.     p_min_dist = register_cvar ( "gp_min_dist", "90" )
  71.     p_throw_force = register_cvar( "gp_throw_force", "1500" )
  72.     p_grab_force = register_cvar( "gp_grab_force", "8" )
  73.     p_speed = register_cvar( "gp_speed", "5" )
  74.    
  75.     p_choke_time = register_cvar( "gp_choke_time", "1.5" )
  76.     p_choke_dmg = register_cvar( "gp_choke_dmg", "5" )
  77.     p_auto_choke = register_cvar( "gp_auto_choke", "1" )
  78.    
  79.     p_glow = register_cvar( "gp_glow", "1" )
  80.    
  81.     register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." )
  82.     register_clcmd( "+grab", "grab", ADMIN, "bind a key to +grab" )
  83.     register_clcmd( "-grab", "unset_grabbed" )
  84.    
  85.     register_clcmd( "+push", "push", ADMIN, "bind a key to +push" )
  86.     register_clcmd( "-push", "push" )
  87.     register_clcmd( "+pull", "pull", ADMIN, "bind a key to +pull" )
  88.     register_clcmd( "-pull", "pull" )
  89.     register_clcmd( "push", "push2" )
  90.     register_clcmd( "pull", "pull2" )
  91.    
  92.     register_clcmd( "drop" ,"throw" )
  93.    
  94.     register_event( "DeathMsg", "DeathMsg", "a" )
  95.    
  96.     register_forward( FM_PlayerPreThink, "fm_player_prethink" )
  97.    
  98.     register_dictionary( "grab_plus.txt" )
  99.    
  100.     MAXPLAYERS = get_maxplayers()
  101.    
  102.     SVC_SCREENFADE = get_user_msgid( "ScreenFade" )
  103.     SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" )
  104.     WTF_DAMAGE = get_user_msgid( "Damage" )
  105.  
  106.     register_dictionary("mg_grab.txt");
  107. }
  108.  
  109. public plugin_precache( )
  110. {
  111.     precache_sound("player/PL_PAIN2.WAV")
  112.     precache_sound("MG_grab/grab_victim_xa.wav")
  113.     precache_sound("MG_grab/grab_id_mine.wav")
  114.     precache_sound("MG_grab/grab_weapon.wav")
  115.     precache_sound("MG_grab/grab_bury.wav")
  116.     g_short = precache_model("sprites/MG_grab/energy_grab.spr");
  117.     model_gibs = precache_model("models/rockgibs.mdl")
  118. }
  119.  
  120. public fm_player_prethink( id )
  121. {
  122.     new target
  123.     //Search for a target
  124.     if ( client_data[id][GRABBED] == -1 )
  125.     {
  126.         new Float:orig[3], Float:ret[3]
  127.         get_view_pos( id, orig )
  128.         ret = vel_by_aim( id, 9999 )
  129.        
  130.         ret[0] += orig[0]
  131.         ret[1] += orig[1]
  132.         ret[2] += orig[2]
  133.        
  134.         target = traceline( orig, ret, id, ret )
  135.        
  136.         if( 0 < target <= MAXPLAYERS )
  137.         {
  138.             if( is_grabbed( target, id ) ) return FMRES_IGNORED
  139.             set_grabbed( id, target )
  140.         }
  141.         else if( !get_pcvar_num( p_players_only ) )
  142.         {
  143.             new movetype
  144.             if( target && pev_valid( target ) )
  145.             {
  146.                 movetype = pev( target, pev_movetype )
  147.                 if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) )
  148.                     return FMRES_IGNORED
  149.             }
  150.             else
  151.             {
  152.                 target = 0
  153.                 new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 )
  154.                 while( !target && ent > 0 )
  155.                 {
  156.                     movetype = pev( ent, pev_movetype )
  157.                     if( ( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS )
  158.                             && ent != id  )
  159.                         target = ent
  160.                     ent = engfunc( EngFunc_FindEntityInSphere, ent, ret, 12.0 )
  161.                 }
  162.             }
  163.             if( target )
  164.             {
  165.                 if( is_grabbed( target, id ) ) return FMRES_IGNORED
  166.                 set_grabbed( id, target )
  167.             }
  168.         }
  169.     }
  170.    
  171.     target = client_data[id][GRABBED]
  172.     //If they've grabbed something
  173.     if( target > 0 )
  174.     {
  175.         if( !pev_valid( target ) || ( pev( target, pev_health ) < 1 && pev( target, pev_max_health ) ) )
  176.         {
  177.             unset_grabbed( id )
  178.             return FMRES_IGNORED
  179.         }
  180.          
  181.         //Use key choke
  182.         if( pev( id, pev_button ) & IN_USE )
  183.             do_choke( id )
  184.        
  185.         //Push and pull
  186.         new cdf = client_data[id][FLAGS]
  187.         if ( cdf & CDF_IN_PULL )
  188.             do_pull( id )
  189.         else if ( cdf & CDF_IN_PUSH )
  190.             do_push( id )
  191.        
  192.         if( target > MAXPLAYERS ) grab_think( id )
  193.     }
  194.    
  195.     //If they're grabbed
  196.     target = client_data[id][GRABBER]
  197.     if( target > 0 ) grab_think( target )
  198.    
  199.     return FMRES_IGNORED
  200. }
  201.  
  202. public grab_think( id ) //id of the grabber
  203. {
  204.     new target = client_data[id][GRABBED]
  205.    
  206.     //Keep grabbed clients from sticking to ladders
  207.     if( pev( target, pev_movetype ) == MOVETYPE_FLY && !(pev( target, pev_button ) & IN_JUMP ) ) client_cmd( target, "+jump;wait;-jump" )
  208.    
  209.     //Move targeted client
  210.     new Float:tmpvec[3], Float:tmpvec2[3], Float:torig[3], Float:tvel[3]
  211.    
  212.     get_view_pos( id, tmpvec )
  213.    
  214.     tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] )
  215.    
  216.     torig = get_target_origin_f( target )
  217.    
  218.     new force = get_pcvar_num( p_grab_force )
  219.    
  220.     tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force
  221.     tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force
  222.     tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force
  223.    
  224.     set_pev( target, pev_velocity, tvel )
  225. }
  226.  
  227. stock Float:get_target_origin_f( id )
  228. {
  229.     new Float:orig[3]
  230.     pev( id, pev_origin, orig )
  231.    
  232.     //If grabbed is not a player, move origin to center
  233.     if( id > MAXPLAYERS )
  234.     {
  235.         new Float:mins[3], Float:maxs[3]
  236.         pev( id, pev_mins, mins )
  237.         pev( id, pev_maxs, maxs )
  238.        
  239.         if( !mins[2] ) orig[2] += maxs[2] / 2
  240.     }
  241.    
  242.     return orig
  243. }
  244.  
  245. public grab( id, level, cid )
  246. {
  247.     if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED
  248.    
  249.     if ( !client_data[id][GRABBED] ) client_data[id][GRABBED] = -1
  250.    
  251.     return PLUGIN_HANDLED
  252. }
  253.  
  254. public SpawnPlayer(id)
  255.     speed_off[id] = false
  256.  
  257. public CurrentWeapon(id)
  258. {
  259.     if(speed_off[id])
  260.         set_pev(id, pev_maxspeed, 00000.0)
  261. }
  262.  
  263. public grab_menu(id)
  264. {
  265.     new name[32]
  266.     new target = client_data[id][GRABBED]
  267.     if(target && is_user_alive(target))
  268.     {
  269.         get_user_name(target, name, charsmax(name))
  270.     }
  271.     new Item[512], Str[10], menu;
  272.  
  273.     formatex(Item, charsmax(Item), "%L", id, "MENU_NAME", name);
  274.     menu = menu_create(Item, "menu_handler")
  275.  
  276.     for(new i = 1; i <= charsmax(Menu); i++)
  277.     {
  278.         num_to_str(i, Str, charsmax(Str));
  279.  
  280.         formatex(Item, charsmax(Item), "%L", id, Menu[i]);
  281.         menu_additem(menu, Item, Str, 0);
  282.     }
  283.     formatex(Item, charsmax(Item), "%L", id, "MENU_EXIT");
  284.     menu_setprop(menu, MPROP_EXITNAME, Item);
  285.  
  286.     menu_display(id, menu, 0);
  287.  
  288.     return PLUGIN_HANDLED;
  289. }
  290.      
  291. public menu_handler(id, menu, item)
  292. {
  293.     if(item == MENU_EXIT)
  294.     {
  295.         menu_destroy(menu)
  296.         return PLUGIN_HANDLED
  297.     }
  298.          
  299.     new data[6], iName[64], access, callback
  300.     menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)
  301.          
  302.     new key = str_to_num(data)
  303.     new target = client_data[id][GRABBED]
  304.          
  305.     switch(key)
  306.     {
  307.         case 1:
  308.         {
  309.             if(target && is_user_alive(target))
  310.             {
  311.                 grab_eff_zd(id, target)
  312.                 server_cmd("kick #%d ^"%s^"", get_user_userid(target), RESON_KICK)
  313.             }
  314.         }
  315.         case 2:
  316.         {
  317.             if(target && is_user_alive(target))
  318.             {
  319.                 user_kill(target)
  320.             }
  321.         }
  322.         case 3:
  323.         {
  324.             if(target && is_user_alive(target))
  325.             {
  326.                 fm_strip_user_weapons(target)
  327.                 fm_give_item(target, "weapon_knife")               
  328.             }
  329.         }
  330.         case 4:
  331.         {
  332.             if(target && is_user_alive(target))
  333.             {
  334.                 Bury(id, target)
  335.             }
  336.         }
  337.         case 5:
  338.         {
  339.             if(target && is_user_alive(target))
  340.             {
  341.                 Bury_off(id, target)
  342.             }
  343.         }
  344.         case 6:
  345.         {
  346.             if(target && is_user_alive(target))
  347.             {
  348.                 pull(id)
  349.             }
  350.         }
  351.         case 7:
  352.         {
  353.             if(target && is_user_alive(target))
  354.             {
  355.                 set_pev(target, pev_punchangle, { 400.0, 999.0, 400.0 })
  356.             }
  357.         }
  358.     }
  359.     return PLUGIN_HANDLED
  360. }
  361.  
  362. public throw( id )
  363. {
  364.     new target = client_data[id][GRABBED]
  365.     if( target > 0 )
  366.     {
  367.         set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) )
  368.         unset_grabbed( id )
  369.         return PLUGIN_HANDLED
  370.     }
  371.  
  372.     return PLUGIN_CONTINUE
  373. }
  374.  
  375. public unset_grabbed( id )
  376. {
  377.     new target = client_data[id][GRABBED]
  378.     if( target > 0 && pev_valid( target ) )
  379.     {
  380.         set_pev( target, pev_renderfx, kRenderFxNone )
  381.         set_pev( target, pev_rendercolor, {255.0, 255.0, 255.0} )
  382.         set_pev( target, pev_rendermode, kRenderNormal )
  383.         set_pev( target, pev_renderamt, 16.0 )
  384.        
  385.         if( 0 < target <= MAXPLAYERS )
  386.             client_data[target][GRABBER] = 0
  387.     }
  388.     show_menu(id, 0, "^n", 1)
  389.     client_data[id][GRABBED] = 0
  390. }
  391.  
  392. //Grabs onto someone
  393. public set_grabbed( id, target )
  394. {
  395.     if( get_pcvar_num( p_glow ) )
  396.     {
  397.         set_pev( target, pev_renderfx, kRenderFxGlowShell )
  398.         set_pev( target, pev_rendercolor, {r, g, b})
  399.         set_pev( target, pev_rendermode, kRenderTransColor )
  400.         set_pev( target, pev_renderamt, a )
  401.     }
  402.    
  403.     if( 0 < target <= MAXPLAYERS )
  404.         client_data[target][GRABBER] = id
  405.     client_data[id][FLAGS] = 0
  406.     client_data[id][GRABBED] = target
  407.     new name[33], name2[33]
  408.     get_user_name(id, name, 32)
  409.     get_user_name(target, name2, 32)
  410.     if(get_user_team(target)==1 || get_user_team(target)==2)
  411.     {      
  412.         client_cmd(target, "spk MG_grab/grab_victim_xa.wav")
  413.         client_cmd(id, "spk MG_grab/grab_id_mine.wav")
  414.         ChatColor(target, "%L", target, "CHAT_1", name)  
  415.         ChatColor(id, "%L", id, "CHAT_2", name2)
  416.         grab_eff(target)
  417.         #if defined GRAB_MENU
  418.         grab_menu(id)
  419.         #endif
  420.     }
  421.     else
  422.     {
  423.         ChatColor(id, "%L", id, "CHAT_3")
  424.         client_cmd(0, "spk MG_grab/grab_weapon.wav")
  425.     }
  426.     new Float:torig[3], Float:orig[3]
  427.     pev( target, pev_origin, torig )
  428.     pev( id, pev_origin, orig )
  429.     client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) )
  430.     if( client_data[id][GRAB_LEN] < get_pcvar_num( p_min_dist ) ) client_data[id][GRAB_LEN] = get_pcvar_num( p_min_dist )
  431. }
  432.  
  433. public Bury(id, target)
  434. {
  435.     ChatColor(id, "%L", id, "CHAT_4")
  436.     set_dhudmessage(255, 0, 0, -1.0, 0.20, 0, 0.1, 3.0, 0.1, 2.0)
  437.     show_dhudmessage(id, "BURIED")
  438.     client_cmd(id, "spk MG_grab/grab_bury.wav")
  439.     grab_eff_zd(id, target)
  440.     if(is_user_alive(target))
  441.         {
  442.         new origin[3]
  443.         get_user_origin(target, origin)
  444.         origin[2] -= 30
  445.         set_user_origin(target, origin)
  446.     }
  447. }
  448.  
  449. public Bury_off(id, target)
  450. {
  451.     ChatColor(id, "%L", id, "CHAT_5")
  452.    
  453.     set_dhudmessage(255, 0, 0, -1.0, 0.20, 0, 0.1, 3.0, 0.1, 2.0)
  454.     show_dhudmessage(target, "UNBURIED")
  455.    
  456.     if(is_user_alive(target))
  457.         {
  458.         new origin[3]
  459.         get_user_origin(target, origin)
  460.         origin[2] += 30
  461.         set_user_origin(target, origin)
  462.     }
  463. }  
  464.  
  465. public grab_eff(target)
  466. {
  467.     new origin[3]
  468.    
  469.     get_user_origin(target,origin)
  470.    
  471.     message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},target)
  472.     write_byte(TE_SPRITETRAIL) //Спрайт захвата
  473.     write_coord(origin[0])
  474.     write_coord(origin[1])
  475.     write_coord(origin[2]+20)
  476.     write_coord(origin[0])
  477.     write_coord(origin[1])
  478.     write_coord(origin[2]+80)
  479.     write_short(g_short)
  480.     write_byte(20)
  481.     write_byte(20)
  482.     write_byte(4)
  483.     write_byte(20)
  484.     write_byte(10)
  485.     message_end()
  486. }
  487.  
  488. public grab_eff_zd(id, target)
  489. {
  490.     new origin[3]
  491.     get_user_origin(id, origin, 3)
  492.  
  493.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  494.     write_byte(TE_BREAKMODEL); // TE_
  495.     write_coord(origin[0]); // X
  496.     write_coord(origin[1]); // Y
  497.     write_coord(origin[2] + 24); // Z
  498.     write_coord(16); // size X
  499.     write_coord(16); // size Y
  500.     write_coord(16); // size Z
  501.     write_coord(random_num(-50,50)); // velocity X
  502.     write_coord(random_num(-50,50)); // velocity Y
  503.     write_coord(25); // velocity Z
  504.     write_byte(10); // random velocity
  505.     write_short(model_gibs); // sprite
  506.     write_byte(9); // count
  507.     write_byte(20); // life
  508.     write_byte(0x08); // flags
  509.     message_end();    
  510. }
  511.    
  512. public push(id)
  513. {
  514.     client_data[id][FLAGS] ^= CDF_IN_PUSH
  515.     return PLUGIN_HANDLED
  516. }
  517.  
  518. public pull(id)
  519. {
  520.     ChatColor(id, "%L", id, "CHAT_6")
  521.     client_data[id][FLAGS] ^= CDF_IN_PULL
  522.     return PLUGIN_HANDLED
  523. }
  524.  
  525. public push2( id )
  526. {
  527.     if( client_data[id][GRABBED] > 0 )
  528.     {
  529.         do_push( id )
  530.         return PLUGIN_HANDLED
  531.     }
  532.     return PLUGIN_CONTINUE
  533. }
  534.  
  535. public pull2( id )
  536. {
  537.     if( client_data[id][GRABBED] > 0 )
  538.     {
  539.         do_pull( id )
  540.         return PLUGIN_HANDLED
  541.     }
  542.     return PLUGIN_CONTINUE
  543. }
  544.  
  545. public do_push( id )
  546.     if( client_data[id][GRAB_LEN] < 9999 )
  547.         client_data[id][GRAB_LEN] += get_pcvar_num( p_speed )
  548.  
  549. public do_pull( id )
  550. {
  551.     new mindist = get_pcvar_num( p_min_dist )
  552.     new len = client_data[id][GRAB_LEN]
  553.    
  554.     if( len > mindist )
  555.     {
  556.         len -= get_pcvar_num( p_speed )
  557.         if( len < mindist ) len = mindist
  558.         client_data[id][GRAB_LEN] = len
  559.     }
  560.     else if( get_pcvar_num( p_auto_choke ) )
  561.         do_choke( id )
  562. }
  563.  
  564. public do_choke( id )
  565. {
  566.     new target = client_data[id][GRABBED]
  567.     if( client_data[id][FLAGS] & CDF_NO_CHOKE || id == target || target > MAXPLAYERS) return
  568.    
  569.     new dmg = get_pcvar_num( p_choke_dmg )
  570.     new vec[3]
  571.     FVecIVec( get_target_origin_f( target ), vec )
  572.    
  573.     message_begin( MSG_ONE, SVC_SCREENSHAKE, _, target )
  574.     write_short( 999999 ) //amount
  575.     write_short( 9999 ) //duration
  576.     write_short( 999 ) //frequency
  577.     message_end( )
  578.    
  579.     message_begin( MSG_ONE, SVC_SCREENFADE, _, target )
  580.     write_short( 9999 ) //duration
  581.     write_short( 100 ) //hold
  582.     write_short( SF_FADE_MODULATE ) //flags
  583.     write_byte( 200 ) //r
  584.     write_byte( 0 ) //g
  585.     write_byte( 0 ) //b
  586.     write_byte( 200 ) //a
  587.     message_end( )
  588.    
  589.     message_begin( MSG_ONE, WTF_DAMAGE, _, target )
  590.     write_byte( 0 ) //damage armor
  591.     write_byte( dmg ) //damage health
  592.     write_long( DMG_CRUSH ) //damage type
  593.     write_coord( vec[0] ) //origin[x]
  594.     write_coord( vec[1] ) //origin[y]
  595.     write_coord( vec[2] ) //origin[z]
  596.     message_end( )
  597.        
  598.     message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  599.     write_byte( TE_BLOODSTREAM )
  600.     write_coord( vec[0] ) //pos.x
  601.     write_coord( vec[1] ) //pos.y
  602.     write_coord( vec[2] + 15 ) //pos.z
  603.     write_coord( random_num( 0, 255 ) ) //vec.x
  604.     write_coord( random_num( 0, 255 ) ) //vec.y
  605.     write_coord( random_num( 0, 255 ) ) //vec.z
  606.     write_byte( 70 ) //col index
  607.     write_byte( random_num( 50, 250 ) ) //speed
  608.     message_end( )
  609.    
  610.     new health = pev( target, pev_health ) - dmg
  611.     set_pev( target, pev_health, float( health ) )
  612.     if( health < 1 ) dllfunc( DLLFunc_ClientKill, target )
  613.    
  614.     emit_sound( target, CHAN_BODY, "player/PL_PAIN2.WAV", VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  615.    
  616.     client_data[id][FLAGS] ^= CDF_NO_CHOKE
  617.     set_task( get_pcvar_float( p_choke_time ), "clear_no_choke", TSK_CHKE + id )
  618. }
  619.  
  620. public clear_no_choke( tskid )
  621. {
  622.     new id = tskid - TSK_CHKE
  623.     client_data[id][FLAGS] ^= CDF_NO_CHOKE
  624. }
  625.  
  626. //Grabs the client and teleports them to the admin
  627. public force_grab(id, level, cid)
  628. {
  629.     if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED
  630.  
  631.     new arg[33]
  632.     read_argv( 1, arg, 32 )
  633.  
  634.     new targetid = cmd_target( id, arg, 1 )
  635.    
  636.     if( is_grabbed( targetid, id ) ) return PLUGIN_HANDLED
  637.     if( !is_user_alive( targetid ) )
  638.     {
  639.         return PLUGIN_HANDLED
  640.     }
  641.    
  642.     //Safe to tp target to aim spot?
  643.     new Float:tmpvec[3], Float:orig[3], Float:torig[3], Float:trace_ret[3]
  644.     new bool:safe = false, i
  645.    
  646.     get_view_pos( id, orig )
  647.     tmpvec = vel_by_aim( id, get_pcvar_num( p_min_dist ) )
  648.    
  649.     for( new j = 1; j < 11 && !safe; j++ )
  650.     {
  651.         torig[0] = orig[0] + tmpvec[i] * j
  652.         torig[1] = orig[1] + tmpvec[i] * j
  653.         torig[2] = orig[2] + tmpvec[i] * j
  654.        
  655.         traceline( tmpvec, torig, id, trace_ret )
  656.        
  657.         if( get_distance_f( trace_ret, torig ) ) break
  658.        
  659.         engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
  660.         if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) )
  661.             safe = true
  662.     }
  663.    
  664.     //Still not safe? Then find another safe spot somewhere around the grabber
  665.     pev( id, pev_origin, orig )
  666.     new try[3]
  667.     orig[2] += 2
  668.     while( try[2] < 3 && !safe )
  669.     {
  670.         for( i = 0; i < 3; i++ )
  671.             switch( try[i] )
  672.             {
  673.                 case 0 : torig[i] = orig[i] + ( i == 2 ? 80 : 40 )
  674.                 case 1 : torig[i] = orig[i]
  675.                 case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )
  676.             }
  677.        
  678.         traceline( tmpvec, torig, id, trace_ret )
  679.        
  680.         engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
  681.         if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen )
  682.                 && !get_distance_f( trace_ret, torig ) ) safe = true
  683.        
  684.         try[0]++
  685.         if( try[0] == 3 )
  686.         {
  687.             try[0] = 0
  688.             try[1]++
  689.             if( try[1] == 3 )
  690.             {
  691.                 try[1] = 0
  692.                 try[2]++
  693.             }
  694.         }
  695.     }
  696.    
  697.     if( safe )
  698.     {
  699.         set_pev( targetid, pev_origin, torig )
  700.         set_grabbed( id, targetid )
  701.     }
  702.  
  703.     return PLUGIN_HANDLED
  704. }
  705.  
  706. public is_grabbed( target, grabber )
  707. {
  708.     for( new i = 1; i <= MAXPLAYERS; i++ )
  709.         if( client_data[i][GRABBED] == target )
  710.         {
  711.             unset_grabbed( grabber )
  712.             return true
  713.         }
  714.     return false
  715. }
  716.  
  717. public DeathMsg( )
  718.     kill_grab( read_data( 2 ) )
  719.  
  720. public client_disconnected( id )
  721. {
  722.     kill_grab( id )
  723.     speed_off[id] = false
  724.     return PLUGIN_CONTINUE
  725. }
  726.  
  727. public kill_grab( id )
  728. {
  729.     //If given client has grabbed, or has a grabber, unset it
  730.     if( client_data[id][GRABBED] )
  731.         unset_grabbed( id )
  732.     else if( client_data[id][GRABBER] )
  733.         unset_grabbed( client_data[id][GRABBER] )
  734. }
  735.  
  736. stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] )
  737. {
  738.     engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 )
  739.     get_tr2( 0, TR_vecEndPos, vHitPos )
  740.     return get_tr2( 0, TR_pHit )
  741. }
  742.  
  743. stock get_view_pos( const id, Float:vViewPos[3] )
  744. {
  745.     new Float:vOfs[3]
  746.     pev( id, pev_origin, vViewPos )
  747.     pev( id, pev_view_ofs, vOfs )      
  748.    
  749.     vViewPos[0] += vOfs[0]
  750.     vViewPos[1] += vOfs[1]
  751.     vViewPos[2] += vOfs[2]
  752. }
  753.  
  754. stock Float:vel_by_aim( id, speed = 1 )
  755. {
  756.     new Float:v1[3], Float:vBlah[3]
  757.     pev( id, pev_v_angle, v1 )
  758.     engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah )
  759.    
  760.     v1[0] *= speed
  761.     v1[1] *= speed
  762.     v1[2] *= speed
  763.    
  764.     return v1
  765. }
  766. stock fm_give_item(index, const item[])
  767. {
  768.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  769.         return 0
  770.  
  771.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  772.     if (!pev_valid(ent))
  773.         return 0
  774.  
  775.     new Float:origin[3];
  776.     pev(index, pev_origin, origin)
  777.     set_pev(ent, pev_origin, origin)
  778.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  779.     dllfunc(DLLFunc_Spawn, ent)
  780.  
  781.     new save = pev(ent, pev_solid)
  782.     dllfunc(DLLFunc_Touch, ent, index)
  783.     if (pev(ent, pev_solid) != save)
  784.         return ent
  785.  
  786.     engfunc(EngFunc_RemoveEntity, ent)
  787.  
  788.     return -1
  789. }
  790.  
  791. stock fm_strip_user_weapons(id)
  792. {
  793.         static ent
  794.         ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
  795.         if (!pev_valid(ent)) return;
  796.        
  797.         dllfunc(DLLFunc_Spawn, ent)
  798.         dllfunc(DLLFunc_Use, ent, id)
  799.         engfunc(EngFunc_RemoveEntity, ent)
  800. }
  801.  
  802. stock ChatColor(const id, const input[], any:...)
  803. {
  804.     new count = 1, players[32]
  805.     static msg[191]
  806.     vformat(msg, 190, input, 3)
  807.    
  808.     replace_all(msg, 190, "!g", "^4")
  809.     replace_all(msg, 190, "!y", "^1")
  810.     replace_all(msg, 190, "!team", "^3")
  811.    
  812.     if (id) players[0] = id; else get_players(players, count, "ch")
  813.     {
  814.         for (new i = 0; i < count; i++)
  815.         {
  816.             if (is_user_connected(players[i]))
  817.             {
  818.                 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
  819.                 write_byte(players[i]);
  820.                 write_string(msg);
  821.                 message_end();
  822.             }
  823.         }
  824.     }
  825. }
  826. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  827. *{\\ rtf1\\ fbidis\\ ansi\\ ansicpg1252\\ deff0{\\ fonttbl{\\ f0\\ fnil\\ fcharset0 Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ ltrpar\\ lang1025\\ f0\\ fs16 \n\\ par }
  828. */
This has no errors when complied are you still having a problem?

Mystic Viper
Senior Member
Senior Member
Romania
Posts: 104
Joined: 11 Months Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

#8

Post by Mystic Viper » 4 Months Ago

Nope, it s working now...thanks for asking

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest