Raised This Month: $51 Target: $400
 12% 

Combining Args


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 05-08-2015 , 12:32   Combining Args
Reply With Quote #1

Is there a better way to display the "giveaway item" as one arg in chat than this?:

PHP Code:
    GetCmdArg(1Arg1sizeof(Arg1)) 
    
GetCmdArg(2Arg2sizeof(Arg2)) 
    
GetCmdArg(3Arg3sizeof(Arg3)) 
    
GetCmdArg(4Arg4sizeof(Arg4)) 
     
    
Format(Arg1sizeof(Arg1), "%s %s"Arg1Arg2); 
    
Format(Arg1sizeof(Arg1), "%s %s"Arg1Arg3); 
    
Format(Arg1sizeof(Arg1), "%s %s"Arg1Arg4); 

    
PrintToChatAll("[\x04Giveaway\x01] Giveaway item: \x02%s"Arg1

Full Code:
PHP Code:
#include <sourcemod> 
#define PLUGIN_VERSION "1.4" 

new Handle:c_clutter;

public 
Plugin:myinfo = { 
    
name "Giveaway"
    
author "Addicted"
    
description "Picks a random client and displays a message."
    
version PLUGIN_VERSION
    
url "" 


public 
OnPluginStart() 

    
RegAdminCmd("sm_giveaway"Giveaway ADMFLAG_ROOT
    
c_clutter CreateConVar("sm_ga_tidychat""0""Remove excess chat messages."FCVAR_PLUGIN true0.0true1.0);
    
AutoExecConfig(true"giveaway")




public 
Action:Giveaway(clientargs){ 
        
    new 
winner GetRandomPlayer(3); 
    new 
String:Arg1[32], String:Arg2[32], String:Arg3[32], String:Arg4[32]
    new 
clutter GetConVarInt(c_clutter);
    
    if(
args <1)
    {
        
PrintToChat(client"[\x04Giveaway\x01] Usage: !giveaway <giveaway item>")
        return 
Plugin_Handled;
    }
    
    
GetCmdArg(1Arg1sizeof(Arg1))
    
GetCmdArg(2Arg2sizeof(Arg2))
    
GetCmdArg(3Arg3sizeof(Arg3))
    
GetCmdArg(4Arg4sizeof(Arg4))
    
    
Format(Arg1sizeof(Arg1), "%s %s"Arg1Arg2);
    
Format(Arg1sizeof(Arg1), "%s %s"Arg1Arg3);
    
Format(Arg1sizeof(Arg1), "%s %s"Arg1Arg4);

    
PrintToChatAll("[\x04Giveaway\x01] Giveaway item: \x02%s"Arg1
    
    if(
clutter == 0)
    {
    
PrintToChatAll("--"
    
PrintToChatAll("--"
    
PrintToChatAll("--"
    
PrintToChatAll("--"
    
PrintToChatAll("[\x04Giveaway\x01] \x06Picking random client...\x01"
    
PrintToChatAll("[\x04Giveaway\x01] \x06Found random client...\x01")
    }
    
PrintToChatAll("[\x04Giveaway\x01] \x06Winner\x01 is \x02%N\x01!"winner

    return 
Plugin_Continue
}    

stock GetRandomPlayer(team) { 

    new 
clients[MaxClients+1], clientCount
    for (new 
1<= MaxClientsi++) 
        if (
IsClientInGame(i) && (GetClientTeam(i) == team)) 
            
clients[clientCount++] = i
    return (
clientCount == 0) ? -clients[GetRandomInt(0clientCount-1)]; 


Last edited by Addicted.; 05-08-2015 at 12:35.
Addicted. is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-08-2015 , 12:40   Re: Combining Args
Reply With Quote #2

have the user use quotes...
sm_giveaway "The item here"
or just get the entire arg string
GetCmdArgString(String:buffer[], maxlength);
Mitchell is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode