AlliedModders

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

maoxianxie 10-01-2011 00:07

read_arg ?
 
new arg[13];
read_argv( 0, arg , 12 );


I m not clear about the read_argv or read_argc , what do they mean and how to use them ? They seem very useful .

fysiks 10-01-2011 00:13

Re: read_arg ?
 
http://www.amxmodx.org/funcwiki.php

maoxianxie 10-01-2011 00:55

Re: read_arg ?
 
Could you explain it more to me ? Thanks for your patience.

fysiks 10-01-2011 01:49

Re: read_arg ?
 
Quote:

Originally Posted by maoxianxie (Post 1566253)
Could you explain it more to me ?

It's not really possible to explain more about those functions than is already listed on the func wiki unless you have a specific question as to whether it will work for a situation or not.

If you are trying to use those functions then you should tell us exactly what you are trying to do. Also, read_argv() is probably in 90% of plugins on this forum so you can see how they are used.

maoxianxie 10-01-2011 02:23

Re: read_arg ?
 
I m sorry , I dont have urgent needs ,but just simply ask about it

plowed 10-01-2011 05:10

Re: read_arg ?
 
PHP Code:

#include <amxmodx>

public plugin_init() {
    
register_clcmd("say""commandcmd")
}

public 
commandcmd(id) {
    new 
arg[15]
    
read_argv(idargcharsmax(arg))
    if(
arg[0] == '/')
        
//First letter of a client message is a slash
        
client_print(idprint_chat," The first letter you wrote is a '/'...")
        
    return 
PLUGIN_CONTINUE


Here is a weapon giver example from ConnorMcLeod

PHP Code:

/*    Copyright © 2009, ConnorMcLeod

    Give Weapon is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Give Weapon; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fun>

new const VERSION[] = "0.1.0"

public plugin_init()

    
register_plugin("Give Weapons"VERSION"ConnorMcLeod")

    
register_clcmd("say""ClientCommand_GiveWeapon")
    
register_clcmd("say_team""ClientCommand_GiveWeapon")

    
register_clcmd("say /weapons""ClientCommand_Weapons")
    
register_clcmd("say_team /weapons""ClientCommand_Weapons")
}

public 
ClientCommand_GiveWeapon(id)
{
    new 
szArg1[15]
    if( 
is_user_alive(id) && read_argv(1szArg1charsmax(szArg1)) < 14 && szArg1[0] == '/' )
    {
        new 
szWeaponName[20] = "weapon_"
        
add(szWeaponNamecharsmax(szWeaponName), szArg1[1])
        if( 
get_weaponid(szWeaponName) )
        {
            
give_item(idszWeaponName)
            return 
PLUGIN_HANDLED_MAIN
        
}
    }
    return 
PLUGIN_CONTINUE
}

public 
ClientCommand_Weaponsid )
{
    if( 
is_user_alive(id) )
    {
        new 
szWeaponName[20]
        for(new 
iCswId=CSW_P228iCswId<=CSW_P90iCswId++)
        {
            if( !
user_has_weapon(idiCswId) && get_weaponname(iCswIdszWeaponNamecharsmax(szWeaponName)) )
            {
                
give_item(idszWeaponName)
            }
        }
    }
    return 
PLUGIN_HANDLED_MAIN




All times are GMT -4. The time now is 19:30.

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