View Single Post
farawayf
Senior Member
Join Date: Jan 2019
Old 07-09-2019 , 13:46   Re: how can you scan a variable and then apply it?
Reply With Quote #4

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

Last edited by farawayf; 07-09-2019 at 13:51.
farawayf is offline