hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.06.16. 14:41



Jelenlévő felhasználók

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

A legtöbb felhasználó (2761 fő) 2025.01.09. 20:06-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], Google [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  [10 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Hook
HozzászólásElküldve:2012.05.13. 16:56 
Offline
Jómunkásember

Csatlakozott:2011.07.14. 11:12
Hozzászólások:320
Megköszönt másnak: 1 alkalommal
Helló pls valaki írja már át ezt a plugint:

Kód:
/**************************************************************************************************
 
**** CVARS (FEATURES) ****
sv_adminhook         = Turn Plugin On/off
**** ADMIN COMMANDS ****
ADMIN_LEVEL_A (flag="m")
Granting Hook/Rope   = amx_granthook <authid, nick, @team, @all or #userid> <on/off>
 
ADMIN_LEVEL_E (flag="q") || Granted by admin
Ninja Rope by Spacedude (slightly modified) & Hook thingy
Attaching Rope         = +rope
Deattaching Rope      = -rope
Attaching Hook         = +hook
Deattaching Hook      = -hook
 
**************************************************************************************************/
#define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX
 
#if USING_AMX
   #include <amxmod>
   #include <amxmisc>
   #include <VexdUM>
   #include <fun>
   new gModName[32] = "AMX"
#else
   #include <amxmodx>
   #include <amxmisc>
   #include <fun>
   #include <engine>
   new gModName[32] = "AMXX"
#endif
 
#define TE_BEAMENTPOINT 1
#define TE_KILLBEAM 99
#define DELTA_T 0.1            // seconds
#define BEAMLIFE 100         // deciseconds
#define MOVEACCELERATION 150   // units per second^2
#define REELSPEED 300         // units per second
 
/* Hook Stuff */
new gHookLocation[33][3]
new gHookLenght[33]
new bool:gIsHooked[33]
new gAllowedHook[33]
new Float:gBeamIsCreated[33]
new global_gravity
new beam
 
/************************************************************************************************************************/
public plugin_init() //Called on plugin start
{
   // Plugin Info
   register_plugin("Admin Hook","1.0","AssKicR")
 
   //CVARS
   register_cvar("sv_adminhook", "1" )
 
   //ADMIN CMDS
   register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
 
   //USER COMMANDS
   register_clcmd("+rope", "hook_on",ADMIN_LEVEL_E)
   register_clcmd("-rope", "hook_off",ADMIN_LEVEL_E)
   register_clcmd("+hook", "hook_on",ADMIN_LEVEL_E)
   register_clcmd("-hook", "hook_off",ADMIN_LEVEL_E)
 
   //HOOKED EVENTS
   register_event("ResetHUD", "ResetHUD", "b")
}
/************************************************************************************************************************/
public plugin_precache()
{
   beam = precache_model("sprites/zbeam4.spr")
   precache_sound("weapons/xbow_hit2.wav")
}
/*************************************************************************************************************************/
/************************************************** USP/SCOUT REMOVE *****************************************************/
/*************************************************************************************************************************/
 
/*************************************************************************************************************************/
/**************************************************** HOOKED EVENTS ******************************************************/
/*************************************************************************************************************************/
public ResetHUD(id) {
   //Check if he is hooked to something
   if (gIsHooked[id]) RopeRelease(id)
}
/************************************************************************************************************************/
stock kz_velocity_set(id,vel[3]) {
   //Set Their Velocity to 0 so that they they fall straight down from
   new Float:Ivel[3]
   Ivel[0]=float(vel[0])
   Ivel[1]=float(vel[1])
   Ivel[2]=float(vel[2])
   entity_set_vector(id, EV_VEC_velocity, Ivel)
}
 
stock kz_velocity_get(id,vel[3]) {
   //Set Their Velocity to 0 so that they they fall straight down from
   new Float:Ivel[3]
 
   entity_get_vector(id, EV_VEC_velocity, Ivel)
   vel[0]=floatround(Ivel[0])
   vel[1]=floatround(Ivel[1])
   vel[2]=floatround(Ivel[2])
}
 
/************************************************************************************************************************/
/**************************************************** ADMIN COMMANDS ****************************************************/
/************************************************************************************************************************/
public AdminGrantHook(id,level,cid)
{
   if ( !cmd_access(id,level,cid,1) )
      return PLUGIN_HANDLED
 
   new arg1[32],arg2[32]
   read_argv(1,arg1,31)
   read_argv(2,arg2,31)
   new onoff = str_to_num(arg2)
 
   if ( equali(arg1,"@all") )
   {
      new plist[32],pnum
      get_players(plist,pnum,"a")
      if (pnum==0)
      {
       console_print(id,"[%s] There are no clients",gModName)
       return PLUGIN_HANDLED
      }
      for (new i=0; i<pnum; i++) {
         gAllowedHook[plist[i]]=onoff
         if (gIsHooked[plist[i]]==true && onoff==0)
         {
            RopeRelease(plist[i])
         }
      }
 
      console_print(id,"[%s] %s all players access to hook/rope",gModName,onoff ? "Gave":"Removed")
   }
   else if ( arg1[0]=='@' )
   {
      new plist[32],pnum
      get_players(plist,pnum,"ae",arg1[1])
      if ( pnum==0 )
      {
       console_print(id,"[%s] No clients in such team",gModName)
       return PLUGIN_HANDLED
      }
      for (new i=0; i<pnum; i++) {
         gAllowedHook[plist[i]]=onoff
         if (gIsHooked[plist[i]]==true && onoff==0)
         {
            RopeRelease(plist[i])
         }
      }
      console_print(id,"[%s] %s all %ss access to hook/rope",onoff ? "Gave":"Removed",arg1[1])
   }
   else
   {
      new pName[32]
      new player = cmd_target(id,arg1,6)
      if (!player) return PLUGIN_HANDLED
 
      gAllowedHook[player]=onoff
      if (gAllowedHook[player]==0 && onoff==0)
      {
         RopeRelease(player)
      }
 
 
      get_user_name(player,pName,31)
      console_print(id,"[%s] %s ^"%s^" access to hook/rope",onoff ? "Gave":"Removed",pName)
   }
 
   return PLUGIN_HANDLED
}
 
/************************************************************************************************************************/
/****************************************************** NINJAROPE *******************************************************/
/************************************************************************************************************************/
 
public ropetask(parm[])
{
   new id = parm[0]
   new user_origin[3], user_look[3], user_direction[3], move_direction[3]
   new A[3], D[3], buttonadjust[3]
   new acceleration, velocity_towards_A, desired_velocity_towards_A
   new velocity[3], null[3]
 
   if (!is_user_alive(id))
   {
      RopeRelease(id)
      return
   }
 
   if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
   {
      beamentpoint(id)
   }
 
   null[0] = 0
   null[1] = 0
   null[2] = 0
 
   get_user_origin(id, user_origin)
   get_user_origin(id, user_look,2)
   kz_velocity_get(id, velocity)
 
   buttonadjust[0]=0
   buttonadjust[1]=0
 
   if (get_user_button(id)&IN_FORWARD)      buttonadjust[0]+=1
   if (get_user_button(id)&IN_BACK)      buttonadjust[0]-=1
   if (get_user_button(id)&IN_MOVERIGHT)   buttonadjust[1]+=1
   if (get_user_button(id)&IN_MOVELEFT)   buttonadjust[1]-=1
   if (get_user_button(id)&IN_JUMP)      buttonadjust[2]+=1
   if (get_user_button(id)&IN_DUCK)      buttonadjust[2]-=1
 
   if (buttonadjust[0] || buttonadjust[1])
   {
      user_direction[0] = user_look[0] - user_origin[0]
      user_direction[1] = user_look[1] - user_origin[1]
 
      move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]
      move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]
      move_direction[2] = 0
 
      velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
      velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
   }
 
   if (buttonadjust[2])   gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)
   if (gHookLenght[id] < 100) gHookLenght[id] = 100
 
   A[0] = gHookLocation[id][0] - user_origin[0]
   A[1] = gHookLocation[id][1] - user_origin[1]
   A[2] = gHookLocation[id][2] - user_origin[2]
 
   D[0] = A[0]*A[2] / get_distance(null,A)
   D[1] = A[1]*A[2] / get_distance(null,A)
   D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)
 
   acceleration = - global_gravity * D[2] / get_distance(null,D)
 
   velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)
   desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4
 
   if (get_distance(null,D)>10)
   {
      velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))
      velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))
      velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))
   }
 
   velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)
   velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)
   velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)
 
   kz_velocity_set(id, velocity)
}
 
public hooktask(parm[])
{
   new id = parm[0]
   new velocity[3]
 
   if ( !gIsHooked[id] ) return
 
   new user_origin[3],oldvelocity[3]
   parm[0] = id
 
   if (!is_user_alive(id))
   {
      RopeRelease(id)
      return
   }
 
   if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
   {
      beamentpoint(id)
   }
 
   get_user_origin(id, user_origin)
   kz_velocity_get(id, oldvelocity)
   new distance=get_distance( gHookLocation[id], user_origin )
   if ( distance > 10 )
   {
      velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )
      velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )
      velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )
   }
   else
   {
      velocity[0]=0
      velocity[1]=0
      velocity[2]=0
   }
 
   kz_velocity_set(id, velocity)
 
}
 
public hook_on(id)
{
   if (get_cvar_num("sv_adminhook")==1)
      {
      if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E)) {
         if (!gIsHooked[id] && is_user_alive(id))
         {
            new cmd[32]
            read_argv(0,cmd,31)
            if(equal(cmd,"+rope")) RopeAttach(id,0)
            if(equal(cmd,"+hook")) RopeAttach(id,1)
         }
      }else{
         client_print(id,print_chat,"[%s] Nincs elerhetoseged hozza",gModName)
         return PLUGIN_HANDLED
      }
   }else{
      client_print(id,print_chat,"[%s] Ez a parancs ki van kapcsolva",gModName)
   }
   return PLUGIN_HANDLED
}
 
public hook_off(id)
{
   if (gAllowedHook[id] || (get_user_flags(id)&ADMIN_LEVEL_E)) {
      if (gIsHooked[id])
      {
         RopeRelease(id)
      }
   }else{
      client_print(id,print_chat,"[%s] Nincs elerhetoseged hozza",gModName)
      return PLUGIN_HANDLED
   }
   return PLUGIN_HANDLED
}
 
public RopeAttach(id,hook)
{
   new parm[1], user_origin[3]
   parm[0] = id
   gIsHooked[id] = true
   get_user_origin(id,user_origin)
   get_user_origin(id,gHookLocation[id], 3)
   gHookLenght[id] = get_distance(gHookLocation[id],user_origin)
   global_gravity = get_cvar_num("sv_gravity")
   set_user_gravity(id,0.001)
   beamentpoint(id)
   emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
   if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")
   else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")
}
 
public RopeRelease(id)
{
   gIsHooked[id] = false
   killbeam(id)
   set_user_gravity(id)
   remove_task(200+id)
}
 
public beamentpoint(id)
{
   message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
   write_byte( TE_BEAMENTPOINT )
   write_short( id )
   write_coord( gHookLocation[id][0] )
   write_coord( gHookLocation[id][1] )
   write_coord( gHookLocation[id][2] )
   write_short( beam )   // sprite index
   write_byte( 0 )      // start frame
   write_byte( 0 )      // framerate
   write_byte( BEAMLIFE )   // life
   write_byte( 10 )   // width
   write_byte( 0 )      // noise
   if (get_user_team(id)==1)      // Terrorist
   {
      write_byte( 255 )   // r, g, b
      write_byte( 0 )   // r, g, b
      write_byte( 0 )   // r, g, b
   }
   else                     // Counter-Terrorist
   {
      write_byte( 0 )   // r, g, b
      write_byte( 0 )   // r, g, b
      write_byte( 255 )   // r, g, b
   }
   write_byte( 150 )   // brightness
   write_byte( 0 )      // speed
   message_end( )
   gBeamIsCreated[id] = get_gametime()
}
 
public killbeam(id)
{
   message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
   write_byte( TE_KILLBEAM )
   write_short( id )
   message_end()
}
 
/************************************************************************************************************************/
/******************************************************* FORWARDS *******************************************************/
/************************************************************************************************************************/
 
public client_disconnect(id) {
   gAllowedHook[id]=0
}
 
/************************************************************************************************************************/
/************************************************** AMXX -> AMX funcs ***************************************************/
/************************************************************************************************************************/
#if USING_AMX
   stock get_user_button(id) return entity_get_int(id, EV_INT_button)
#endif


úgy hogy minden player tudja használni ne csak az adminok..............

Előre is thx.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Hook
HozzászólásElküldve:2012.05.13. 18:02 
Offline
Signore Senior
Avatar

Csatlakozott:2011.09.09. 17:39
Hozzászólások:4020
Megköszönt másnak: 12 alkalommal
Megköszönték neki: 139 alkalommal
Kód:
  1.  

  2. /**************************************************************************************************

  3.  

  4. **** CVARS (FEATURES) ****

  5. sv_adminhook         = Turn Plugin On/off

  6. **** ADMIN COMMANDS ****

  7. ADMIN_LEVEL_A (flag="m")

  8. Granting Hook/Rope   = amx_granthook <authid, nick, @team, @all or #userid> <on/off>

  9.  

  10. ADMIN_LEVEL_E (flag="q") || Granted by admin

  11. Ninja Rope by Spacedude (slightly modified) & Hook thingy

  12. Attaching Rope         = +rope

  13. Deattaching Rope      = -rope

  14. Attaching Hook         = +hook

  15. Deattaching Hook      = -hook

  16.  

  17. **************************************************************************************************/

  18. #define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX

  19.  

  20. #if USING_AMX

  21.    #include <amxmod>

  22.    #include <amxmisc>

  23.    #include <VexdUM>

  24.    #include <fun>

  25.    new gModName[32] = "AMX"

  26. #else

  27.    #include <amxmodx>

  28.    #include <amxmisc>

  29.    #include <fun>

  30.    #include <engine>

  31.    new gModName[32] = "AMXX"

  32. #endif

  33.  

  34. #define TE_BEAMENTPOINT 1

  35. #define TE_KILLBEAM 99

  36. #define DELTA_T 0.1            // seconds

  37. #define BEAMLIFE 100         // deciseconds

  38. #define MOVEACCELERATION 150   // units per second^2

  39. #define REELSPEED 300         // units per second

  40.  

  41. /* Hook Stuff */

  42. new gHookLocation[33][3]

  43. new gHookLenght[33]

  44. new bool:gIsHooked[33]

  45. new gAllowedHook[33]

  46. new Float:gBeamIsCreated[33]

  47. new global_gravity

  48. new beam

  49.  

  50. /************************************************************************************************************************/

  51. public plugin_init() //Called on plugin start

  52. {

  53.    // Plugin Info

  54.    register_plugin("Admin Hook","1.0","AssKicR")

  55.  

  56.    //CVARS

  57.    register_cvar("sv_adminhook", "1" )

  58.  

  59.    //ADMIN CMDS

  60.    register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")

  61.  

  62.    //USER COMMANDS

  63.    register_clcmd("+rope", "hook_on")

  64.    register_clcmd("-rope", "hook_off")

  65.    register_clcmd("+hook", "hook_on")

  66.    register_clcmd("-hook", "hook_off")

  67.  

  68.    //HOOKED EVENTS

  69.    register_event("ResetHUD", "ResetHUD", "b")

  70. }

  71. /************************************************************************************************************************/

  72. public plugin_precache()

  73. {

  74.    beam = precache_model("sprites/zbeam4.spr")

  75.    precache_sound("weapons/xbow_hit2.wav")

  76. }

  77. /*************************************************************************************************************************/

  78. /************************************************** USP/SCOUT REMOVE *****************************************************/

  79. /*************************************************************************************************************************/

  80.  

  81. /*************************************************************************************************************************/

  82. /**************************************************** HOOKED EVENTS ******************************************************/

  83. /*************************************************************************************************************************/

  84. public ResetHUD(id) {

  85.    //Check if he is hooked to something

  86.    if (gIsHooked[id]) RopeRelease(id)

  87. }

  88. /************************************************************************************************************************/

  89. stock kz_velocity_set(id,vel[3]) {

  90.    //Set Their Velocity to 0 so that they they fall straight down from

  91.    new Float:Ivel[3]

  92.    Ivel[0]=float(vel[0])

  93.    Ivel[1]=float(vel[1])

  94.    Ivel[2]=float(vel[2])

  95.    entity_set_vector(id, EV_VEC_velocity, Ivel)

  96. }

  97.  

  98. stock kz_velocity_get(id,vel[3]) {

  99.    //Set Their Velocity to 0 so that they they fall straight down from

  100.    new Float:Ivel[3]

  101.  

  102.    entity_get_vector(id, EV_VEC_velocity, Ivel)

  103.    vel[0]=floatround(Ivel[0])

  104.    vel[1]=floatround(Ivel[1])

  105.    vel[2]=floatround(Ivel[2])

  106. }

  107.  

  108. /************************************************************************************************************************/

  109. /**************************************************** ADMIN COMMANDS ****************************************************/

  110. /************************************************************************************************************************/

  111. public AdminGrantHook(id,level,cid)

  112. {

  113.    if ( !cmd_access(id,level,cid,1) )

  114.       return PLUGIN_HANDLED

  115.  

  116.    new arg1[32],arg2[32]

  117.    read_argv(1,arg1,31)

  118.    read_argv(2,arg2,31)

  119.    new onoff = str_to_num(arg2)

  120.  

  121.    if ( equali(arg1,"@all") )

  122.    {

  123.       new plist[32],pnum

  124.       get_players(plist,pnum,"a")

  125.       if (pnum==0)

  126.       {

  127.        console_print(id,"[%s] There are no clients",gModName)

  128.        return PLUGIN_HANDLED

  129.       }

  130.       for (new i=0; i<pnum; i++) {

  131.          gAllowedHook[plist[i]]=onoff

  132.          if (gIsHooked[plist[i]]==true && onoff==0)

  133.          {

  134.             RopeRelease(plist[i])

  135.          }

  136.       }

  137.  

  138.       console_print(id,"[%s] %s all players access to hook/rope",gModName,onoff ? "Gave":"Removed")

  139.    }

  140.    else if ( arg1[0]=='@' )

  141.    {

  142.       new plist[32],pnum

  143.       get_players(plist,pnum,"ae",arg1[1])

  144.       if ( pnum==0 )

  145.       {

  146.        console_print(id,"[%s] No clients in such team",gModName)

  147.        return PLUGIN_HANDLED

  148.       }

  149.       for (new i=0; i<pnum; i++) {

  150.          gAllowedHook[plist[i]]=onoff

  151.          if (gIsHooked[plist[i]]==true && onoff==0)

  152.          {

  153.             RopeRelease(plist[i])

  154.          }

  155.       }

  156.       console_print(id,"[%s] %s all %ss access to hook/rope",onoff ? "Gave":"Removed",arg1[1])

  157.    }

  158.    else

  159.    {

  160.       new pName[32]

  161.       new player = cmd_target(id,arg1,6)

  162.       if (!player) return PLUGIN_HANDLED

  163.  

  164.       gAllowedHook[player]=onoff

  165.       if (gAllowedHook[player]==0 && onoff==0)

  166.       {

  167.          RopeRelease(player)

  168.       }

  169.  

  170.  

  171.       get_user_name(player,pName,31)

  172.       console_print(id,"[%s] %s ^"%s^" access to hook/rope",onoff ? "Gave":"Removed",pName)

  173.    }

  174.  

  175.    return PLUGIN_HANDLED

  176. }

  177.  

  178. /************************************************************************************************************************/

  179. /****************************************************** NINJAROPE *******************************************************/

  180. /************************************************************************************************************************/

  181.  

  182. public ropetask(parm[])

  183. {

  184.    new id = parm[0]

  185.    new user_origin[3], user_look[3], user_direction[3], move_direction[3]

  186.    new A[3], D[3], buttonadjust[3]

  187.    new acceleration, velocity_towards_A, desired_velocity_towards_A

  188.    new velocity[3], null[3]

  189.  

  190.    if (!is_user_alive(id))

  191.    {

  192.       RopeRelease(id)

  193.       return

  194.    }

  195.  

  196.    if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())

  197.    {

  198.       beamentpoint(id)

  199.    }

  200.  

  201.    null[0] = 0

  202.    null[1] = 0

  203.    null[2] = 0

  204.  

  205.    get_user_origin(id, user_origin)

  206.    get_user_origin(id, user_look,2)

  207.    kz_velocity_get(id, velocity)

  208.  

  209.    buttonadjust[0]=0

  210.    buttonadjust[1]=0

  211.  

  212.    if (get_user_button(id)&IN_FORWARD)      buttonadjust[0]+=1

  213.    if (get_user_button(id)&IN_BACK)      buttonadjust[0]-=1

  214.    if (get_user_button(id)&IN_MOVERIGHT)   buttonadjust[1]+=1

  215.    if (get_user_button(id)&IN_MOVELEFT)   buttonadjust[1]-=1

  216.    if (get_user_button(id)&IN_JUMP)      buttonadjust[2]+=1

  217.    if (get_user_button(id)&IN_DUCK)      buttonadjust[2]-=1

  218.  

  219.    if (buttonadjust[0] || buttonadjust[1])

  220.    {

  221.       user_direction[0] = user_look[0] - user_origin[0]

  222.       user_direction[1] = user_look[1] - user_origin[1]

  223.  

  224.       move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]

  225.       move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]

  226.       move_direction[2] = 0

  227.  

  228.       velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))

  229.       velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))

  230.    }

  231.  

  232.    if (buttonadjust[2])   gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)

  233.    if (gHookLenght[id] < 100) gHookLenght[id] = 100

  234.  

  235.    A[0] = gHookLocation[id][0] - user_origin[0]

  236.    A[1] = gHookLocation[id][1] - user_origin[1]

  237.    A[2] = gHookLocation[id][2] - user_origin[2]

  238.  

  239.    D[0] = A[0]*A[2] / get_distance(null,A)

  240.    D[1] = A[1]*A[2] / get_distance(null,A)

  241.    D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)

  242.  

  243.    acceleration = - global_gravity * D[2] / get_distance(null,D)

  244.  

  245.    velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)

  246.    desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4

  247.  

  248.    if (get_distance(null,D)>10)

  249.    {

  250.       velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))

  251.       velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))

  252.       velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))

  253.    }

  254.  

  255.    velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)

  256.    velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)

  257.    velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)

  258.  

  259.    kz_velocity_set(id, velocity)

  260. }

  261.  

  262. public hooktask(parm[])

  263. {

  264.    new id = parm[0]

  265.    new velocity[3]

  266.  

  267.    if ( !gIsHooked[id] ) return

  268.  

  269.    new user_origin[3],oldvelocity[3]

  270.    parm[0] = id

  271.  

  272.    if (!is_user_alive(id))

  273.    {

  274.       RopeRelease(id)

  275.       return

  276.    }

  277.  

  278.    if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())

  279.    {

  280.       beamentpoint(id)

  281.    }

  282.  

  283.    get_user_origin(id, user_origin)

  284.    kz_velocity_get(id, oldvelocity)

  285.    new distance=get_distance( gHookLocation[id], user_origin )

  286.    if ( distance > 10 )

  287.    {

  288.       velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )

  289.       velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )

  290.       velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )

  291.    }

  292.    else

  293.    {

  294.       velocity[0]=0

  295.       velocity[1]=0

  296.       velocity[2]=0

  297.    }

  298.  

  299.    kz_velocity_set(id, velocity)

  300.  

  301. }

  302.  

  303. public hook_on(id)

  304. {

  305.    if (get_cvar_num("sv_adminhook")==1)

  306.       {

  307.       if (gAllowedHook[id]) {

  308.          if (!gIsHooked[id] && is_user_alive(id))

  309.          {

  310.             new cmd[32]

  311.             read_argv(0,cmd,31)

  312.             if(equal(cmd,"+rope")) RopeAttach(id,0)

  313.             if(equal(cmd,"+hook")) RopeAttach(id,1)

  314.          }

  315.       }else{

  316.          client_print(id,print_chat,"[%s] Nincs elerhetoseged hozza",gModName)

  317.          return PLUGIN_HANDLED

  318.       }

  319.    }else{

  320.       client_print(id,print_chat,"[%s] Ez a parancs ki van kapcsolva",gModName)

  321.    }

  322.    return PLUGIN_HANDLED

  323. }

  324.  

  325. public hook_off(id)

  326. {

  327.    if (gAllowedHook[id]) {

  328.       if (gIsHooked[id])

  329.       {

  330.          RopeRelease(id)

  331.       }

  332.    }else{

  333.       client_print(id,print_chat,"[%s] Nincs elerhetoseged hozza",gModName)

  334.       return PLUGIN_HANDLED

  335.    }

  336.    return PLUGIN_HANDLED

  337. }

  338.  

  339. public RopeAttach(id,hook)

  340. {

  341.    new parm[1], user_origin[3]

  342.    parm[0] = id

  343.    gIsHooked[id] = true

  344.    get_user_origin(id,user_origin)

  345.    get_user_origin(id,gHookLocation[id], 3)

  346.    gHookLenght[id] = get_distance(gHookLocation[id],user_origin)

  347.    global_gravity = get_cvar_num("sv_gravity")

  348.    set_user_gravity(id,0.001)

  349.    beamentpoint(id)

  350.    emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)

  351.    if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")

  352.    else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")

  353. }

  354.  

  355. public RopeRelease(id)

  356. {

  357.    gIsHooked[id] = false

  358.    killbeam(id)

  359.    set_user_gravity(id)

  360.    remove_task(200+id)

  361. }

  362.  

  363. public beamentpoint(id)

  364. {

  365.    message_begin( MSG_BROADCAST, SVC_TEMPENTITY )

  366.    write_byte( TE_BEAMENTPOINT )

  367.    write_short( id )

  368.    write_coord( gHookLocation[id][0] )

  369.    write_coord( gHookLocation[id][1] )

  370.    write_coord( gHookLocation[id][2] )

  371.    write_short( beam )   // sprite index

  372.    write_byte( 0 )      // start frame

  373.    write_byte( 0 )      // framerate

  374.    write_byte( BEAMLIFE )   // life

  375.    write_byte( 10 )   // width

  376.    write_byte( 0 )      // noise

  377.    if (get_user_team(id)==1)      // Terrorist

  378.    {

  379.       write_byte( 255 )   // r, g, b

  380.       write_byte( 0 )   // r, g, b

  381.       write_byte( 0 )   // r, g, b

  382.    }

  383.    else                     // Counter-Terrorist

  384.    {

  385.       write_byte( 0 )   // r, g, b

  386.       write_byte( 0 )   // r, g, b

  387.       write_byte( 255 )   // r, g, b

  388.    }

  389.    write_byte( 150 )   // brightness

  390.    write_byte( 0 )      // speed

  391.    message_end( )

  392.    gBeamIsCreated[id] = get_gametime()

  393. }

  394.  

  395. public killbeam(id)

  396. {

  397.    message_begin( MSG_BROADCAST, SVC_TEMPENTITY )

  398.    write_byte( TE_KILLBEAM )

  399.    write_short( id )

  400.    message_end()

  401. }

  402.  

  403. /************************************************************************************************************************/

  404. /******************************************************* FORWARDS *******************************************************/

  405. /************************************************************************************************************************/

  406.  

  407. public client_disconnect(id) {

  408.    gAllowedHook[id]=0

  409. }

  410.  

  411. /************************************************************************************************************************/

  412. /************************************************** AMXX -> AMX funcs ***************************************************/

  413. /************************************************************************************************************************/

  414. #if USING_AMX

  415.    stock get_user_button(id) return entity_get_int(id, EV_INT_button)

  416. #endif

  417.  


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Hook
HozzászólásElküldve:2012.05.13. 18:29 
Offline
Jómunkásember

Csatlakozott:2011.07.14. 11:12
Hozzászólások:320
Megköszönt másnak: 1 alkalommal
Köszönöm szépen


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Hook
HozzászólásElküldve:2012.05.14. 15:59 
Offline
Jómunkásember

Csatlakozott:2011.07.14. 11:12
Hozzászólások:320
Megköszönt másnak: 1 alkalommal
Kedves Silent a plugin nem jó 1-ik csapat sem tudja hasznáni így a hook-ot se aa CT se a T se az Admin se a Player.

Kérnék valakit hogy csinálja meg hogy mindenki tudja használni, köszönöm szépen.



Ui.: egyéb módosítás nem kell.........


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

Csatlakozott:2011.06.07. 15:29
Hozzászólások:1728
Megköszönt másnak: 1 alkalommal
Megköszönték neki: 63 alkalommal
Nem használtam valami bonyolult módszert, csak minden kör elején ad minden playernek hookot. ( amx_granthook @all )
Kód:
  1.      

  2.     /**************************************************************************************************

  3.      

  4.     **** CVARS (FEATURES) ****

  5.     sv_adminhook         = Turn Plugin On/off

  6.     **** ADMIN COMMANDS ****

  7.     ADMIN_LEVEL_A (flag="m")

  8.     Granting Hook/Rope   = amx_granthook <authid, nick, @team, @all or #userid> <on/off>

  9.      

  10.     ADMIN_LEVEL_E (flag="q") || Granted by admin

  11.     Ninja Rope by Spacedude (slightly modified) & Hook thingy

  12.     Attaching Rope         = +rope

  13.     Deattaching Rope      = -rope

  14.     Attaching Hook         = +hook

  15.     Deattaching Hook      = -hook

  16.      

  17.     **************************************************************************************************/

  18.     #define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX

  19.      

  20.     #if USING_AMX

  21.        #include <amxmod>

  22.        #include <amxmisc>

  23.        #include <VexdUM>

  24.        #include <fun>

  25.        new gModName[32] = "AMX"

  26.     #else

  27.        #include <amxmodx>

  28.        #include <amxmisc>

  29.        #include <fun>

  30.        #include <engine>

  31.        new gModName[32] = "AMXX"

  32.     #endif

  33.      

  34.     #define TE_BEAMENTPOINT 1

  35.     #define TE_KILLBEAM 99

  36.     #define DELTA_T 0.1            // seconds

  37.     #define BEAMLIFE 100         // deciseconds

  38.     #define MOVEACCELERATION 150   // units per second^2

  39.     #define REELSPEED 300         // units per second

  40.      

  41.     /* Hook Stuff */

  42.     new gHookLocation[33][3]

  43.     new gHookLenght[33]

  44.     new bool:gIsHooked[33]

  45.     new gAllowedHook[33]

  46.     new Float:gBeamIsCreated[33]

  47.     new global_gravity

  48.     new beam

  49.      

  50.     /************************************************************************************************************************/

  51.     public plugin_init() //Called on plugin start

  52.     {

  53.        // Plugin Info

  54.        register_plugin("Admin Hook","1.0","AssKicR")

  55.      

  56.        //CVARS

  57.        register_cvar("sv_adminhook", "1" )

  58.      

  59.        //ADMIN CMDS

  60.        register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")

  61.      

  62.        //USER COMMANDS

  63.        register_clcmd("+rope", "hook_on")

  64.        register_clcmd("-rope", "hook_off")

  65.        register_clcmd("+hook", "hook_on")

  66.        register_clcmd("-hook", "hook_off")

  67.  

  68. register_logevent( "addhook", 2, "1=Round_Start" );

  69.      

  70.        //HOOKED EVENTS

  71.        register_event("ResetHUD", "ResetHUD", "b")

  72.     }

  73.     /************************************************************************************************************************/

  74. public addhook()

  75. {

  76.         server_cmd("amx_granthook @all")

  77. }

  78.     public plugin_precache()

  79.     {

  80.        beam = precache_model("sprites/zbeam4.spr")

  81.        precache_sound("weapons/xbow_hit2.wav")

  82.     }

  83.     /*************************************************************************************************************************/

  84.     /************************************************** USP/SCOUT REMOVE *****************************************************/

  85.     /*************************************************************************************************************************/

  86.      

  87.     /*************************************************************************************************************************/

  88.     /**************************************************** HOOKED EVENTS ******************************************************/

  89.     /*************************************************************************************************************************/

  90.     public ResetHUD(id) {

  91.        //Check if he is hooked to something

  92.        if (gIsHooked[id]) RopeRelease(id)

  93.     }

  94.     /************************************************************************************************************************/

  95.     stock kz_velocity_set(id,vel[3]) {

  96.        //Set Their Velocity to 0 so that they they fall straight down from

  97.        new Float:Ivel[3]

  98.        Ivel[0]=float(vel[0])

  99.        Ivel[1]=float(vel[1])

  100.        Ivel[2]=float(vel[2])

  101.        entity_set_vector(id, EV_VEC_velocity, Ivel)

  102.     }

  103.      

  104.     stock kz_velocity_get(id,vel[3]) {

  105.        //Set Their Velocity to 0 so that they they fall straight down from

  106.        new Float:Ivel[3]

  107.      

  108.        entity_get_vector(id, EV_VEC_velocity, Ivel)

  109.        vel[0]=floatround(Ivel[0])

  110.        vel[1]=floatround(Ivel[1])

  111.        vel[2]=floatround(Ivel[2])

  112.     }

  113.      

  114.     /************************************************************************************************************************/

  115.     /**************************************************** ADMIN COMMANDS ****************************************************/

  116.     /************************************************************************************************************************/

  117.     public AdminGrantHook(id,level,cid)

  118.     {

  119.        if ( !cmd_access(id,level,cid,1) )

  120.           return PLUGIN_HANDLED

  121.      

  122.        new arg1[32],arg2[32]

  123.        read_argv(1,arg1,31)

  124.        read_argv(2,arg2,31)

  125.        new onoff = str_to_num(arg2)

  126.      

  127.        if ( equali(arg1,"@all") )

  128.        {

  129.           new plist[32],pnum

  130.           get_players(plist,pnum,"a")

  131.           if (pnum==0)

  132.           {

  133.            console_print(id,"[%s] There are no clients",gModName)

  134.            return PLUGIN_HANDLED

  135.           }

  136.           for (new i=0; i<pnum; i++) {

  137.              gAllowedHook[plist[i]]=onoff

  138.              if (gIsHooked[plist[i]]==true && onoff==0)

  139.              {

  140.                 RopeRelease(plist[i])

  141.              }

  142.           }

  143.      

  144.           console_print(id,"[%s] %s all players access to hook/rope",gModName,onoff ? "Gave":"Removed")

  145.        }

  146.        else if ( arg1[0]=='@' )

  147.        {

  148.           new plist[32],pnum

  149.           get_players(plist,pnum,"ae",arg1[1])

  150.           if ( pnum==0 )

  151.           {

  152.            console_print(id,"[%s] No clients in such team",gModName)

  153.            return PLUGIN_HANDLED

  154.           }

  155.           for (new i=0; i<pnum; i++) {

  156.              gAllowedHook[plist[i]]=onoff

  157.              if (gIsHooked[plist[i]]==true && onoff==0)

  158.              {

  159.                 RopeRelease(plist[i])

  160.              }

  161.           }

  162.           console_print(id,"[%s] %s all %ss access to hook/rope",onoff ? "Gave":"Removed",arg1[1])

  163.        }

  164.        else

  165.        {

  166.           new pName[32]

  167.           new player = cmd_target(id,arg1,6)

  168.           if (!player) return PLUGIN_HANDLED

  169.      

  170.           gAllowedHook[player]=onoff

  171.           if (gAllowedHook[player]==0 && onoff==0)

  172.           {

  173.              RopeRelease(player)

  174.           }

  175.      

  176.      

  177.           get_user_name(player,pName,31)

  178.           console_print(id,"[%s] %s ^"%s^" access to hook/rope",onoff ? "Gave":"Removed",pName)

  179.        }

  180.      

  181.        return PLUGIN_HANDLED

  182.     }

  183.      

  184.     /************************************************************************************************************************/

  185.     /****************************************************** NINJAROPE *******************************************************/

  186.     /************************************************************************************************************************/

  187.      

  188.     public ropetask(parm[])

  189.     {

  190.        new id = parm[0]

  191.        new user_origin[3], user_look[3], user_direction[3], move_direction[3]

  192.        new A[3], D[3], buttonadjust[3]

  193.        new acceleration, velocity_towards_A, desired_velocity_towards_A

  194.        new velocity[3], null[3]

  195.      

  196.        if (!is_user_alive(id))

  197.        {

  198.           RopeRelease(id)

  199.           return

  200.        }

  201.      

  202.        if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())

  203.        {

  204.           beamentpoint(id)

  205.        }

  206.      

  207.        null[0] = 0

  208.        null[1] = 0

  209.        null[2] = 0

  210.      

  211.        get_user_origin(id, user_origin)

  212.        get_user_origin(id, user_look,2)

  213.        kz_velocity_get(id, velocity)

  214.      

  215.        buttonadjust[0]=0

  216.        buttonadjust[1]=0

  217.      

  218.        if (get_user_button(id)&IN_FORWARD)      buttonadjust[0]+=1

  219.        if (get_user_button(id)&IN_BACK)      buttonadjust[0]-=1

  220.        if (get_user_button(id)&IN_MOVERIGHT)   buttonadjust[1]+=1

  221.        if (get_user_button(id)&IN_MOVELEFT)   buttonadjust[1]-=1

  222.        if (get_user_button(id)&IN_JUMP)      buttonadjust[2]+=1

  223.        if (get_user_button(id)&IN_DUCK)      buttonadjust[2]-=1

  224.      

  225.        if (buttonadjust[0] || buttonadjust[1])

  226.        {

  227.           user_direction[0] = user_look[0] - user_origin[0]

  228.           user_direction[1] = user_look[1] - user_origin[1]

  229.      

  230.           move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]

  231.           move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]

  232.           move_direction[2] = 0

  233.      

  234.           velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))

  235.           velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))

  236.        }

  237.      

  238.        if (buttonadjust[2])   gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)

  239.        if (gHookLenght[id] < 100) gHookLenght[id] = 100

  240.      

  241.        A[0] = gHookLocation[id][0] - user_origin[0]

  242.        A[1] = gHookLocation[id][1] - user_origin[1]

  243.        A[2] = gHookLocation[id][2] - user_origin[2]

  244.      

  245.        D[0] = A[0]*A[2] / get_distance(null,A)

  246.        D[1] = A[1]*A[2] / get_distance(null,A)

  247.        D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)

  248.      

  249.        acceleration = - global_gravity * D[2] / get_distance(null,D)

  250.      

  251.        velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)

  252.        desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4

  253.      

  254.        if (get_distance(null,D)>10)

  255.        {

  256.           velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))

  257.           velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))

  258.           velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))

  259.        }

  260.      

  261.        velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)

  262.        velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)

  263.        velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)

  264.      

  265.        kz_velocity_set(id, velocity)

  266.     }

  267.      

  268.     public hooktask(parm[])

  269.     {

  270.        new id = parm[0]

  271.        new velocity[3]

  272.      

  273.        if ( !gIsHooked[id] ) return

  274.      

  275.        new user_origin[3],oldvelocity[3]

  276.        parm[0] = id

  277.      

  278.        if (!is_user_alive(id))

  279.        {

  280.           RopeRelease(id)

  281.           return

  282.        }

  283.      

  284.        if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())

  285.        {

  286.           beamentpoint(id)

  287.        }

  288.      

  289.        get_user_origin(id, user_origin)

  290.        kz_velocity_get(id, oldvelocity)

  291.        new distance=get_distance( gHookLocation[id], user_origin )

  292.        if ( distance > 10 )

  293.        {

  294.           velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )

  295.           velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )

  296.           velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )

  297.        }

  298.        else

  299.        {

  300.           velocity[0]=0

  301.           velocity[1]=0

  302.           velocity[2]=0

  303.        }

  304.      

  305.        kz_velocity_set(id, velocity)

  306.      

  307.     }

  308.      

  309.     public hook_on(id)

  310.     {

  311.        if (get_cvar_num("sv_adminhook")==1)

  312.           {

  313.             server_cmd("amx_granthook @all")

  314.           if (gAllowedHook[id]) {

  315.              if (!gIsHooked[id] && is_user_alive(id))

  316.              {

  317.                 new cmd[32]

  318.                 read_argv(0,cmd,31)

  319.                 if(equal(cmd,"+rope")) RopeAttach(id,0)

  320.                 if(equal(cmd,"+hook")) RopeAttach(id,1)

  321.              }

  322.           }else{

  323.              client_print(id,print_chat,"[%s] Nincs elerhetoseged hozza",gModName)

  324.              return PLUGIN_HANDLED

  325.           }

  326.        }else{

  327.           client_print(id,print_chat,"[%s] Ez a parancs ki van kapcsolva",gModName)

  328.        }

  329.        return PLUGIN_HANDLED

  330.     }

  331.      

  332.     public hook_off(id)

  333.     {

  334.        if (gAllowedHook[id]) {

  335.           if (gIsHooked[id])

  336.           {

  337.              RopeRelease(id)

  338.           }

  339.        }else{

  340.           client_print(id,print_chat,"[%s] Nincs elerhetoseged hozza",gModName)

  341.           return PLUGIN_HANDLED

  342.        }

  343.        return PLUGIN_HANDLED

  344.     }

  345.      

  346.     public RopeAttach(id,hook)

  347.     {

  348.        new parm[1], user_origin[3]

  349.        parm[0] = id

  350.        gIsHooked[id] = true

  351.        get_user_origin(id,user_origin)

  352.        get_user_origin(id,gHookLocation[id], 3)

  353.        gHookLenght[id] = get_distance(gHookLocation[id],user_origin)

  354.        global_gravity = get_cvar_num("sv_gravity")

  355.        set_user_gravity(id,0.001)

  356.        beamentpoint(id)

  357.        emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)

  358.        if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")

  359.        else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")

  360.     }

  361.      

  362.     public RopeRelease(id)

  363.     {

  364.        gIsHooked[id] = false

  365.        killbeam(id)

  366.        set_user_gravity(id)

  367.        remove_task(200+id)

  368.     }

  369.      

  370.     public beamentpoint(id)

  371.     {

  372.        message_begin( MSG_BROADCAST, SVC_TEMPENTITY )

  373.        write_byte( TE_BEAMENTPOINT )

  374.        write_short( id )

  375.        write_coord( gHookLocation[id][0] )

  376.        write_coord( gHookLocation[id][1] )

  377.        write_coord( gHookLocation[id][2] )

  378.        write_short( beam )   // sprite index

  379.        write_byte( 0 )      // start frame

  380.        write_byte( 0 )      // framerate

  381.        write_byte( BEAMLIFE )   // life

  382.        write_byte( 10 )   // width

  383.        write_byte( 0 )      // noise

  384.        if (get_user_team(id)==1)      // Terrorist

  385.        {

  386.           write_byte( 255 )   // r, g, b

  387.           write_byte( 0 )   // r, g, b

  388.           write_byte( 0 )   // r, g, b

  389.        }

  390.        else                     // Counter-Terrorist

  391.        {

  392.           write_byte( 0 )   // r, g, b

  393.           write_byte( 0 )   // r, g, b

  394.           write_byte( 255 )   // r, g, b

  395.        }

  396.        write_byte( 150 )   // brightness

  397.        write_byte( 0 )      // speed

  398.        message_end( )

  399.        gBeamIsCreated[id] = get_gametime()

  400.     }

  401.      

  402.     public killbeam(id)

  403.     {

  404.        message_begin( MSG_BROADCAST, SVC_TEMPENTITY )

  405.        write_byte( TE_KILLBEAM )

  406.        write_short( id )

  407.        message_end()

  408.     }

  409.      

  410.     /************************************************************************************************************************/

  411.     /******************************************************* FORWARDS *******************************************************/

  412.     /************************************************************************************************************************/

  413.      

  414.     public client_disconnect(id) {

  415.        gAllowedHook[id]=0

  416.     }

  417.      

  418.     /************************************************************************************************************************/

  419.     /************************************************** AMXX -> AMX funcs ***************************************************/

  420.     /************************************************************************************************************************/

  421.     #if USING_AMX

  422.        stock get_user_button(id) return entity_get_int(id, EV_INT_button)

  423.     #endif

  424.      


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Hook
HozzászólásElküldve:2012.05.14. 17:27 
Offline
Jómunkásember

Csatlakozott:2011.07.14. 11:12
Hozzászólások:320
Megköszönt másnak: 1 alkalommal
Köszönöm. Feltéve ha jó :D


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Hook
HozzászólásElküldve:2012.05.14. 18:31 
Offline
Jómunkásember

Csatlakozott:2011.07.14. 11:12
Hozzászólások:320
Megköszönt másnak: 1 alkalommal
Ez se jó O_o


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Hook
HozzászólásElküldve:2012.05.14. 18:58 
Offline
Veterán
Avatar

Csatlakozott:2011.06.07. 15:29
Hozzászólások:1728
Megköszönt másnak: 1 alkalommal
Megköszönték neki: 63 alkalommal
Ennek jónak kellene lennie. Amikor feljön valaki a szeróra, akkor ad a nevére hookot.
Kód:
  1.          

  2.         /**************************************************************************************************

  3.          

  4.         **** CVARS (FEATURES) ****

  5.         sv_adminhook         = Turn Plugin On/off

  6.         **** ADMIN COMMANDS ****

  7.         ADMIN_LEVEL_A (flag="m")

  8.         Granting Hook/Rope   = amx_granthook <authid, nick, @team, @all or #userid> <on/off>

  9.          

  10.         ADMIN_LEVEL_E (flag="q") || Granted by admin

  11.         Ninja Rope by Spacedude (slightly modified) & Hook thingy

  12.         Attaching Rope         = +rope

  13.         Deattaching Rope      = -rope

  14.         Attaching Hook         = +hook

  15.         Deattaching Hook      = -hook

  16.          

  17.         **************************************************************************************************/

  18.         #define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX

  19.          

  20.         #if USING_AMX

  21.            #include <amxmod>

  22.            #include <amxmisc>

  23.            #include <VexdUM>

  24.            #include <fun>

  25.            new gModName[32] = "AMX"

  26.         #else

  27.            #include <amxmodx>

  28.            #include <amxmisc>

  29.            #include <fun>

  30.            #include <engine>

  31.            new gModName[32] = "AMXX"

  32.         #endif

  33.          

  34.         #define TE_BEAMENTPOINT 1

  35.         #define TE_KILLBEAM 99

  36.         #define DELTA_T 0.1            // seconds

  37.         #define BEAMLIFE 100         // deciseconds

  38.         #define MOVEACCELERATION 150   // units per second^2

  39.         #define REELSPEED 300         // units per second

  40.          

  41.         /* Hook Stuff */

  42.         new gHookLocation[33][3]

  43.         new gHookLenght[33]

  44.         new bool:gIsHooked[33]

  45.         new gAllowedHook[33]

  46.         new Float:gBeamIsCreated[33]

  47.         new global_gravity

  48.         new beam

  49.          

  50.         /************************************************************************************************************************/

  51.         public plugin_init() //Called on plugin start

  52.         {

  53.            // Plugin Info

  54.            register_plugin("Admin Hook","1.0","AssKicR")

  55.          

  56.            //CVARS

  57.            register_cvar("sv_adminhook", "1" )

  58.          

  59.            //ADMIN CMDS

  60.            register_concmd("amx_granthook","AdminGrantHook",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")

  61.          

  62.            //USER COMMANDS

  63.            register_clcmd("+rope", "hook_on")

  64.            register_clcmd("-rope", "hook_off")

  65.            register_clcmd("+hook", "hook_on")

  66.            register_clcmd("-hook", "hook_off")

  67.      

  68.     register_logevent( "addhook", 2, "1=Round_Start" );

  69.          

  70.            //HOOKED EVENTS

  71.            register_event("ResetHUD", "ResetHUD", "b")

  72.         }

  73.         /************************************************************************************************************************/

  74.     public client_putinserver(id)

  75.     {

  76.             new name[33]

  77.             get_user_name(id, name, 31)

  78.             server_cmd("amx_granthook %s", name)

  79.     }

  80.         public plugin_precache()

  81.         {

  82.            beam = precache_model("sprites/zbeam4.spr")

  83.            precache_sound("weapons/xbow_hit2.wav")

  84.         }

  85.         /*************************************************************************************************************************/

  86.         /************************************************** USP/SCOUT REMOVE *****************************************************/

  87.         /*************************************************************************************************************************/

  88.          

  89.         /*************************************************************************************************************************/

  90.         /**************************************************** HOOKED EVENTS ******************************************************/

  91.         /*************************************************************************************************************************/

  92.         public ResetHUD(id) {

  93.            //Check if he is hooked to something

  94.            if (gIsHooked[id]) RopeRelease(id)

  95.         }

  96.         /************************************************************************************************************************/

  97.         stock kz_velocity_set(id,vel[3]) {

  98.            //Set Their Velocity to 0 so that they they fall straight down from

  99.            new Float:Ivel[3]

  100.            Ivel[0]=float(vel[0])

  101.            Ivel[1]=float(vel[1])

  102.            Ivel[2]=float(vel[2])

  103.            entity_set_vector(id, EV_VEC_velocity, Ivel)

  104.         }

  105.          

  106.         stock kz_velocity_get(id,vel[3]) {

  107.            //Set Their Velocity to 0 so that they they fall straight down from

  108.            new Float:Ivel[3]

  109.          

  110.            entity_get_vector(id, EV_VEC_velocity, Ivel)

  111.            vel[0]=floatround(Ivel[0])

  112.            vel[1]=floatround(Ivel[1])

  113.            vel[2]=floatround(Ivel[2])

  114.         }

  115.          

  116.         /************************************************************************************************************************/

  117.         /**************************************************** ADMIN COMMANDS ****************************************************/

  118.         /************************************************************************************************************************/

  119.         public AdminGrantHook(id,level,cid)

  120.         {

  121.            if ( !cmd_access(id,level,cid,1) )

  122.               return PLUGIN_HANDLED

  123.          

  124.            new arg1[32],arg2[32]

  125.            read_argv(1,arg1,31)

  126.            read_argv(2,arg2,31)

  127.            new onoff = str_to_num(arg2)

  128.          

  129.            if ( equali(arg1,"@all") )

  130.            {

  131.               new plist[32],pnum

  132.               get_players(plist,pnum,"a")

  133.               if (pnum==0)

  134.               {

  135.                console_print(id,"[%s] There are no clients",gModName)

  136.                return PLUGIN_HANDLED

  137.               }

  138.               for (new i=0; i<pnum; i++) {

  139.                  gAllowedHook[plist[i]]=onoff

  140.                  if (gIsHooked[plist[i]]==true && onoff==0)

  141.                  {

  142.                     RopeRelease(plist[i])

  143.                  }

  144.               }

  145.          

  146.               console_print(id,"[%s] %s all players access to hook/rope",gModName,onoff ? "Gave":"Removed")

  147.            }

  148.            else if ( arg1[0]=='@' )

  149.            {

  150.               new plist[32],pnum

  151.               get_players(plist,pnum,"ae",arg1[1])

  152.               if ( pnum==0 )

  153.               {

  154.                console_print(id,"[%s] No clients in such team",gModName)

  155.                return PLUGIN_HANDLED

  156.               }

  157.               for (new i=0; i<pnum; i++) {

  158.                  gAllowedHook[plist[i]]=onoff

  159.                  if (gIsHooked[plist[i]]==true && onoff==0)

  160.                  {

  161.                     RopeRelease(plist[i])

  162.                  }

  163.               }

  164.               console_print(id,"[%s] %s all %ss access to hook/rope",onoff ? "Gave":"Removed",arg1[1])

  165.            }

  166.            else

  167.            {

  168.               new pName[32]

  169.               new player = cmd_target(id,arg1,6)

  170.               if (!player) return PLUGIN_HANDLED

  171.          

  172.               gAllowedHook[player]=onoff

  173.               if (gAllowedHook[player]==0 && onoff==0)

  174.               {

  175.                  RopeRelease(player)

  176.               }

  177.          

  178.          

  179.               get_user_name(player,pName,31)

  180.               console_print(id,"[%s] %s ^"%s^" access to hook/rope",onoff ? "Gave":"Removed",pName)

  181.            }

  182.          

  183.            return PLUGIN_HANDLED

  184.         }

  185.          

  186.         /************************************************************************************************************************/

  187.         /****************************************************** NINJAROPE *******************************************************/

  188.         /************************************************************************************************************************/

  189.          

  190.         public ropetask(parm[])

  191.         {

  192.            new id = parm[0]

  193.            new user_origin[3], user_look[3], user_direction[3], move_direction[3]

  194.            new A[3], D[3], buttonadjust[3]

  195.            new acceleration, velocity_towards_A, desired_velocity_towards_A

  196.            new velocity[3], null[3]

  197.          

  198.            if (!is_user_alive(id))

  199.            {

  200.               RopeRelease(id)

  201.               return

  202.            }

  203.          

  204.            if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())

  205.            {

  206.               beamentpoint(id)

  207.            }

  208.          

  209.            null[0] = 0

  210.            null[1] = 0

  211.            null[2] = 0

  212.          

  213.            get_user_origin(id, user_origin)

  214.            get_user_origin(id, user_look,2)

  215.            kz_velocity_get(id, velocity)

  216.          

  217.            buttonadjust[0]=0

  218.            buttonadjust[1]=0

  219.          

  220.            if (get_user_button(id)&IN_FORWARD)      buttonadjust[0]+=1

  221.            if (get_user_button(id)&IN_BACK)      buttonadjust[0]-=1

  222.            if (get_user_button(id)&IN_MOVERIGHT)   buttonadjust[1]+=1

  223.            if (get_user_button(id)&IN_MOVELEFT)   buttonadjust[1]-=1

  224.            if (get_user_button(id)&IN_JUMP)      buttonadjust[2]+=1

  225.            if (get_user_button(id)&IN_DUCK)      buttonadjust[2]-=1

  226.          

  227.            if (buttonadjust[0] || buttonadjust[1])

  228.            {

  229.               user_direction[0] = user_look[0] - user_origin[0]

  230.               user_direction[1] = user_look[1] - user_origin[1]

  231.          

  232.               move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]

  233.               move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]

  234.               move_direction[2] = 0

  235.          

  236.               velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))

  237.               velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))

  238.            }

  239.          

  240.            if (buttonadjust[2])   gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)

  241.            if (gHookLenght[id] < 100) gHookLenght[id] = 100

  242.          

  243.            A[0] = gHookLocation[id][0] - user_origin[0]

  244.            A[1] = gHookLocation[id][1] - user_origin[1]

  245.            A[2] = gHookLocation[id][2] - user_origin[2]

  246.          

  247.            D[0] = A[0]*A[2] / get_distance(null,A)

  248.            D[1] = A[1]*A[2] / get_distance(null,A)

  249.            D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)

  250.          

  251.            acceleration = - global_gravity * D[2] / get_distance(null,D)

  252.          

  253.            velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)

  254.            desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4

  255.          

  256.            if (get_distance(null,D)>10)

  257.            {

  258.               velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))

  259.               velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))

  260.               velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))

  261.            }

  262.          

  263.            velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)

  264.            velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)

  265.            velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)

  266.          

  267.            kz_velocity_set(id, velocity)

  268.         }

  269.          

  270.         public hooktask(parm[])

  271.         {

  272.            new id = parm[0]

  273.            new velocity[3]

  274.          

  275.            if ( !gIsHooked[id] ) return

  276.          

  277.            new user_origin[3],oldvelocity[3]

  278.            parm[0] = id

  279.          

  280.            if (!is_user_alive(id))

  281.            {

  282.               RopeRelease(id)

  283.               return

  284.            }

  285.          

  286.            if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())

  287.            {

  288.               beamentpoint(id)

  289.            }

  290.          

  291.            get_user_origin(id, user_origin)

  292.            kz_velocity_get(id, oldvelocity)

  293.            new distance=get_distance( gHookLocation[id], user_origin )

  294.            if ( distance > 10 )

  295.            {

  296.               velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )

  297.               velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )

  298.               velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )

  299.            }

  300.            else

  301.            {

  302.               velocity[0]=0

  303.               velocity[1]=0

  304.               velocity[2]=0

  305.            }

  306.          

  307.            kz_velocity_set(id, velocity)

  308.          

  309.         }

  310.          

  311.         public hook_on(id)

  312.         {

  313.            if (get_cvar_num("sv_adminhook")==1)

  314.               {

  315.                 server_cmd("amx_granthook @all")

  316.               if (gAllowedHook[id]) {

  317.                  if (!gIsHooked[id] && is_user_alive(id))

  318.                  {

  319.                     new cmd[32]

  320.                     read_argv(0,cmd,31)

  321.                     if(equal(cmd,"+rope")) RopeAttach(id,0)

  322.                     if(equal(cmd,"+hook")) RopeAttach(id,1)

  323.                  }

  324.               }else{

  325.                  client_print(id,print_chat,"[%s] Nincs elerhetoseged hozza",gModName)

  326.                  return PLUGIN_HANDLED

  327.               }

  328.            }else{

  329.               client_print(id,print_chat,"[%s] Ez a parancs ki van kapcsolva",gModName)

  330.            }

  331.            return PLUGIN_HANDLED

  332.         }

  333.          

  334.         public hook_off(id)

  335.         {

  336.            if (gAllowedHook[id]) {

  337.               if (gIsHooked[id])

  338.               {

  339.                  RopeRelease(id)

  340.               }

  341.            }else{

  342.               client_print(id,print_chat,"[%s] Nincs elerhetoseged hozza",gModName)

  343.               return PLUGIN_HANDLED

  344.            }

  345.            return PLUGIN_HANDLED

  346.         }

  347.          

  348.         public RopeAttach(id,hook)

  349.         {

  350.            new parm[1], user_origin[3]

  351.            parm[0] = id

  352.            gIsHooked[id] = true

  353.            get_user_origin(id,user_origin)

  354.            get_user_origin(id,gHookLocation[id], 3)

  355.            gHookLenght[id] = get_distance(gHookLocation[id],user_origin)

  356.            global_gravity = get_cvar_num("sv_gravity")

  357.            set_user_gravity(id,0.001)

  358.            beamentpoint(id)

  359.            emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)

  360.            if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")

  361.            else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")

  362.         }

  363.          

  364.         public RopeRelease(id)

  365.         {

  366.            gIsHooked[id] = false

  367.            killbeam(id)

  368.            set_user_gravity(id)

  369.            remove_task(200+id)

  370.         }

  371.          

  372.         public beamentpoint(id)

  373.         {

  374.            message_begin( MSG_BROADCAST, SVC_TEMPENTITY )

  375.            write_byte( TE_BEAMENTPOINT )

  376.            write_short( id )

  377.            write_coord( gHookLocation[id][0] )

  378.            write_coord( gHookLocation[id][1] )

  379.            write_coord( gHookLocation[id][2] )

  380.            write_short( beam )   // sprite index

  381.            write_byte( 0 )      // start frame

  382.            write_byte( 0 )      // framerate

  383.            write_byte( BEAMLIFE )   // life

  384.            write_byte( 10 )   // width

  385.            write_byte( 0 )      // noise

  386.            if (get_user_team(id)==1)      // Terrorist

  387.            {

  388.               write_byte( 255 )   // r, g, b

  389.               write_byte( 0 )   // r, g, b

  390.               write_byte( 0 )   // r, g, b

  391.            }

  392.            else                     // Counter-Terrorist

  393.            {

  394.               write_byte( 0 )   // r, g, b

  395.               write_byte( 0 )   // r, g, b

  396.               write_byte( 255 )   // r, g, b

  397.            }

  398.            write_byte( 150 )   // brightness

  399.            write_byte( 0 )      // speed

  400.            message_end( )

  401.            gBeamIsCreated[id] = get_gametime()

  402.         }

  403.          

  404.         public killbeam(id)

  405.         {

  406.            message_begin( MSG_BROADCAST, SVC_TEMPENTITY )

  407.            write_byte( TE_KILLBEAM )

  408.            write_short( id )

  409.            message_end()

  410.         }

  411.          

  412.         /************************************************************************************************************************/

  413.         /******************************************************* FORWARDS *******************************************************/

  414.         /************************************************************************************************************************/

  415.          

  416.         public client_disconnect(id) {

  417.            gAllowedHook[id]=0

  418.         }

  419.          

  420.         /************************************************************************************************************************/

  421.         /************************************************** AMXX -> AMX funcs ***************************************************/

  422.         /************************************************************************************************************************/

  423.         #if USING_AMX

  424.            stock get_user_button(id) return entity_get_int(id, EV_INT_button)

  425.         #endif

  426.          


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Hook
HozzászólásElküldve:2012.05.14. 19:22 
Offline
Developer
Avatar

Csatlakozott:2011.06.01. 21:11
Hozzászólások:7966
Megköszönt másnak: 295 alkalommal
Megköszönték neki: 537 alkalommal
Decuki:

Kód:
#define USING_AMX 0 // 1 = Using AMX \ 0 = Useing AMXX
 
#if USING_AMX
   #include <amxmod>
   #include <amxmisc>
   #include <VexdUM>
   #include <fun>
   new gModName[32] = "AMX"
#else
   #include <amxmodx>
   #include <amxmisc>
   #include <fun>
   #include <engine>
   new gModName[32] = "AMXX"
#endif

_________________
http://www.easyrankup.eu


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Hook
HozzászólásElküldve:2012.05.16. 21:20 
Offline
Nagyúr
Avatar

Csatlakozott:2011.12.18. 10:40
Hozzászólások:671
Megköszönt másnak: 5 alkalommal
Megköszönték neki: 20 alkalommal
https://forums.alliedmods.net/showthread.php?t=63271
Kód:
sv_hookinstant 1
ez egyböl oda huzza majd a playert mint az admin hookban, de ha csak a rope miatt akarod bocsi:D

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


Ki van itt

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