Raised This Month: $ Target: $400
 0% 

register_clcmd & read_arg help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeasT
Senior Member
Join Date: Apr 2007
Location: Lithuania
Old 06-16-2009 , 08:17   register_clcmd & read_arg help
Reply With Quote #1

I want plugin 'to do something' when admin with specific flag press "buy" button. I was trying to do it in several ways, but I don't understand the read_arg part correctly, so it didn't work. All I was able to do is to copy the read_arg part from another plugin and register a new command. This way it worked.

PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("amx_setgrav""cmdGravset"ADMIN_BAN)
}

public 
cmdGravset(id,level,cid)
{
    if ( !
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
if (read_argc() == 2) {
        new 
argument[10]
        
read_argv(1,argument,9)
        if (
equal(argument"on"))
        { 
BeasT is offline
Send a message via Skype™ to BeasT
Emilioneri
Senior Member
Join Date: Feb 2009
Location: Georgia, Tbilisi
Old 06-16-2009 , 15:24   Re: register_clcmd & read_arg help
Reply With Quote #2

Quote:
Originally Posted by BeasT View Post
I want plugin 'to do something' when admin with specific flag press "buy" button.
PHP Code:
/* Plugin generated by Emilioneri */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Something"
#define VERSION "1.0"
#define AUTHOR "Emilioneri"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
register_clcmd("buy""cmd_buy"ADMIN_BAN"Something")
}

public 
cmd_buy(id)
{
    if (!
access(idADMIN_BAN))
       return 
PLUGIN_HANDLED
       
    
// do something

__________________
Emilioneri is offline
Send a message via Skype™ to Emilioneri
BeasT
Senior Member
Join Date: Apr 2007
Location: Lithuania
Old 06-16-2009 , 16:07   Re: register_clcmd & read_arg help
Reply With Quote #3

I doesn't work with 'buy'. I tested with 'radio2' and 'drop' and it worked just fine. Why's that?
BeasT is offline
Send a message via Skype™ to BeasT
tpt
Member
Join Date: Jun 2009
Location: Scripting help section
Old 06-16-2009 , 17:08   Re: register_clcmd & read_arg help
Reply With Quote #4

Code:
public client_command(id) {     new arg[13];     read_argv( 0, arg , 12 );         if ( equal( "buy", arg ) || equal( "autobuy", arg ) )         client_print( id, print_chat, "I used buy command" );         }
tpt is offline
Reply


Thread Tools
Display Modes

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 14:01.


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