Raised This Month: $51 Target: $400
 12% 

Reset buttons at round start


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Event Related        Approver:   Exolent[jNr] (178)
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-14-2009 , 11:57   Reset buttons at round start
Reply With Quote #1

Reset buttons
At round start
By xPaw

.: Description :.
This plugin was mainly done for deathrun servers, did you had situation when you are terrorist and pressing button, then cts die, and in new round the button is still red? this plugin is for you, it makes all buttons to be usable at new round aka resets buttons / makes them green.
Attached Files
File Type: sma Get Plugin or Get Source (ResetButtons.sma - 10945 views - 342 Bytes)
__________________

Last edited by xPaw; 02-14-2010 at 12:29.
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-14-2009 , 12:09   Re: Reset buttons at round start
Reply With Quote #2

You could start at max_clients + 1.

Btw :
Quote:
Originally Posted by xPaw View Post
By the way, this plugin is gay
Arkshine is offline
kabul
BANNED
Join Date: Feb 2009
Old 05-14-2009 , 21:33   Re: Reset buttons at round start
Reply With Quote #3

Nice, but I was wondering, can you also make a plugin that sets a delay for all buttons that you have pressed, something like 20 seconds or so? The reason why I am asking is because there are some maps like deathrun_projetocs2 where the terrorists like to make abuse of the buttons. Thanks in advance if you can help.
kabul is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-14-2009 , 22:05   Re: Reset buttons at round start
Reply With Quote #4

starting at gMaxplayers or gMaxplayers+1 is crap, no matter which way you use... you have to set the iButton var although you dont have to + you use an operator, i hope you see why its crap.
tbh, both of you should have seen several plugin which search for an entity by a given classname by find_ent_by_* or EngFunc_FindEntityByString. did you ever see someone setting the startvalue to gMaxplayers?

PHP Code:
// tested, works
#include <amxmodx>
#include <fakemeta>

#pragma semicolon 1

public plugin_init( )
{
    
register_plugin"I""<3""xPaw" );
    
register_event"HLTV""eventHLTV""a""1=0""2=0" );
}

public 
eventHLTV( )
{
    new 
ent;
    while( ( 
ent engfuncEngFunc_FindEntityByStringent"classname""func_button" ) ) != )
    {
        
dllfuncDLLFunc_Thinkent );
    }

__________________

Last edited by SchlumPF*; 05-14-2009 at 22:11.
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-14-2009 , 22:10   Re: Reset buttons at round start
Reply With Quote #5

If the buttons are static, hook their spawn (in plugin_precache) and group them in a dynamic array.

Edit:

The code:
PHP Code:

new Array:Buttons
new ButtonsNumber

public plugin_precache()
{
    
Buttons ArrayCreate();
    
    
RegisterHam(Ham_Spawn,"func_button","buttonSpawn");
}

public 
buttonSpawn(id)
{
    
ArrayPushCell(Buttons,id);
    
ButtonsNumber++;
}

public 
eventHLTV( )
{
    for(new 
i=0;i<ButtonsNumber;i++)
        
dllfunc(DLLFunc_Think,ArrayGetCell(Buttons,i));
 

__________________

Last edited by joaquimandrade; 05-14-2009 at 22:14.
joaquimandrade is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-14-2009 , 22:14   Re: Reset buttons at round start
Reply With Quote #6

Quote:
Originally Posted by joaquimandrade View Post
If the buttons are static, hook their spawn (in plugin_precache) and group them in a dynamic array.
do you think such an neglible optimization is necessarry for such a small plugin? i mean roundstart is not called very often + searching by a native for ~50 func_buttons isnt taking that much performance either
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-14-2009 , 22:15   Re: Reset buttons at round start
Reply With Quote #7

Quote:
Originally Posted by SchlumPF* View Post
do you think such an neglible optimization is necesarry for such a small plugin? i mean roundstart is not called very often + searching by a native for ~50 func_buttons isnt taking that much performance either
Why would you search, everytime you need, for something that you can store? Anyway yours is better than the first.
__________________
joaquimandrade is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-14-2009 , 22:21   Re: Reset buttons at round start
Reply With Quote #8

i know taht mine is better, i also thought about caching but i dont think that its really necessarry although it is for sure an optimization.
since you already posted the code, xPaw should use it ^^
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-15-2009 , 01:07   Re: Reset buttons at round start
Reply With Quote #9

Quote:
Originally Posted by arkshine View Post
You could start at max_clients + 1.

Btw :
Doesn't the index passed "start after" mean that if you pass maxplayer, it will check at maxplayers + 1 ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-15-2009 , 05:07   Re: Reset buttons at round start
Reply With Quote #10

usually iButton holds the id of your latest func_button which got found == you are right. if you pass maxplayers maxplayers+1 will be the first id to be checked (even though im not sure whether the searching natives check ent by ent).
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
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 01:27.


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