Page 2 of 2

Re: Press Button Info

Posted: 04 Sep 2018, 11:42
by czirimbolo
Raheem wrote: 6 years ago +Like sam. And it may cause some spam so we may make it appear for admins only.
Can you make it appear for admins only? Now, every player see this message

Re: Press Button Info

Posted: 04 Sep 2018, 22:45
by Mark
czirimbolo wrote: 5 years ago
Raheem wrote: 6 years ago +Like sam. And it may cause some spam so we may make it appear for admins only.
Can you make it appear for admins only? Now, every player see this message
This should only show to Admin with ADMIN_CHECK ADMIN_KICK //Flag C
  1. #include <zombie_escape>
  2.  
  3. #define PLUGIN    "Button Info"
  4. #define AUTHOR    "SeRious_SaM"
  5. #define VERSION    "1.0"
  6. #define ADMIN_CHECK ADMIN_KICK //Flag C
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin(PLUGIN, VERSION, AUTHOR)
  11.     RegisterHam(Ham_Use,"func_button","fwButtonUsed",1)
  12. }
  13.  
  14.    
  15. public fwButtonUsed( ent, idcaller )
  16.     {
  17.         new szName[33];
  18.         get_user_name( idcaller, szName, charsmax( szName ) );
  19.        
  20.         if(get_user_flags(idcaller) & ADMIN_CHECK)
  21.         {
  22.             ze_colored_print( 0, "!y[!gZombie Escape!y]!t %s !gPressed the BUTTON!y!", szName );
  23.         }
  24.     }
  25.  
  26. /* Color Stocks */
  27. stock print_colored( const id, const input[], any: ... )
  28. {
  29.     new count = 1, players[32], i, player;
  30.     static msg[191];
  31.     if ( numargs() == 2 )
  32.         copy( msg, 190, input );
  33.     else
  34.         vformat( msg, 190, input, 3 );
  35.     replace_all( msg, 190, "!g", "^4" );
  36.     replace_all( msg, 190, "!y", "^1" );
  37.     replace_all( msg, 190, "!t", "^3" );
  38.     if ( id )
  39.     {
  40.         if ( !is_user_connected( id ) ) return;
  41.         players[0] = id;
  42.     } else get_players( players, count, "ch" );
  43.     for ( i = 0; i < count; i++ )
  44.     {
  45.         player = players[i];
  46.         message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, player );
  47.         write_byte( player );
  48.         write_string( msg );
  49.         message_end();
  50.     }
  51. }

Re: Press Button Info

Posted: 05 Sep 2018, 20:04
by sPe3doN
Mark wrote: 5 years ago
czirimbolo wrote: 5 years ago
Raheem wrote: 6 years ago +Like sam. And it may cause some spam so we may make it appear for admins only.
Can you make it appear for admins only? Now, every player see this message
This should only show to Admin with ADMIN_CHECK ADMIN_KICK //Flag C
  1. #include <zombie_escape>
  2.  
  3. #define PLUGIN    "Button Info"
  4. #define AUTHOR    "SeRious_SaM"
  5. #define VERSION    "1.0"
  6. #define ADMIN_CHECK ADMIN_KICK //Flag C
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin(PLUGIN, VERSION, AUTHOR)
  11.     RegisterHam(Ham_Use,"func_button","fwButtonUsed",1)
  12. }
  13.  
  14.    
  15. public fwButtonUsed( ent, idcaller )
  16.     {
  17.         new szName[33];
  18.         get_user_name( idcaller, szName, charsmax( szName ) );
  19.        
  20.         if(get_user_flags(idcaller) & ADMIN_CHECK)
  21.         {
  22.             ze_colored_print( 0, "!y[!gZombie Escape!y]!t %s !gPressed the BUTTON!y!", szName );
  23.         }
  24.     }
  25.  
  26. /* Color Stocks */
  27. stock print_colored( const id, const input[], any: ... )
  28. {
  29.     new count = 1, players[32], i, player;
  30.     static msg[191];
  31.     if ( numargs() == 2 )
  32.         copy( msg, 190, input );
  33.     else
  34.         vformat( msg, 190, input, 3 );
  35.     replace_all( msg, 190, "!g", "^4" );
  36.     replace_all( msg, 190, "!y", "^1" );
  37.     replace_all( msg, 190, "!t", "^3" );
  38.     if ( id )
  39.     {
  40.         if ( !is_user_connected( id ) ) return;
  41.         players[0] = id;
  42.     } else get_players( players, count, "ch" );
  43.     for ( i = 0; i < count; i++ )
  44.     {
  45.         player = players[i];
  46.         message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, player );
  47.         write_byte( player );
  48.         write_string( msg );
  49.         message_end();
  50.     }
  51. }
this will show for admin only if aonther admin use the button

Re: Press Button Info

Posted: 09 Sep 2018, 00:26
by Raheem
  1. #include <zombie_escape>
  2.  
  3. #define PLUGIN    "Button Info"
  4. #define AUTHOR    "SeRious_SaM"
  5. #define VERSION    "1.0"
  6. #define ADMIN_CHECK ADMIN_KICK //Flag C
  7.  
  8. new g_iMaxPlayers
  9.  
  10. public plugin_init()
  11. {
  12.     register_plugin(PLUGIN, VERSION, AUTHOR)
  13.     RegisterHam(Ham_Use,"func_button","Fw_ButtonUsed_Post",1)
  14.    
  15.     g_iMaxPlayers = get_member_game(m_nMaxPlayers)
  16. }
  17.  
  18.    
  19. public Fw_ButtonUsed_Post(iEnt, iCaller)
  20. {
  21.     new szName[32];
  22.     get_user_name(iCaller, szName, charsmax(szName));
  23.    
  24.     for(new id = 1; id <= g_iMaxPlayers; id++)
  25.     {
  26.         if (!is_user_connected(id) || !(get_user_flags(id) & ADMIN_CHECK))
  27.             continue
  28.        
  29.         ze_colored_print(id, "!y[!gZombie Escape!y]!t %s !gPressed the BUTTON!y!", szName);
  30.     }
  31. }

Re: Press Button Info

Posted: 10 Oct 2018, 05:22
by shady101852
Raheem wrote: 5 years ago
  1. #include <zombie_escape>
  2.  
  3. #define PLUGIN    "Button Info"
  4. #define AUTHOR    "SeRious_SaM"
  5. #define VERSION    "1.0"
  6. #define ADMIN_CHECK ADMIN_KICK //Flag C
  7.  
  8. new g_iMaxPlayers
  9.  
  10. public plugin_init()
  11. {
  12.     register_plugin(PLUGIN, VERSION, AUTHOR)
  13.     RegisterHam(Ham_Use,"func_button","Fw_ButtonUsed_Post",1)
  14.    
  15.     g_iMaxPlayers = get_member_game(m_nMaxPlayers)
  16. }
  17.  
  18.    
  19. public Fw_ButtonUsed_Post(iEnt, iCaller)
  20. {
  21.     new szName[32];
  22.     get_user_name(iCaller, szName, charsmax(szName));
  23.    
  24.     for(new id = 1; id <= g_iMaxPlayers; id++)
  25.     {
  26.         if (!is_user_connected(id) || !(get_user_flags(id) & ADMIN_CHECK))
  27.             continue
  28.        
  29.         ze_colored_print(id, "!y[!gZombie Escape!y]!t %s !gPressed the BUTTON!y!", szName);
  30.     }
  31. }
any way to prevent chat spam with this? If someone spams a button the chat will be spammed as well xD

Re: Press Button Info

Posted: 11 Oct 2018, 04:19
by Raheem
We can add delay but won't be useful as maybe one close door and not printed on chat.

If you have good idea for limiting this, let me know.

Re: Press Button Info

Posted: 11 Oct 2018, 04:31
by shady101852
Raheem wrote: 5 years ago We can add delay but won't be useful as maybe one close door and not printed on chat.

If you have good idea for limiting this, let me know.
If a player presses a button 2 times in a duration of 5 seconds, block the rest of his button messages for the next 5 seconds. Example: I open a door, then i close it.
Shady pressed a button
Shady pressed a button
After that second one the rest of the messages will be blocked for the next 5 seconds. Now lets have another situation.
Shady pressed a button
In this case, if the player doesn't press a button again in the next 5 seconds, the message block limit will be reset and he can press the button 2 more times again
Shady pressed a button
Shady pressed a button
Then message block.

Do not do this:
Shady pressed a button
After 5 seconds:
Shady pressed a button
(do not block the chat at this point)

So basically they can still spam, but only every 5 seconds. And their limiter gets reset every 5 seconds. Not sure if this is possible but I think its a good way to deal with it. It would be good if you can do this on the version that shows the message only to admins since not many people will be aware of the chat message, but its still a little precaution that could be useful. I can't imagine someone needing to press a button more than once in 10 seconds unless they want to open and close a door or something.

Re: Press Button Info

Posted: 12 Oct 2018, 09:19
by Raheem
Player pressed button, it will print message that he pressed. Then after 5 seconds it will print again if he pressed. If he pressed during delay then nothing will be printed.

  1. #include <zombie_escape>
  2.  
  3. #define PLUGIN    "Button Info"
  4. #define AUTHOR    "SeRious_SaM"
  5. #define VERSION    "1.0"
  6. #define ADMIN_CHECK ADMIN_KICK //Flag C
  7.  
  8. #define DELAY 5 // Delay 5 second for same user
  9.  
  10. new g_iMaxPlayers
  11.  
  12. new g_iLastUsed[33]
  13.  
  14. public plugin_init()
  15. {
  16.     register_plugin(PLUGIN, VERSION, AUTHOR)
  17.     RegisterHam(Ham_Use,"func_button","Fw_ButtonUsed_Post",1)
  18.    
  19.     g_iMaxPlayers = get_member_game(m_nMaxPlayers)
  20. }
  21.  
  22. public Fw_ButtonUsed_Post(iEnt, iCaller)
  23. {
  24.     new szName[32];
  25.     get_user_name(iCaller, szName, charsmax(szName));
  26.    
  27.     for(new id = 1; id <= g_iMaxPlayers; id++)
  28.     {
  29.         if (!is_user_connected(id) || !(get_user_flags(id) & ADMIN_CHECK))
  30.             continue
  31.        
  32.         if (floatround(get_gametime()) >= g_iLastUsed[iCaller] + DELAY)
  33.         {
  34.             ze_colored_print(id, "!y[!gZombie Escape!y]!t %s !gPressed the BUTTON!y!", szName);
  35.            
  36.             g_iLastUsed[iCaller] = floatround(get_gametime());
  37.         }
  38.     }
  39. }

Re: Press Button Info

Posted: 29 Jun 2021, 12:52
by VicKy
can you make this only in consule
its spamming in server

Re: Press Button Info

Posted: 29 Jun 2021, 22:31
by karan
Raheem wrote: 5 years ago Player pressed button, it will print message that he pressed. Then after 5 seconds it will print again if he pressed. If he pressed during delay then nothing will be printed.

  1. #include <zombie_escape>
  2.  
  3. #define PLUGIN    "Button Info"
  4. #define AUTHOR    "SeRious_SaM"
  5. #define VERSION    "1.0"
  6. #define ADMIN_CHECK ADMIN_KICK //Flag C
  7.  
  8. #define DELAY 5 // Delay 5 second for same user
  9.  
  10. new g_iMaxPlayers
  11.  
  12. new g_iLastUsed[33]
  13.  
  14. public plugin_init()
  15. {
  16.     register_plugin(PLUGIN, VERSION, AUTHOR)
  17.     RegisterHam(Ham_Use,"func_button","Fw_ButtonUsed_Post",1)
  18.    
  19.     g_iMaxPlayers = get_member_game(m_nMaxPlayers)
  20. }
  21.  
  22. public Fw_ButtonUsed_Post(iEnt, iCaller)
  23. {
  24.     new szName[32];
  25.     get_user_name(iCaller, szName, charsmax(szName));
  26.    
  27.     for(new id = 1; id <= g_iMaxPlayers; id++)
  28.     {
  29.         if (!is_user_connected(id) || !(get_user_flags(id) & ADMIN_CHECK))
  30.             continue
  31.        
  32.         if (floatround(get_gametime()) >= g_iLastUsed[iCaller] + DELAY)
  33.         {
  34.             ze_colored_print(id, "!y[!gZombie Escape!y]!t %s !gPressed the BUTTON!y!", szName);
  35.            
  36.             g_iLastUsed[iCaller] = floatround(get_gametime());
  37.         }
  38.     }
  39. }
use this one for the delay on same player

Re: Press Button Info

Posted: 29 Jun 2021, 22:32
by karan
VicKy wrote: 2 years ago can you make this only in consule
its spamming in server
increase the delay if needed

Re: Press Button Info

Posted: 23 Jul 2021, 09:38
by wbyokomo
Hi, i just updated the plugin a bit.

Code: Select all

#include <amxmodx>
#include <hamsandwich>
#include <reapi>

#define TIME_COOLDOWN 5.0

public plugin_init()
{
	register_plugin("AMX183 Button Info", "1.0p", "SeRious_SaM,wbyokomo")

	RegisterHam(Ham_Use, "func_button", "OnButtonPressedPost", 1)
}

public OnButtonPressedPost(ent, id)
{
	static Float:fCurTime; fCurTime = get_gametime();
	if(get_entvar(ent, var_flTimeStepSound) <= fCurTime)
	{
		set_entvar(ent, var_flTimeStepSound, fCurTime + TIME_COOLDOWN)
		static szName[32]; get_user_name(id, szName, charsmax(szName));
		client_print_color(0, id, "^4[Waifu Escape]^3 %s^1 just pressed a^3 BUTTON^1 !", szName)
	}
}
Increase cooldown time TIME_COOLDOWN 5.0 if you want to see less message. It use amxmodx >= 183. I don't want to support old amxmodx version.