Raised This Month: $51 Target: $400
 12% 

help with hook freeze


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
king999
Member
Join Date: Feb 2015
Location: Mars
Old 02-27-2016 , 17:27   help with hook freeze
Reply With Quote #1

hi i hope everyone is ok i really need your help i am working on a project so i am working on this hook so the customer asked me to put so when ever i use hook aimming it at a player he freezes for 5 sec
Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <fakemeta>

#define ADMIN_LEVEL_Q	ADMIN_LEVEL_C
#define RANDOM_NUM random_num(19,655)


new bool:hook[33]
new hook_to[33][3]
new hook_speed_cvar
new hook_enabled_cvar
new bool:has_hook[33]
new beamsprite

public plugin_init()
{
	register_plugin("Lightning Hook","1.0","GHW_Chronic Edit")
	register_concmd("+hook","hook_on",ADMIN_LEVEL_Q," - Use: bind key +hook")
	register_concmd("-hook","hook_off")
	register_concmd("hook_toggle","hook_toggle",ADMIN_LEVEL_Q,"Toggles your hook on and off")
	register_concmd("amx_give_hook","cmd_givetake",ADMIN_LEVEL_Q,"Give a player the ability to hook <nick>")
	register_concmd("amx_take_hook","cmd_givetake",ADMIN_LEVEL_Q,"Take a player's ability to hook <nick>")
	hook_enabled_cvar = register_cvar("hook_enabled","0")
	hook_speed_cvar = register_cvar("hook_speed","7")
}

public plugin_precache()
{
	beamsprite = precache_model("sprites/lighting_hook.spr")
	precache_sound("x/x_shoot1.wav")
	
}


public client_putinserver(id)
{
	has_hook[id]=false
}

public cmd_givetake(id,level,cid)
{
	if(!cmd_access(id,level,cid,2))
	{
		return PLUGIN_HANDLED
	}
	
	new arg1[32]
	read_argv(1,arg1,31)
	
	new target = cmd_target(id,arg1,9)
	if(!target)
	{
		return PLUGIN_HANDLED
	}
	
	new name[32]
	get_user_name(target,name,31)
	if(get_user_flags(target) & ADMIN_LEVEL_Q)
	{
		console_print(id,"[AMXX] Cannot give/take hook from admin %s.",name)
		return PLUGIN_HANDLED
	}
	
	new arg0[32]
	read_argv(0,arg0,31)
	if(containi(arg0,"give")!=-1)
	{
	{
		if(has_hook[target])
		{
			console_print(id,"[AMXX] %s already has hook",name)
		}
		else
		{
			has_hook[target]=true
			console_print(id,"[AMXX] %s has been given hook",name)
			client_print(target,print_chat,"[AMXX] An admin has given you hook. Use: bind key +hook")
		}
	}
	
}
if(containi(arg0,"take")!=-1)
{
	if(containi(arg0,"hook")!=-1)
	{
		if(!has_hook[target])
		{
			console_print(id,"[AMXX] %s doesn't have hook",name)
		}
		else
		{
			has_hook[target]=false
			console_print(id,"[AMXX] %s's hook has been taken away.",name)
			client_print(target,print_chat,"[AMXX] An admin has taken your hook away.")
		}
	}
	
}
return PLUGIN_HANDLED
}

public hook_toggle(id,level,cid)
{
if(hook[id]) hook_off(id)
else hook_on(id,level,cid)
return PLUGIN_HANDLED
}

public hook_on(id,level,cid)
{
if(!has_hook[id] && !get_pcvar_num(hook_enabled_cvar) && !cmd_access(id,level,cid,1))
{
	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,"x/x_shoot1.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
}

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]
}



//Lightnings
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(1)  
write_short(id)  
write_coord(hook_to[id][0])
write_coord(hook_to[id][1])
write_coord(hook_to[id][2])
write_short(beamsprite)
write_byte(0)  // framestart
write_byte(0)  // framerate
write_byte(2)  // life in 0.1's
write_byte(44)  // width
write_byte(0)  // noise
write_byte(RANDOM_NUM) // r  
write_byte(RANDOM_NUM) // g  
write_byte(RANDOM_NUM) // b  
write_byte(255)  // 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
}




public get_origin(ent,Float:origin[3])
{
#if defined engine
return entity_get_vector(id,EV_VEC_origin,origin)
#else
return pev(ent,pev_origin,origin)
#endif
}

public set_velo(id,Float:velocity[3])
{
#if defined engine
return set_user_velocity(id,velocity)
#else
return set_pev(id,pev_velocity,velocity)
#endif
}

public get_velo(id,Float:velocity[3])
{
#if defined engine
return get_user_velocity(id,velocity)
#else
return pev(id,pev_velocity,velocity)
#endif
}

public is_valid_ent2(ent)
{
#if defined engine
return is_valid_ent(ent)
#else
return pev_valid(ent)
#endif
}

public get_solidity(ent)
{
#if defined engine
return entity_get_int(ent,EV_INT_solid)
#else
return pev(ent,pev_solid)
#endif
}

stock set_rendering2(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
{
#if defined engine
return set_rendering(index,fx,r,g,b,render,amount)
#else
set_pev(index, pev_renderfx, fx);
new Float:RenderColor[3];
RenderColor[0] = float(r);
RenderColor[1] = float(g);
RenderColor[2] = float(b);
set_pev(index, pev_rendercolor, RenderColor);
set_pev(index, pev_rendermode, render);
set_pev(index, pev_renderamt, float(amount));
return 1;
#endif
}
if possible can someone help me i cant do it i am finding it hard i have looked around your my last hope please help me thank you
i repeat what i want is so when i aim at someone he freezes for 5 sec.

Last edited by king999; 02-27-2016 at 17:29.
king999 is offline
Send a message via Skype™ to king999
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode