AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Find if a user has pressed a button? (https://forums.alliedmods.net/showthread.php?t=51170)

blackops7799 02-12-2007 20:08

Find if a user has pressed a button?
 
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!"

teame06 02-12-2007 20:35

Re: Find if a user has pressed a button?
 
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; }

XxAvalanchexX 02-12-2007 20:37

Re: Find if a user has pressed a button?
 
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.

teame06 02-12-2007 20:47

Re: Find if a user has pressed a button?
 
Oh yea, I forgot you can still press the button while not aiming at it.

blackops7799 02-12-2007 20:56

Re: Find if a user has pressed a button?
 
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.

VEN 03-05-2007 13:25

Re: Find if a user has pressed a button?
 
Ham Sandwich module by sawce can hook and block the actual use (not the command but so called "event").


All times are GMT -4. The time now is 00:36.

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