I need to change this code so it works for only 1 person not for all..can't seem to find the right thing.
I used the hook body from Ghw_cronic's hook plugin(of course credits given):
Code:
public hook_on(id,level,cid)
{
if(!has_hook[id] && !get_pcvar_num(hook_enabled_cvar))
{
return PLUGIN_HANDLED
}
if(hook[id])
{
return PLUGIN_HANDLED
}
set_user_gravity(id,0.0)
set_task(0.1,"hook_prethink",id+10000,"",0,"b")
hook[id]=true
hook_to[id][0]=999999
hook_prethink(id+10000)
emit_sound(id,CHAN_VOICE,"weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
return PLUGIN_HANDLED
}
public hook_off(id)
{
if(is_user_alive(id)) set_user_gravity(id)
hook[id]=false
return PLUGIN_HANDLED
}
public hook_prethink(id)
{
id -= 10000
if(!is_user_alive(id))
{
hook[id]=false
}
if(!hook[id])
{
remove_task(id+10000)
return PLUGIN_HANDLED
}
//Get Id's origin
static origin1[3]
get_user_origin(id,origin1)
if(hook_to[id][0]==999999)
{
static origin2[3]
get_user_origin(id,origin2,3)
hook_to[id][0]=origin2[0]
hook_to[id][1]=origin2[1]
hook_to[id][2]=origin2[2]
}
//Create blue beam
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(1) //TE_BEAMENTPOINT
write_short(id) // start entity
write_coord(hook_to[id][0])
write_coord(hook_to[id][1])
write_coord(hook_to[id][2])
write_short(beamsprite)
write_byte(1) // framestart
write_byte(1) // framerate
write_byte(2) // life in 0.1's
write_byte(15) // width
write_byte(7) // noise
write_byte(31) // red
write_byte(180) // green
write_byte(160) // blue
write_byte(200) // brightness
write_byte(0) // speed
message_end()
//Calculate Velocity
static Float:velocity[3]
velocity[0] = (float(hook_to[id][0]) - float(origin1[0])) * 3.0
velocity[1] = (float(hook_to[id][1]) - float(origin1[1])) * 3.0
velocity[2] = (float(hook_to[id][2]) - float(origin1[2])) * 3.0
static Float:y
y = velocity[0]*velocity[0] + velocity[1]*velocity[1] + velocity[2]*velocity[2]
static Float:x
x = (get_pcvar_float(hook_speed_cvar) * 120.0) / floatsqroot(y)
velocity[0] *= x
velocity[1] *= x
velocity[2] *= x
set_velo(id,velocity)
return PLUGIN_CONTINUE
}
PS..a mod should delete this post as it's in the wrong section..