Hello Hook have this plugin but not working properly.
The problem there is that when someone finish off a map in the Hook not working
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#define KZ_LEVEL ADMIN_KICK
new bool:canusehook[32]
new bool:ishooked[32]
new hookorigin[32][3]
new Sbeam
public plugin_init() {
register_plugin("ProKreedzHook","1.0","p4ddY")
register_clcmd("+hook","hook_on",KZ_LEVEL)
register_clcmd("-hook","hook_off",KZ_LEVEL)
register_srvcmd("kz_hook","give_hook_cmd")
}
public plugin_precache() {
precache_sound("weapons/xbow_hit2.wav")
Sbeam = precache_model("sprites/laserbeam.spr")
}
public client_disconnect(id) {
remove_hook(id)
}
public client_putinserver(id) {
remove_hook(id)
}
public give_hook_cmd(id,level,cid) {
new szarg1[33], szarg2[8], bool:mode
read_argv(1,szarg1,32)
read_argv(2,szarg2,7)
remove_quotes(szarg1)
remove_quotes(szarg2)
if(equal(szarg2,"on"))
mode = true
new pid = cmd_target(id,szarg1,0)
if(pid) {
if(canusehook[pid-1] == mode)
return PLUGIN_CONTINUE
canusehook[pid-1] = mode
if(mode) {
client_print(id,print_chat,"")
}
else
client_print(id,print_chat,"")
}
return PLUGIN_CONTINUE
}
public hook_on(id,level,cid) {
if(!canusehook[id-1] && !cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
get_user_origin(id,hookorigin[id-1],3)
ishooked[id-1] = true
emit_sound(id,CHAN_STATIC,"weapons/xbow_hit2.wav",1.0,ATTN_NORM,0,PITCH_NORM)
set_task(0.1,"hook_task",id,"",0,"ab")
hook_task(id)
return PLUGIN_HANDLED
}
public is_hooked(id) {
return ishooked[id-1]
}
public hook_off(id) {
remove_hook(id)
return PLUGIN_HANDLED
}
public hook_task(id) {
if(!is_user_connected(id) || !is_user_alive(id))
remove_hook(id)
remove_beam(id)
draw_hook(id)
new origin[3], Float:velocity[3]
get_user_origin(id,origin)
new distance = get_distance(hookorigin[id-1],origin)
if(distance > 25) {
velocity[0] = (hookorigin[id-1][0] - origin[0]) * (2.0 * 300 / distance)
velocity[1] = (hookorigin[id-1][1] - origin[1]) * (2.0 * 300 / distance)
velocity[2] = (hookorigin[id-1][2] - origin[2]) * (2.0 * 300 / distance)
entity_set_vector(id,EV_VEC_velocity,velocity)
}
else {
entity_set_vector(id,EV_VEC_velocity,Float:{0.0,0.0,0.0})
remove_hook(id)
}
}
public draw_hook(id) {
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(1)
write_short(id)
write_coord(hookorigin[id-1][0])
write_coord(hookorigin[id-1][1])
write_coord(hookorigin[id-1][2])
write_short(Sbeam)
write_byte(0)
write_byte(0)
write_byte(100)
write_byte(10)
write_byte(0)
if(get_user_team(id) == 1) {
write_byte(255)
write_byte(0)
write_byte(0)
}
else {
write_byte(0)
write_byte(0)
write_byte(255)
}
write_byte(150)
write_byte(0)
message_end()
}
public remove_hook(id) {
if(task_exists(id))
remove_task(id)
remove_beam(id)
ishooked[id-1] = false
}
public remove_beam(id) {
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(99)
write_short(id)
message_end()
}