View Single Post
Author Message
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 09-09-2019 , 10:54   [HELP] Get All Cmd Args
Reply With Quote #1

Hello everyone.

I tried to get all the cmd args that the client will use, has that is unknown the ammount he is going to use I tried this one.

PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "SpirT"
#define PLUGIN_VERSION "1.0"

char file[512];

#include <sourcemod>
#include <sdktools>

#pragma newdecls required

public Plugin myinfo 
{
    
name "[SpirT] Phrase Setter",
    
author PLUGIN_AUTHOR,
    
description "Sets a player's phrase with a command",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_phrase"Command_Phrase);
    
    
BuildPath(Path_SMfilesizeof(file), "configs/SpirT/phrase.cfg");
    
char dir[512] = "addons/sourcemod/configs/SpirT";
    if(!
DirExists(dir))
    {
        
CreateDirectory(dir511);
    }
}

public 
void OnClientPutInServer(int client)
{
    
KeyValues kv = new KeyValues("SpirTPhrase");
    
kv.ImportFromFile(file);
    
    
char sID[32];
    
GetClientAuthId(clientAuthId_Steam2sIDsizeof(sID));
    
    if(!
KvJumpToKey(kvsIDfalse))
    {
        
PrintToServer("[SpirT - Phrase Set] Player %N don't has his / her phrase set yet!"client);
    }
    
    
char phrase[64];
    
KvGetString(kv"phrase"phrasesizeof(phrase));
    
    
PrintToChatAll("%N Connected: %s"clientphrase);
}

public 
Action Command_Phrase(int clientint args)
{
    if(
args 1)
    {
        
char phrase[128];
        
int phrase_args GetCmdArgs();
        
GetCmdArg(phrase_argsphrasesizeof(phrase));
        
        
KeyValues kvm = new KeyValues("SpirTPhrase");
        
kvm.ImportFromFile(file);
        
        
char steamID[32];
        
GetClientAuthId(clientAuthId_Steam2steamIDsizeof(steamID));
        
        if(
KvJumpToKey(kvmsteamIDtrue))
        {
            
char check[64];
            
KvGetString(kvm"phrase"checksizeof(check), "");
        
            if(!
StrEqual(checkphrase))
            {
                
KvSetString(kvm"phrase"phrase);
            }
            
PrintToChat(client"[SpirT - Phrase Set] Your actual phrase is the same that you're trying to set. Please try another one.");
        }
    }
    
    return 
Plugin_Handled;

And when he connects instead of saying all the phrase, just prints the start!

Let's supose that phrase is "The pro is Me"
It Just's print to chat:
Code:
SpirT Connected: The
So it's just prints the first argument of the cmd. How can I get all and make in only one string to store the value?

Best Regards,

SpirT.
__________________

Last edited by SpirT; 09-09-2019 at 10:54.
SpirT is offline