Approved Press Button Info

Plug-ins compatibility with Zombie Escape 1.x only!


czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#21

Post by czirimbolo » 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
Image

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#22

Post by Mark » 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. }

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#23

Post by sPe3doN » 5 years ago

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
Image

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#24

Post by Raheem » 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. }
He who fails to plan is planning to fail

shady101852
Member
Member
United States of America
Posts: 27
Joined: 5 years ago
Contact:

#25

Post by shady101852 » 5 years ago

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

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#26

Post by Raheem » 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.
He who fails to plan is planning to fail

shady101852
Member
Member
United States of America
Posts: 27
Joined: 5 years ago
Contact:

#27

Post by shady101852 » 5 years ago

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.

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#28

Post by Raheem » 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. }
He who fails to plan is planning to fail

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#29

Post by VicKy » 2 years ago

can you make this only in consule
its spamming in server
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#30

Post by karan » 2 years ago

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
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#31

Post by karan » 2 years ago

VicKy wrote: 2 years ago can you make this only in consule
its spamming in server
increase the delay if needed
Image

User avatar
wbyokomo
VIP
VIP
Malaysia
Posts: 15
Joined: 2 years ago
Location: Malaysia
Contact:

#32

Post by wbyokomo » 2 years ago

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.
[MMG]~Zombie-Escape-X
Image
[MMG]~Zombie-Plague-X
Image
[MMG]~Multi-Mod-X
Image

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 0 guests