Raised This Month: $ Target: $400
 0% 

Find if a user has pressed a button?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blackops7799
Senior Member
Join Date: May 2006
Old 02-12-2007 , 20:08   Find if a user has pressed a button?
Reply With Quote #1

I was wondering how I would go about making it so if a user on my server hits a button they get slayed, at the same time not making the button work?

The Entid for the button is "661"
Its target is "diner_robber"

This button is used to crash the server so yea...


Edit: I know how to remove it, I just think it would be funny if they were slayed with a message on everyones screen saying (%s HAS BEEN SLAIN FOR USING THE SERVER CRASH BUTTON!"
blackops7799 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 02-12-2007 , 20:35   Re: Find if a user has pressed a button?
Reply With Quote #2

I assume when you mean "Is target is "diner_robber". I'm assuming that the pev_target of the entity. I only coded this I havn't test it any further than that. Also if there is more than one entity with that label as target it will probably screw it up.

Code:
#include <amxmodx> #include <fakemeta> new button; public plugin_init() {     register_plugin("Who", "0.00", "hat");     button = engfunc(EngFunc_FindEntityByString, -1, "target", "diner_robber");     if(button)         register_forward(FM_CmdStart, "_FM_CmdStart"); } public _FM_CmdStart(player, uc_handle, random_seed) {     if(is_user_alive(player))     {         new buttons = get_uc(uc_handle, UC_Buttons);         if(buttons & IN_USE && !(pev(player, pev_oldbuttons) & IN_USE))         {             static ent, body;             if(get_user_aiming(player, ent, body) != 0.0)             {                 if(pev_valid(ent) && ent == button)                 {                     buttons &= ~IN_USE;                     set_uc(uc_handle, UC_Buttons, buttons);                     user_kill(player);                     return FMRES_HANDLED;                 }             }         }     }     return FMRES_IGNORED; }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-12-2007 , 20:37   Re: Find if a user has pressed a button?
Reply With Quote #3

blackops7799: You can't hook when an entity is used.

teame06: That will only work if the user's crosshair is placed directly over the button when pressing it.

EDIT: This is now possible through sawce's Ham Sandwich module.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS

Last edited by XxAvalanchexX; 03-05-2007 at 19:19.
XxAvalanchexX is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 02-12-2007 , 20:47   Re: Find if a user has pressed a button?
Reply With Quote #4

Oh yea, I forgot you can still press the button while not aiming at it.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
blackops7799
Senior Member
Join Date: May 2006
Old 02-12-2007 , 20:56   Re: Find if a user has pressed a button?
Reply With Quote #5

Well, can I remove the button, and if they are in the area of where the button was and press E they will be killed.
blackops7799 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-05-2007 , 13:25   Re: Find if a user has pressed a button?
Reply With Quote #6

Ham Sandwich module by sawce can hook and block the actual use (not the command but so called "event").
VEN is offline
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 05:18.


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