AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Button Spam (https://forums.alliedmods.net/showthread.php?t=140261)

Stylaa 10-10-2010 07:05

Button Spam
 
Im using this Code, and Players can Press "E" alltime an are totaly Flooding the Server whit messages.
How i can fix this?

PHP Code:


RegisterHam
(Ham_Use"func_button""fwdButton");

public 
fwdButton(entid)
{
    
//id = index of player who pressed the button
    //ent = entity index of the button
    
    
new PlayerName[33]
    
    
get_user_name(idPlayerName32)
    
    new 
mapname[33]
    
get_mapname(mapname32)
        
    if (
equali(mapname,"jb_mania_fixed"))
    {
        switch(
ent)
        {
            case 
329:
            {
                
ColorChat(0RED"%s %s starts a Cool Sound in the Disco",PREFIXPlayerName )
            }
        }
    }
    



wrecked_ 10-10-2010 10:47

Re: Button Spam
 
Though I'm assuming you use your switch statement for multiple things, if you aren't, you should just an if() statement to compare the ent id.

Use this:
Code:
#define DELAY   3.0 new Float:LastUse public plugin_init() {     RegisterHam(Ham_Use, "func_button", "fwdButton"); }     public fwdButton(ent, id) {     //id = index of player who pressed the button     //ent = entity index of the button         new PlayerName[33]         get_user_name(id, PlayerName, 32)         new mapname[33]     get_mapname(mapname, 32)             if (equali(mapname,"jb_mania_fixed"))     {         switch(ent)         {             case 329:             {                 if( get_gametime() >= LastUse + DELAY )                 {                     ColorChat(0, RED, "%s %s starts a Cool Sound in the Disco",PREFIX, PlayerName )                                         LastUse = get_gametime()                 }             }         }     }     }


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

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