View Single Post
Doggg
Member
Join Date: Jun 2018
Old 07-09-2019 , 13:24   Re: how can you scan a variable and then apply it?
Reply With Quote #3

Quote:
Originally Posted by farawayf View Post
upd include
PHP Code:
#include <sourcemod>

#pragma newdecls required

public void OnPluginStart() {
    
RegAdminCmd("sm_cheats"cheatsADMFLAG_CONVARS);
}

public 
Action cheats(int clientint args) {    
    if(
args 1) {
        
ReplyToCommand(client"[SM] Usage: sm_cheats <value>");
        return 
Plugin_Handled;
    }    
    
    
char arg[4];
    
    
GetCmdArg(1argsizeof(arg));
    
    if(
StrEqual(arg"1")) {
        
ServerCommand("sv_cheats 1");
        
PrintToChat(client"\x04svcheats is *on*");
    }
    else if(
StrEqual(arg"0")) {
        
ServerCommand("sv_cheats 0");
        
PrintToChat(client"\x03svcheats is *off*");
    }        
    return 
Plugin_Handled;

thanks for the code, But i am trying to understand the logic for improve.
a few questions,
is this the actual scan commnad? GetCmdArg(1, arg, sizeof(arg));?
if so, what does the one means? i understood that args is a char array, and the sizeof(args) means the bytes (am i even right?), but what does the one means?
when will args will be lower then one? when there is none? like cheats <nothing>?
thanks!
Doggg is offline