AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [PROBLEM SOLVED]Problem catching pre pre think +commands (https://forums.alliedmods.net/showthread.php?t=26420)

SubStream 04-01-2006 18:45

[PROBLEM SOLVED]Problem catching pre pre think +commands
 
here is what I have so far
Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <fakemeta> new const gs_PLUGIN[]   = "test" new const gs_VERSION[]  = "1.0" new const gs_AUTHOR[]   = "SubStream" new gi_players[32] new gi_playercnt new gi_playernum new gi_playerID public plugin_init () {     register_plugin ( gs_PLUGIN, gs_VERSION, gs_AUTHOR )     register_forward ( FM_PlayerPreThink, "fn_hookprethink" ) } public fn_hookprethink ( id ) {     if ( get_user_button ( id ) & IN_ATTACK )     {         entity_set_int ( id, EV_INT_button, get_user_button ( id ) & ~IN_ATTACK )                 fn_saymessage ()                 return FMRES_SUPERCEDE     }         else     {         return FMRES_IGNORED     } } public fn_saymessage () {     get_players ( gi_players, gi_playercnt, "ch" )         for ( gi_playernum = 0; gi_playernum < gi_playercnt; gi_playernum++ )     {         gi_playerID = gi_players[gi_playernum]                 client_print ( gi_playerID, print_center, "hello its working" )                 return PLUGIN_HANDLED     }         return PLUGIN_HANDLED }

I am testing to see if I can block +attack... I have read other forums threads in here about this but haven't got it working yet ... I have looked up as much as I can and according to other topics posted this is supposed to work but its not. Can someone tell me what I am doing wrong I appreciate any help to actually get this working. My goal is to block +attack.

The message shows up when I press the attack button, but I am still allowed to fire.

I already looked at Restricting buttons if you need to reference to where I got my information.

Edit:

Ven solved the problem. Thank you Ven I appreciate it.

v3x 04-01-2006 18:51

Well first of all change:
Code:
else {   return PLUGIN_CONTINUE }
to
Code:
return FMRES_IGNORED

SubStream 04-01-2006 19:01

ok now what? lol

[ --<-@ ] Black Rose 04-01-2006 20:56

u can do that? what is it?
Code:
get_user_button ( id ) & -IN_ATTACK

SubStream 04-01-2006 21:04

Quote:

Originally Posted by [ --<-@
Black Rose]u can do that? what is it?
Code:
get_user_button ( id ) & -IN_ATTACK

In another thread it said to make sure to block -IN_ATTACK also... so I tried that too... even with only IN_ATTACK it doesn't work... but I think that -IN_ATTACK isn't even recognized at all. I was just trying something that someone else posted... but I guess that it's nothing.

Edit:

Check first post I updated the code. I tried doing what was said on another post and it simply does not work. Can someone finalize if it is in fact possible to block +attack and all the other commands or is it simply not possible.

VEN 04-03-2006 14:33

First of all - a common mistake is recognizing whether button blocked or not by player's animation/decals/etc. All that done on the client's side while on the server side only actual button state is altered. Your code will block "the bullets" but not the animation etc.
Also it's not a good idea to block player's entity from thinking neither it's necessary (at least in this case).


All times are GMT -4. The time now is 16:46.

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