View Single Post
sdz
Senior Member
Join Date: Feb 2012
Old 12-28-2018 , 15:08   Re: Execute command from a menu
Reply With Quote #2

first things first i can't recommend mixing the two syntaxes, it looks bad and inconsistent as well as people on this forum will cry for weeks on end
continuing on - the blow example is wrong, followed by the correct method: %s is used for strings and/or char arrays, you'll want %i or %d for integers, or alternatively %N for the client's name (only if passing a client index, this is sourcemod specific), however none of these are recommended at all

PHP Code:
//bad 
public Action Cmd_vipHeal(int clientint args
{
    
PrintToChat(client"Fullt HP");

    
ServerCommand("sm_hp %s 100"client);
        
    return 
Plugin_Handled;
}

//"good"
public Action Cmd_vipHeal(int clientint args
{
    
PrintToChat(client"Fullt HP");
    
/* If we really wanted to do it this way, this is how: 
    ServerCommand("sm_hp %i 100", GetClientUserId(client));
    Better than calling and passing a client index through a servercommand, https://sm.alliedmods.net/new-api/entity_prop_stocks/SetEntityHealth
    */
    
SetEntityHealth(client100);
    return 
Plugin_Handled;

and I think you'll just need to use SetEntityHealth in your menu handler
just to clarify, clients are edicts, which are entities

Last edited by sdz; 12-28-2018 at 15:12.
sdz is offline