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

Quote:
Originally Posted by farawayf View Post
PHP Code:

public Action cheats(int clientint args) {    
    
/* if arguments less than 1, then print to client and return. This will be called if player types the command without 
        arguments. Like "!cheats"
    */ 
     
if(args 1) {
        
ReplyToCommand(client"[SM] Usage: sm_cheats <value>");
        return 
Plugin_Handled;
    }   
    
    
char arg[4]; //creating char with any name, "arg" for example.
    
    
GetCmdArg(1argsizeof(arg)); //get the first argument of command and store it in char with full size of argument
    
   //then check equal and do stuff
    
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;

GetCmdArg: https://sm.alliedmods.net/new-api/console/GetCmdArg
Thanks!
one last question, can you go a bit deeper about the first thing you need to input?
GetCmdArg(1, arg, sizeof(arg)); this 1 means you can input only 0 and 1? or what? i am not fully get what this 1 stands for (as you may see its new for me).
Doggg is offline