View Single Post
farawayf
Senior Member
Join Date: Jan 2019
Old 01-19-2019 , 13:03   Re: How to activate func_button
Reply With Quote #5

Quote:
Originally Posted by Ilusion9 View Post
You haven't used my code because it doesn't even compile.
It's easy to talk that your server crashes because you are still using your code.

Use this:

PHP Code:

#pragma semicolon 1 

#include <sourcemod> 
#include <sdktools> 

public void OnPluginStart() 

    
RegAdminCmd("sm_activatebutton"Command_ActivateButtonADMFLAG_ROOT"sm_activatebutton <name>"); 


public 
Action Command_ActivateButton(int clientint args
{
    if (
args 1)
    {
        
ReplyToCommand(client"[SM] Usage: sm_activatebutton <name>");
        return 
Plugin_Handled
    }
    
    
char arg[65]; 
    
GetCmdArg(1argsizeof(arg)); 

    
int entity = -1
    while ((
entity FindEntityByClassname(entity"func_button")) != -1)
    {
        
char name[65]; 
        
GetEntPropString(entityProp_Data"m_iName"namesizeof(name)); 
        
        if (
StrEqual(argname))
        { 
            
AcceptEntityInput(entity"Press"); 
            return 
Plugin_Handled
        } 
    } 

    return 
Plugin_Handled

Thanks you. Everything works fine.

Sorry to appeal to you again, but it’s not working the way I would like. I would like to do this: the administrator writes the command “sm_activatebutton 1 (or 2, 3, etc.)” And, for example, 1 - button_open, 2 - button_close, 3 - button_slay etc.
Not to write every time the name of the buttons like "sm_activatebutton button_open"

Last edited by farawayf; 01-19-2019 at 13:07.
farawayf is offline