SHARE
TWEET

Untitled

a guest Oct 20th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //#define engine
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <fun>
  6. #if defined engine
  7. #include <engine>
  8. #else
  9. #include <fakemeta>
  10. #endif
  11.  
  12. #define ADMIN_LEVEL_Q   ADMIN_LEVEL_C
  13.  
  14. //Used for Grab
  15. new maxplayers
  16. new grab[33]
  17. new Float:grab_totaldis[33]
  18. new grab_speed_cvar
  19. new grab_enabled_cvar
  20. new bool:has_grab[33]
  21.  
  22. //Used for Hook
  23. new bool:hook[33]
  24. new hook_to[33][3]
  25. new hook_speed_cvar
  26. new hook_enabled_cvar
  27. new bool:has_hook[33]
  28.  
  29. //Used for Rope
  30. new bool:rope[33]
  31. new rope_to[33][3]
  32. new Float:rope_totaldis[33]
  33. new rope_speed_cvar
  34. new rope_enabled_cvar
  35. new bool:has_rope[33]
  36.  
  37. //Used for All
  38. new beamsprite
  39.  
  40.  
  41. /****************************
  42.  Register Commands and CVARs
  43. ****************************/
  44.  
  45. public plugin_init()
  46. {
  47.     register_plugin("Grab + Hook + Rope","1.0","GHW_Chronic")
  48.     register_concmd("+grab","grab_on",ADMIN_LEVEL_Q," - Use: bind key +grab")
  49.     register_concmd("-grab","grab_off")
  50.     register_concmd("grab_toggle","grab_toggle",ADMIN_LEVEL_Q,"Toggles your grab on and off")
  51.     register_concmd("+hook","hook_on",ADMIN_LEVEL_Q," - Use: bind key +hook")
  52.     register_concmd("-hook","hook_off")
  53.     register_concmd("hook_toggle","hook_toggle",ADMIN_LEVEL_Q,"Toggles your hook on and off")
  54.     register_concmd("+rope","rope_on",ADMIN_LEVEL_Q," - Use: bind key +rope")
  55.     register_concmd("-rope","rope_off")
  56.     register_concmd("rope_toggle","rope_toggle",ADMIN_LEVEL_Q,"Toggles your rope on and off")
  57.  
  58.     //register_concmd("amx_give_grab","cmd_givetake",ADMIN_LEVEL_Q,"Give a player the ability to grab <nick>")
  59.     //register_concmd("amx_give_hook","cmd_givetake",ADMIN_LEVEL_Q,"Give a player the ability to hook <nick>")
  60.     //register_concmd("amx_give_rope","cmd_givetake",ADMIN_LEVEL_Q,"Give a player the ability to rope <nick>")
  61.  
  62.     //register_concmd("amx_take_grab","cmd_givetake",ADMIN_LEVEL_Q,"Take a player's ability to grab <nick>")
  63.     //register_concmd("amx_take_hook","cmd_givetake",ADMIN_LEVEL_Q,"Take a player's ability to hook <nick>")
  64.     //register_concmd("amx_take_rope","cmd_givetake",ADMIN_LEVEL_Q,"Take a player's ability to rope <nick>")
  65.  
  66.     //register_concmd("amx_ghr_menu","menu_cmd",ADMIN_LEVEL_Q,"Shows a menu that allows you to turn on/off non-admin use of grab, hook, or rope")
  67.  
  68.     //register_menucmd(register_menuid("ghr_menu"),(1<<0)|(1<<1)|(1<<2)|(1<<9), "Pressedghr")
  69.  
  70.     grab_speed_cvar = register_cvar("grab_speed","5")
  71.     grab_enabled_cvar = register_cvar("grab_enabled","0")
  72.  
  73.     hook_speed_cvar = register_cvar("hook_speed","5")
  74.     hook_enabled_cvar = register_cvar("hook_enabled","0")
  75.  
  76.     rope_speed_cvar = register_cvar("rope_speed","5")
  77.     rope_enabled_cvar = register_cvar("rope_enabled","0")
  78.  
  79.     maxplayers = get_maxplayers()
  80.  
  81.     //CVAR that is only used for tracking servers that use this plugin.
  82.     register_cvar("GHW_GHW","1",FCVAR_SERVER)
  83. }
  84.  
  85.  
  86. /**********************************
  87.  Register beam sprite + Hook Sound
  88. **********************************/
  89.  
  90. public plugin_precache()
  91. {
  92.     beamsprite = precache_model("sprites/dot.spr")
  93.     precache_sound("weapons/zoom.wav")
  94.     precache_sound("weapons/xbow_fire1.wav")
  95. }
  96.  
  97.  
  98. /*****************************
  99.  Reset VARs on client connect
  100. *****************************/
  101.  
  102. public client_putinserver(id)
  103. {
  104.     has_grab[id]=false
  105.     has_hook[id]=false
  106.     has_rope[id]=false
  107. }
  108.  
  109.  
  110. /*****
  111.  Menu
  112. *****/
  113.  
  114. public menu_cmd(id,level,cid)
  115. {
  116.     if(cmd_access(id,level,cid,1))
  117.     {
  118.         show_ghr(id)
  119.         console_print(id,"[AMXX] Menu launched.")
  120.     }
  121. }
  122.  
  123. public show_ghr(id)
  124. {
  125.     static aaa[32]
  126.     static bbb[32]
  127.     static ccc[32]
  128.     if(get_pcvar_num(grab_enabled_cvar)==0) format(aaa,31,"No")
  129.     else format(aaa,31,"Yes")
  130.     if(get_pcvar_num(hook_enabled_cvar)==0) format(bbb,31,"No")
  131.     else format(bbb,31,"Yes")
  132.     if(get_pcvar_num(rope_enabled_cvar)==0) format(ccc,31,"No")
  133.     else format(ccc,31,"Yes")
  134.  
  135.     new menuBody[576]
  136.  
  137.     if(colored_menus())
  138.     {
  139.         new len = format(menuBody,575,"\bAllow Players To Use:^n^n")
  140.         len += format(menuBody[len],575-len, "\w1. Grab\R\w%s^n",aaa)
  141.         len += format(menuBody[len],575-len, "\w2. Hook\R\w%s^n",bbb)
  142.         len += format(menuBody[len],575-len, "\w3. Rope\R\w%s^n",ccc)
  143.         len += format(menuBody[len],575-len, "\r0. Exit")
  144.     }
  145.     else
  146.     {
  147.         new len = format(menuBody,575,"Allow Players To Use:^n^n")
  148.         len += format(menuBody[len],575-len, "1. Grab\R%s^n",aaa)
  149.         len += format(menuBody[len],575-len, "2. Hook\R%s^n",bbb)
  150.         len += format(menuBody[len],575-len, "3. Rope\R%s^n",ccc)
  151.         len += format(menuBody[len],575-len, "0. Exit")
  152.     }
  153.     show_menu(id,(1<<0)|(1<<1)|(1<<2)|(1<<9),menuBody,-1,"ghr_menu")
  154.  
  155.     return PLUGIN_CONTINUE
  156. }
  157.  
  158. public Pressedghr(id,key)
  159. {
  160.     switch(key)
  161.     {
  162.         case 0:
  163.         {
  164.             if(get_pcvar_num(grab_enabled_cvar)==0)
  165.             {
  166.                 set_pcvar_num(grab_enabled_cvar,1)
  167.                 client_print(0,print_chat,"[AMXX] Admin has enabled Grab for all clients. Use: bind key +grab")
  168.             }
  169.             else
  170.             {
  171.                 set_pcvar_num(grab_enabled_cvar,0)
  172.                 client_print(0,print_chat,"[AMXX] Admin has disabled Grab for all non-admins.")
  173.             }
  174.             show_ghr(id)
  175.         }
  176.         case 1:
  177.         {
  178.             if(get_pcvar_num(hook_enabled_cvar)==0)
  179.             {
  180.                 set_pcvar_num(hook_enabled_cvar,1)
  181.                 client_print(0,print_chat,"[AMXX] Admin has enabled Hook for all clients. Use: bind key +hook")
  182.             }
  183.             else
  184.             {
  185.                 set_pcvar_num(hook_enabled_cvar,0)
  186.                 client_print(0,print_chat,"[AMXX] Admin has disabled Hook for all non-admins.")
  187.             }
  188.             show_ghr(id)
  189.         }
  190.         case 2:
  191.         {
  192.             if(get_pcvar_num(rope_enabled_cvar)==0)
  193.             {
  194.                 set_pcvar_num(rope_enabled_cvar,1)
  195.                 client_print(0,print_chat,"[AMXX] Admin has enabled Rope for all clients. Use: bind key +rope")
  196.             }
  197.             else
  198.             {
  199.                 set_pcvar_num(rope_enabled_cvar,0)
  200.                 client_print(0,print_chat,"[AMXX] Admin has disabled Rope for all non-admins.")
  201.             }
  202.             show_ghr(id)
  203.         }
  204.     }
  205. }
  206.  
  207.  
  208. /****************
  209.  Handle Commands
  210. ****************/
  211.  
  212. public cmd_givetake(id,level,cid)
  213. {
  214.     if(!cmd_access(id,level,cid,2))
  215.     {
  216.         return PLUGIN_HANDLED
  217.     }
  218.  
  219.     new arg1[32]
  220.     read_argv(1,arg1,31)
  221.  
  222.     new target = cmd_target(id,arg1,9)
  223.     if(!target)
  224.     {
  225.         return PLUGIN_HANDLED
  226.     }
  227.  
  228.     new name[32]
  229.     get_user_name(target,name,31)
  230.     if(get_user_flags(target) & ADMIN_LEVEL_Q)
  231.     {
  232.         console_print(id,"[AMXX] Cannot give/take grab/hook/rope from admin %s.",name)
  233.         return PLUGIN_HANDLED
  234.     }
  235.  
  236.     new arg0[32]
  237.     read_argv(0,arg0,31)
  238.     if(containi(arg0,"give")!=-1)
  239.     {
  240.         if(containi(arg0,"grab")!=-1)
  241.         {
  242.             if(has_grab[target])
  243.             {
  244.                 console_print(id,"[AMXX] %s already has grab",name)
  245.             }
  246.             else
  247.             {
  248.                 has_grab[target]=true
  249.                 console_print(id,"[AMXX] %s has been given grab",name)
  250.                 client_print(target,print_chat,"[AMXX] An admin has given you grab. Use: bind key +grab")
  251.             }
  252.         }
  253.         else if(containi(arg0,"hook")!=-1)
  254.         {
  255.             if(has_hook[target])
  256.             {
  257.                 console_print(id,"[AMXX] %s already has hook",name)
  258.             }
  259.             else
  260.             {
  261.                 has_hook[target]=true
  262.                 console_print(id,"[AMXX] %s has been given hook",name)
  263.                 client_print(target,print_chat,"[AMXX] An admin has given you hook. Use: bind key +hook")
  264.             }
  265.         }
  266.         else if(containi(arg0,"rope")!=-1)
  267.         {
  268.             if(has_rope[target])
  269.             {
  270.                 console_print(id,"[AMXX] %s already has rope",name)
  271.             }
  272.             else
  273.             {
  274.                 has_rope[target]=true
  275.                 console_print(id,"[AMXX] %s has been given rope",name)
  276.                 client_print(target,print_chat,"[AMXX] An admin has given you hook. Use: bind key +rope")
  277.             }
  278.         }
  279.     }
  280.     if(containi(arg0,"take")!=-1)
  281.     {
  282.         if(containi(arg0,"grab")!=-1)
  283.         {
  284.             if(!has_grab[target])
  285.             {
  286.                 console_print(id,"[AMXX] %s doesn't have grab",name)
  287.             }
  288.             else
  289.             {
  290.                 has_grab[target]=false
  291.                 console_print(id,"[AMXX] %s's grab has been taken away.",name)
  292.                 client_print(target,print_chat,"[AMXX] An admin has taken your grab away.")
  293.             }
  294.         }
  295.         if(containi(arg0,"hook")!=-1)
  296.         {
  297.             if(!has_hook[target])
  298.             {
  299.                 console_print(id,"[AMXX] %s doesn't have hook",name)
  300.             }
  301.             else
  302.             {
  303.                 has_hook[target]=false
  304.                 console_print(id,"[AMXX] %s's hook has been taken away.",name)
  305.                 client_print(target,print_chat,"[AMXX] An admin has taken your hook away.")
  306.             }
  307.         }
  308.         if(containi(arg0,"rope")!=-1)
  309.         {
  310.             if(!has_rope[target])
  311.             {
  312.                 console_print(id,"[AMXX] %s doesn't have rope",name)
  313.             }
  314.             else
  315.             {
  316.                 has_rope[target]=false
  317.                 console_print(id,"[AMXX] %s's rope has been taken away.",name)
  318.                 client_print(target,print_chat,"[AMXX] An admin has taken your rope away.")
  319.             }
  320.         }
  321.     }
  322.     return PLUGIN_HANDLED
  323. }
  324.  
  325.  
  326. /*****
  327.  Grab
  328. *****/
  329.  
  330. public grab_toggle(id,level,cid)
  331. {
  332.     if(grab[id]) grab_off(id)
  333.     else grab_on(id,level,cid)
  334.     return PLUGIN_HANDLED
  335. }
  336.  
  337. public grab_on(id,level,cid)
  338. {
  339.     if(is_user_alive(id))
  340.     {
  341.         if(!has_grab[id] && !get_pcvar_num(grab_enabled_cvar))
  342.         {
  343.             if(!cmd_access(id,level,cid,1))
  344.                 client_print(id,    print_chat, "NU ESTI VIP")
  345.             return PLUGIN_HANDLED
  346.         }
  347.         if(grab[id])
  348.         {
  349.             return PLUGIN_HANDLED
  350.         }
  351.     /*  if(!cmd_access(id, level, cid, 1)) {
  352.             client_print(id,    print_chat, "NU ESTI VIP")
  353.             return PLUGIN_HANDLED
  354.         }*/
  355.         grab[id]=-1
  356.         static target, trash
  357.         target=0
  358.         get_user_aiming(id,target,trash)
  359.         if(target && is_valid_ent2(target) && target!=id)
  360.         {
  361.             if(target<=maxplayers)
  362.             {
  363.                 if(is_user_alive(target) && !(get_user_flags(target) & ADMIN_IMMUNITY))
  364.                 {
  365.                     client_print(id,print_chat,"[AMXX] Found Target")
  366.                     grabem(id,target)
  367.                 }
  368.             }
  369.             else if(get_solidity(target)!=4)
  370.             {
  371.                 client_print(id,print_chat,"[AMXX] Found Target")
  372.                 grabem(id,target)
  373.             }
  374.         }
  375.         else
  376.         {
  377.             client_print(id,print_chat,"[AMXX] Searching for Target")
  378.             set_task(0.1,"grab_on2",id)
  379.         }
  380.     }
  381.     else
  382.         client_print(id,    print_chat, "Poti folosi comanda doar cand esti viu.")
  383.     return PLUGIN_HANDLED
  384. }
  385.  
  386. public grab_on2(id)
  387. {
  388.     if(is_user_connected(id))
  389.     {
  390.         static target, trash
  391.         target=0
  392.         get_user_aiming(id,target,trash)
  393.         if(target && is_valid_ent2(target) && target!=id)
  394.         {
  395.             if(target<=maxplayers)
  396.             {
  397.                 if(is_user_alive(target) && !(get_user_flags(target) & ADMIN_IMMUNITY))
  398.                 {
  399.                     client_print(id,print_chat,"[AMXX] Found Target")
  400.                     grabem(id,target)
  401.                 }
  402.             }
  403.             else if(get_solidity(target)!=4)
  404.             {
  405.                 client_print(id,print_chat,"[AMXX] Found Target")
  406.                 grabem(id,target)
  407.             }
  408.         }
  409.         else
  410.         {
  411.             set_task(0.1,"grab_on2",id)
  412.         }
  413.     }
  414. }
  415.  
  416. public grabem(id,target)
  417. {
  418.     grab[id]=target
  419.     set_rendering2(target,kRenderFxGlowShell,255,0,0,kRenderTransAlpha,70)
  420.     if(target<=maxplayers) set_user_gravity(target,0.0)
  421.     grab_totaldis[id] = 0.0
  422.     set_task(0.1,"grab_prethink",id+1000,"",0,"b")
  423.     grab_prethink(id+1000)
  424.     emit_sound(id,CHAN_VOICE,"weapons/zoom.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  425. }
  426.  
  427. public grab_off(id)
  428. {
  429.     if(is_user_connected(id))
  430.     {
  431.         if(grab[id]==-1)
  432.         {
  433.             client_print(id,print_chat,"[AMXX] No Target Found")
  434.             grab[id]=0
  435.         }
  436.         else if(grab[id])
  437.         {
  438.             client_print(id,print_chat,"[AMXX] Target Released")
  439.             set_rendering2(grab[id])
  440.             if(grab[id]<=maxplayers && is_user_alive(grab[id])) set_user_gravity(grab[id],1.0)
  441.             grab[id]=0
  442.         }
  443.     }
  444.     return PLUGIN_HANDLED
  445. }
  446.  
  447. public grab_prethink(id)
  448. {
  449.     id -= 1000
  450.     if(!is_user_connected(id) && grab[id]>0)
  451.     {
  452.         set_rendering2(grab[id])
  453.         if(grab[id]<=maxplayers && is_user_alive(grab[id])) set_user_gravity(grab[id],1.0)
  454.         grab[id]=0
  455.     }
  456.     if(!grab[id] || grab[id]==-1)
  457.     {
  458.         remove_task(id+1000)
  459.         return PLUGIN_HANDLED
  460.     }
  461.  
  462.     //Get Id's, target's, and Where Id is looking's origins
  463.     static origin1[3]
  464.     get_user_origin(id,origin1)
  465.     static Float:origin2_F[3], origin2[3]
  466.     get_origin(grab[id],origin2_F)
  467.     origin2[0] = floatround(origin2_F[0])
  468.     origin2[1] = floatround(origin2_F[1])
  469.     origin2[2] = floatround(origin2_F[2])
  470.     static origin3[3]
  471.     get_user_origin(id,origin3,3)
  472.  
  473.     //Create red beam
  474.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  475.     write_byte(1)       //TE_BEAMENTPOINT
  476.     write_short(id)     // start entity
  477.     write_coord(origin2[0])
  478.     write_coord(origin2[1])
  479.     write_coord(origin2[2])
  480.     write_short(beamsprite)
  481.     write_byte(1)       // framestart
  482.     write_byte(1)       // framerate
  483.     write_byte(1)       // life in 0.1's
  484.     write_byte(5)       // width
  485.     write_byte(0)       // noise
  486.     write_byte(255)     // red
  487.     write_byte(0)       // green
  488.     write_byte(0)       // blue
  489.     write_byte(255)     // brightness
  490.     write_byte(0)       // speed
  491.     message_end()
  492.  
  493.     //Convert to floats for calculation
  494.     static Float:origin1_F[3]
  495.     static Float:origin3_F[3]
  496.     origin1_F[0] = float(origin1[0])
  497.     origin1_F[1] = float(origin1[1])
  498.     origin1_F[2] = float(origin1[2])
  499.     origin3_F[0] = float(origin3[0])
  500.     origin3_F[1] = float(origin3[1])
  501.     origin3_F[2] = float(origin3[2])
  502.  
  503.     //Calculate target's new velocity
  504.     static Float:distance[3]
  505.  
  506.     if(!grab_totaldis[id])
  507.     {
  508.         distance[0] = floatabs(origin1_F[0] - origin2_F[0])
  509.         distance[1] = floatabs(origin1_F[1] - origin2_F[1])
  510.         distance[2] = floatabs(origin1_F[2] - origin2_F[2])
  511.         grab_totaldis[id] = floatsqroot(distance[0]*distance[0] + distance[1]*distance[1] + distance[2]*distance[2])
  512.     }
  513.     distance[0] = origin3_F[0] - origin1_F[0]
  514.     distance[1] = origin3_F[1] - origin1_F[1]
  515.     distance[2] = origin3_F[2] - origin1_F[2]
  516.  
  517.     static Float:grab_totaldis2
  518.     grab_totaldis2 = floatsqroot(distance[0]*distance[0] + distance[1]*distance[1] + distance[2]*distance[2])
  519.  
  520.     static Float:que
  521.     que = grab_totaldis[id] / grab_totaldis2
  522.  
  523.     static Float:origin4[3]
  524.     origin4[0] = ( distance[0] * que ) + origin1_F[0]
  525.     origin4[1] = ( distance[1] * que ) + origin1_F[1]
  526.     origin4[2] = ( distance[2] * que ) + origin1_F[2]
  527.  
  528.     static Float:velocity[3]
  529.     velocity[0] = (origin4[0] - origin2_F[0]) * (get_pcvar_float(grab_speed_cvar) / 1.666667)
  530.     velocity[1] = (origin4[1] - origin2_F[1]) * (get_pcvar_float(grab_speed_cvar) / 1.666667)
  531.     velocity[2] = (origin4[2] - origin2_F[2]) * (get_pcvar_float(grab_speed_cvar) / 1.666667)
  532.  
  533.     set_velo(grab[id],velocity)
  534.  
  535.     return PLUGIN_CONTINUE
  536. }
  537.  
  538.  
  539. /*****
  540.  Hook
  541. *****/
  542.  
  543. public hook_toggle(id,level,cid)
  544. {
  545.     if(hook[id]) hook_off(id)
  546.     else hook_on(id,level,cid)
  547.     return PLUGIN_HANDLED
  548. }
  549.  
  550. public hook_on(id,level,cid)
  551. {
  552.     if(is_user_alive(id))
  553.     {
  554.         if(cmd_access(id,level,cid,1))
  555.         {
  556.             if(!has_hook[id] && !get_pcvar_num(hook_enabled_cvar))
  557.             {
  558.                 return PLUGIN_HANDLED
  559.             }
  560.             if(hook[id])
  561.             {
  562.                 return PLUGIN_HANDLED
  563.             }
  564.             set_user_gravity(id,0.0)
  565.             set_task(0.1,"hook_prethink",id+10000,"",0,"b")
  566.             hook[id]=true
  567.             hook_to[id][0]=999999
  568.             hook_prethink(id+10000)
  569.             emit_sound(id,CHAN_VOICE,"weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  570.         }
  571.         else
  572.             client_print(id,    print_chat, "NU ESTI VIP")
  573.     }
  574.     else
  575.         client_print(id,    print_chat, "Poti folosi comanda doar cand esti viu.")
  576.     return PLUGIN_HANDLED
  577. }
  578.  
  579. public hook_off(id)
  580. {
  581.     if(is_user_alive(id)) set_user_gravity(id)
  582.     hook[id]=false
  583.     return PLUGIN_HANDLED
  584. }
  585.  
  586. public hook_prethink(id)
  587. {
  588.     id -= 10000
  589.     if(!is_user_alive(id))
  590.     {
  591.         hook[id]=false
  592.     }
  593.     if(!hook[id])
  594.     {
  595.         remove_task(id+10000)
  596.         return PLUGIN_HANDLED
  597.     }
  598.  
  599.     //Get Id's origin
  600.     static origin1[3]
  601.     get_user_origin(id,origin1)
  602.  
  603.     if(hook_to[id][0]==999999)
  604.     {
  605.         static origin2[3]
  606.         get_user_origin(id,origin2,3)
  607.         hook_to[id][0]=origin2[0]
  608.         hook_to[id][1]=origin2[1]
  609.         hook_to[id][2]=origin2[2]
  610.     }
  611.  
  612.     //Create blue beam
  613.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  614.     write_byte(1)       //TE_BEAMENTPOINT
  615.     write_short(id)     // start entity
  616.     write_coord(hook_to[id][0])
  617.     write_coord(hook_to[id][1])
  618.     write_coord(hook_to[id][2])
  619.     write_short(beamsprite)
  620.     write_byte(1)       // framestart
  621.     write_byte(1)       // framerate
  622.     write_byte(2)       // life in 0.1's
  623.     write_byte(5)       // width
  624.     write_byte(0)       // noise
  625.     write_byte(255)     // red
  626.     write_byte(255)     // green
  627.     write_byte(0)       // blue
  628.     write_byte(255)     // brightness
  629.     write_byte(0)       // speed
  630.     message_end()
  631.  
  632.     //Calculate Velocity
  633.     static Float:velocity[3]
  634.     velocity[0] = (float(hook_to[id][0]) - float(origin1[0])) * 3.0
  635.     velocity[1] = (float(hook_to[id][1]) - float(origin1[1])) * 3.0
  636.     velocity[2] = (float(hook_to[id][2]) - float(origin1[2])) * 3.0
  637.  
  638.     static Float:y
  639.     y = velocity[0]*velocity[0] + velocity[1]*velocity[1] + velocity[2]*velocity[2]
  640.  
  641.     static Float:x
  642.     x = (get_pcvar_float(hook_speed_cvar) * 120.0) / floatsqroot(y)
  643.  
  644.     velocity[0] *= x
  645.     velocity[1] *= x
  646.     velocity[2] *= x
  647.  
  648.     set_velo(id,velocity)
  649.  
  650.     return PLUGIN_CONTINUE
  651. }
  652.  
  653.  
  654. /*****
  655.  Rope
  656. *****/
  657.  
  658. public rope_toggle(id,level,cid)
  659. {
  660.         if(rope[id])
  661.             rope_off(id)
  662.         else
  663.             rope_on(id,level,cid)
  664. }
  665.  
  666. public rope_on(id,level,cid)
  667. {
  668.     if(is_user_alive(id))
  669.     {
  670.         if(!has_rope[id] && !get_pcvar_num(rope_enabled_cvar) && !cmd_access(id,level,cid,1))
  671.         {
  672.             return PLUGIN_HANDLED
  673.         }
  674.         if(rope[id])
  675.         {
  676.             return PLUGIN_HANDLED
  677.         }
  678.         set_task(0.1,"rope_prethink",id+100000,"",0,"b")
  679.         rope[id]=true
  680.         rope_to[id][0]=999999
  681.         rope_prethink(id+100000)
  682.         emit_sound(id,CHAN_VOICE,"weapons/zoom.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  683.     }
  684.     else
  685.         client_print(id,    print_chat, "POTI FOLOSI COMANDA DOAR CAND ESTI VIU!")
  686.     return PLUGIN_HANDLED
  687. }
  688.  
  689. public rope_off(id)
  690. {
  691.     rope[id]=false
  692.     return PLUGIN_HANDLED
  693. }
  694.  
  695. public rope_prethink(id)
  696. {
  697.     id -= 100000
  698.     if(!is_user_alive(id))
  699.     {
  700.         rope[id]=false
  701.     }
  702.     if(!rope[id])
  703.     {
  704.         remove_task(id+100000)
  705.         return PLUGIN_HANDLED
  706.     }
  707.  
  708.     //Get Id's origin
  709.     static origin1[3]
  710.     get_user_origin(id,origin1)
  711.  
  712.     static Float:origin1_F[3]
  713.     origin1_F[0] = float(origin1[0])
  714.     origin1_F[1] = float(origin1[1])
  715.     origin1_F[2] = float(origin1[2])
  716.  
  717.     //Check to see if this is the first time prethink is being run
  718.     if(rope_to[id][0]==999999)
  719.     {
  720.         static origin2[3]
  721.         get_user_origin(id,origin2,3)
  722.         rope_to[id][0]=origin2[0]
  723.         rope_to[id][1]=origin2[1]
  724.         rope_to[id][2]=origin2[2]
  725.  
  726.         static Float:origin2_F[3]
  727.         origin2_F[0] = float(origin2[0])
  728.         origin2_F[1] = float(origin2[1])
  729.         origin2_F[2] = float(origin2[2])
  730.  
  731.         static Float:distance[3]
  732.         distance[0] = floatabs(origin1_F[0] - origin2_F[0])
  733.         distance[1] = floatabs(origin1_F[1] - origin2_F[1])
  734.         distance[2] = floatabs(origin1_F[2] - origin2_F[2])
  735.         rope_totaldis[id] = floatsqroot(distance[0]*distance[0] + distance[1]*distance[1] + distance[2]*distance[2])
  736.     }
  737.  
  738.     //Create green beam
  739.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  740.     write_byte(1)       //TE_BEAMENTPOINT
  741.     write_short(id)     // start entity
  742.     write_coord(rope_to[id][0])
  743.     write_coord(rope_to[id][1])
  744.     write_coord(rope_to[id][2])
  745.     write_short(beamsprite)
  746.     write_byte(170)     // framestart
  747.     write_byte(100)     // framerate
  748.     write_byte(1)       // life in 0.1's
  749.     write_byte(5)       // width
  750.     write_byte(30)      // noise
  751.     write_byte(random(255))     // red
  752.     write_byte(random(255))     // green
  753.     write_byte(random(255))     // blue
  754.     write_byte(255)     // brightness
  755.     write_byte(0)       // speed
  756.     message_end()
  757.  
  758.     //Calculate Velocity
  759.     static Float:velocity[3]
  760.     get_velo(id,velocity)
  761.  
  762.     static Float:velocity2[3]
  763.     velocity2[0] = (rope_to[id][0] - origin1_F[0]) * 3.0
  764.     velocity2[1] = (rope_to[id][1] - origin1_F[1]) * 3.0
  765.  
  766.     static Float:y
  767.     y = velocity2[0]*velocity2[0] + velocity2[1]*velocity2[1]
  768.  
  769.     static Float:x
  770.     x = (get_pcvar_float(rope_speed_cvar) * 20.0) / floatsqroot(y)
  771.  
  772.     velocity[0] += velocity2[0]*x
  773.     velocity[1] += velocity2[1]*x
  774.  
  775.     if(rope_to[id][2] - origin1_F[2] >= rope_totaldis[id] && velocity[2]<0.0) velocity[2] *= -1
  776.  
  777.     set_velo(id,velocity)
  778.  
  779.     return PLUGIN_CONTINUE
  780. }
  781.  
  782. public get_origin(ent,Float:origin[3])
  783. {
  784. #if defined engine
  785.     return entity_get_vector(id,EV_VEC_origin,origin)
  786. #else
  787.     return pev(ent,pev_origin,origin)
  788. #endif
  789. }
  790.  
  791. public set_velo(id,Float:velocity[3])
  792. {
  793. #if defined engine
  794.     return set_user_velocity(id,velocity)
  795. #else
  796.     return set_pev(id,pev_velocity,velocity)
  797. #endif
  798. }
  799.  
  800. public get_velo(id,Float:velocity[3])
  801. {
  802. #if defined engine
  803.     return get_user_velocity(id,velocity)
  804. #else
  805.     return pev(id,pev_velocity,velocity)
  806. #endif
  807. }
  808.  
  809. public is_valid_ent2(ent)
  810. {
  811. #if defined engine
  812.     return is_valid_ent(ent)
  813. #else
  814.     return pev_valid(ent)
  815. #endif
  816. }
  817.  
  818. public get_solidity(ent)
  819. {
  820. #if defined engine
  821.     return entity_get_int(ent,EV_INT_solid)
  822. #else
  823.     return pev(ent,pev_solid)
  824. #endif
  825. }
  826.  
  827. stock set_rendering2(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
  828. {
  829. #if defined engine
  830.     return set_rendering(index,fx,r,g,b,render,amount)
  831. #else
  832.     set_pev(index, pev_renderfx, fx);
  833.     new Float:RenderColor[3];
  834.     RenderColor[0] = float(r);
  835.     RenderColor[1] = float(g);
  836.     RenderColor[2] = float(b);
  837.     set_pev(index, pev_rendercolor, RenderColor);
  838.     set_pev(index, pev_rendermode, render);
  839.     set_pev(index, pev_renderamt, float(amount));
  840.     return 1;
  841. #endif
  842. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top