Raised This Month: $32 Target: $400
 8% 

Say commands with names aside


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
aSior
Member
Join Date: Jan 2016
Old 12-20-2017 , 09:14   Say commands with names aside
Reply With Quote #1

Hi, im curious how to make a command with name aside, so the name works as an argument, for example !revive NAME. A check if there's a value too, would be nice (ex. !money NAME 10).
aSior is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 12-20-2017 , 10:19   Re: Say commands with names aside
Reply With Quote #2

Are you talking about this?
Code:
register_clcmd("!money", "clcmd_money") public clcmd_money(id){     new szTarget[32], pid // argument 1 storage     read_argv(1, szTarget, charsmax(szTarget)) // retrieving argument 1     pid = cmd_target(id, szTarget, 2) // searching for user containing argument 1 text     if (!pid) return 1; // no search result, cancel     new szAmount[6], amount // argument 2 storage     read_argv(2, szAmount, charsmax(szAmount)) // retrieving argument 2          if (!szAmount[0]) return 1; // no money argument, cancel     amount = str_to_num(szAmount) // converting the 2nd argument to a integer     new szName[32] // targeteds' user storage     get_user_name(pid, szName, charsmax(szName)) // retrieving user name     if (amount < 1) return 1; // money amount is lower than 1, cancel     cs_set_user_money(pid, cs_get_user_money(pid) + amount) // setting user money     if (cs_get_user_money(pid) < 0) cs_set_user_money(pid, 0) // user money is lower than 0, setting it to 0 }
__________________

Last edited by Relaxing; 12-20-2017 at 10:19. Reason: Unclosed bracket. Cloinc
Relaxing is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-20-2017 , 13:15   Re: Say commands with names aside
Reply With Quote #3

PHP Code:
public plugin_init()
{
    
register_clcmd("say""OnSay")
    
register_clcmd("say_team""OnSay")
}

public 
OnSay(id)
{
    new 
szArg[64], szCommand[32], szPlayer[32]
    
read_argv(1szArgcharsmax(szArg))
    
parse(szArgszCommandcharsmax(szCommand), szPlayercharsmax(szPlayer))
    
    if(
equal(szCommand"!revive"))
    {
        new 
iPlayer cmd_target(idszPlayerCMDTARGET_ALLOW_SELF)
        
        if(!
iPlayer)
            return 
PLUGIN_HANDLED
    
        ExecuteHamB
(Ham_CS_RoundRespawniPlayer)
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_CONTINUE

__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 06:45.


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