| NiGHTFiRE |
02-16-2005 09:07 |
it
if you change that the code should be
Quote:
#include <amxmod>
#include <amxmodx>
#include <engine>
new grabbed[33]
new grablength[33]
new bool:grabmodeon[33]
new velocity_multiplier
public grabtask(parm[])
{
new id = parm[0]
new targetid, body
if (!grabbed[id])
{
get_user_aiming(id, targetid, body)
if (targetid)
{
set_grabbed(id, targetid)
}
}
if (grabbed[id])
{
new origin[3], look[3], direction[3], moveto[3], grabbedorigin[3], velocity[3], length
if (!is_user_alive(grabbed[id]))
{
release(id)
return
}
get_user_origin(id, origin, 1)
get_user_origin(id, look, 3)
get_user_origin(grabbed[id], grabbedorigin)
direction[0]=look[0]-origin[0]
direction[1]=look[1]-origin[1]
direction[2]=look[2]-origin[2]
length = get_distance(look,origin)
if (!length) length=1 // avoid division by 0
moveto[0]=origin[0]+direction[0]*grablength[id]/length
moveto[1]=origin[1]+direction[1]*grablength[id]/length
moveto[2]=origin[2]+direction[2]*grablength[id]/length
velocity[0]=(moveto[0]-grabbedorigin[0])*velocity_multiplier
velocity[1]=(moveto[1]-grabbedorigin[1])*velocity_multiplier
velocity[2]=(moveto[2]-grabbedorigin[2])*velocity_multiplier
set_user_velocity(grabbed[id], velocity)
}
}
public grab_toggle(id)
{
if (grabmodeon[id])
release(id)
else
grab(id)
return PLUGIN_HANDLED
}
public grab(id)
{
if (!(get_user_flags(id)&ADMIN_SLAY))
{
client_print(id,print_notify,"[AMX] You have no access to that command")
return PLUGIN_HANDLED
}
if (!grabmodeon[id])
{
new targetid, body
new parm[1]
parm[0] = id
velocity_multiplier = get_cvar_num("sv_grabforce")
grabmodeon[id]=true
set_task(0.1, "grabtask", 100+id, parm, 1, "b")
get_user_aiming(id, targetid, body)
if (targetid)
{
set_grabbed(id, targetid)
}
else
{
client_print(id,print_notify,"[AMX] Searching for a target")
}
}
return PLUGIN_HANDLED
}
public release(id)
{
if (!(get_user_flags(id)&ADMIN_SLAY))
{
client_print(id,print_notify,"[AMX] You have no access to that command")
return PLUGIN_HANDLED
}
if (grabmodeon[id])
{
grabmodeon[id]=false
if (grabbed[id])
{
new targname[32]
set_user_gravity(grabbed[id])
set_user_rendering(grabbed[id])
get_user_name(grabbed[id],targname,31)
client_print(id,print_notify,"[AMX] You have released %s", targname)
}
else
{
client_print(id,print_notify,"[AMX] No target found")
}
grabbed[id]=0
remove_task(100+id)
}
return PLUGIN_HANDLED
}
public spec_event(id)
{
new targetid = read_data(2)
if (targetid < 1 || targetid > 32)
return PLUGIN_CONTINUE
if (grabmodeon[id] && !grabbed[id])
{
set_grabbed(id, targetid)
}
return PLUGIN_CONTINUE
}
public set_grabbed(id, targetid)
{
new origin1[3], origin2[3], targname[32]
get_user_origin(id, origin1)
get_user_origin(targetid, origin2)
grabbed[id]=targetid
grablength[id]=get_distance(origin1,origin2)
set_user_gravity(targetid,0.001)
set_user_rendering(targetid,kRenderFxGlowShel l,10,145,245, kRenderNormal, 0)
get_user_name(targetid,targname,31)
client_print(id,print_notify,"[AMX] You have grabbed onto %s", targname)
}
public plugin_init()
{
register_plugin("Jedi Force Grab","1.1","SpaceDude")
register_cvar("sv_grabforce","8")
register_clcmd("grab_toggle","grab_toggle",AD MIN_SLAY,"press once to grab and again to release")
register_clcmd("+grab","grab",ADMIN_SLAY,"bin d a key to +grab")
register_clcmd("-grab","release",ADMIN_SLAY)
register_event("StatusValue","spec_event","be ","1=2")
}
|
I'm not sure though why amxmod is ni this.
|