AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_clcmd & read_arg help (https://forums.alliedmods.net/showthread.php?t=94845)

BeasT 06-16-2009 08:17

register_clcmd & read_arg help
 
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"))
        { 


Emilioneri 06-16-2009 15:24

Re: register_clcmd & read_arg help
 
Quote:

Originally Posted by BeasT (Post 850078)
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


:D

BeasT 06-16-2009 16:07

Re: register_clcmd & read_arg help
 
I doesn't work with 'buy'. I tested with 'radio2' and 'drop' and it worked just fine. Why's that?

tpt 06-16-2009 17:08

Re: register_clcmd & read_arg help
 
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" );         }


All times are GMT -4. The time now is 14:01.

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