Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
public plugin_init()
{
register_plugin("Door Mod", "1", "Jake")
}
public client_prethink(id)
{
new entbody, entid
get_user_aiming(id,entid,entbody,200)
if(entity_get_int(id,EV_INT_button) & IN_USE && !(entity_get_int(id,EV_INT_oldbuttons) & IN_USE))
{
force_use(id,entid)
fake_touch(entid,id)
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
Change to the line below. When you put 200 in there, the only time the door will open is if the client is exactly 200 units away from the door. If you want to open the door only when the client is within 200 units of the door, check the distance between the client and door with
get_distance.
Code:
get_user_aiming(id,entid,entbody)
I don't actually know for sure if this function is case sensitive, but I always write it like this:
Code:
public client_PreThink
Other than that , it looks ok. I don't know if fake_touch is necessary. You can omit the return inside of the if.
EDIT: Hawk is right, passing 200 for the distance doesn't do what I thought it did. I didn't test it correctly when I was playing around with it. Sorry about that.