AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   +Use to open door (https://forums.alliedmods.net/showthread.php?t=50319)

blackops7799 01-23-2007 20:43

+Use to open door
 
I run a zombie server for TS and I have to remove all the doors in order for the players to get into buildings and stuff.

Then a friend recommended a mod that can open the door on +use.

We both tried making them but we both failed.

This is what I have.


Not sure if I did this right... lol.
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 }

stupok 01-23-2007 20:50

Re: +Use to open door
 
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.

Hawk552 01-23-2007 21:18

Re: +Use to open door
 
Quote:

Originally Posted by stupok69 (Post 430832)
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.

Disregard this comment, it's wrong.

Quote:

Originally Posted by stupok69 (Post 430832)
I don't actually know for sure if this function is case sensitive, but I always right 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.

"Right" is inappropriate in this context.

Also, if that doesn't work, try changing the fake_touch/force_use block to this:

Code:
force_use(entid,entid) fake_touch(entid,entid)

blackops7799 01-23-2007 21:53

Re: +Use to open door
 
well its working, but Im getting spammed in my console and it is also freezing alot.

Code:

L 01/23/2007 - 21:03:06: [ENGINE] Invalid player 0 (not in-game)
L 01/23/2007 - 21:03:06: [AMXX] Displaying debug trace (plugin "doormod.amxx")
L 01/23/2007 - 21:03:06: [AMXX] Run time error 10: native error (native "force_use")
L 01/23/2007 - 21:03:06: [AMXX]    [0] doormod.sma::client_PreThink (line 15)


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 }

Hawk552 01-23-2007 22:33

Re: +Use to open door
 
Try changing it to the thing I said before.


All times are GMT -4. The time now is 22:24.

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