AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Reset buttons at round start (https://forums.alliedmods.net/showthread.php?t=92372)

xPaw 05-14-2009 11:57

Reset buttons at round start
 
4 Attachment(s)
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.

Arkshine 05-14-2009 12:09

Re: Reset buttons at round start
 
You could start at max_clients + 1.

Btw :
Quote:

Originally Posted by xPaw (Post 827368)
By the way, this plugin is gay :mrgreen:

:twisted:

kabul 05-14-2009 21:33

Re: Reset buttons at round start
 
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.

SchlumPF* 05-14-2009 22:05

Re: Reset buttons at round start
 
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 );
    }



joaquimandrade 05-14-2009 22:10

Re: Reset buttons at round start
 
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));
 



SchlumPF* 05-14-2009 22:14

Re: Reset buttons at round start
 
Quote:

Originally Posted by joaquimandrade (Post 827654)
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

joaquimandrade 05-14-2009 22:15

Re: Reset buttons at round start
 
Quote:

Originally Posted by SchlumPF* (Post 827656)
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.

SchlumPF* 05-14-2009 22:21

Re: Reset buttons at round start
 
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 ^^

ConnorMcLeod 05-15-2009 01:07

Re: Reset buttons at round start
 
Quote:

Originally Posted by arkshine (Post 827376)
You could start at max_clients + 1.

Btw :
:twisted:

Doesn't the index passed "start after" mean that if you pass maxplayer, it will check at maxplayers + 1 ?

SchlumPF* 05-15-2009 05:07

Re: Reset buttons at round start
 
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).


All times are GMT -4. The time now is 21:48.

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