AlliedModders

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

anon12 07-25-2014 19:14

command contain
 
is it possible to check if the command contains something?

Example:
1. If command contains "amx_" then show all the commands in the amx_help.
2. If command contains "heal" then restore user health back to normal.

Eagle07 07-25-2014 22:59

1. this ?
PHP Code:

public client_command(id

    new 
arg[32]; 
    
read_argv(0arg31); 
    if (
equali(arg"amx_")) 
    { 
        
client_cmd(id"amx_help")
    } 


or
PHP Code:

new const Commands[ ][ ] ={
    
"amx_"
}
public 
client_command(id)
{
    new 
Command[32];
    
read_argv(0Commandcharsmax(Command));
    
    for( new 
0sizeofCommands ); ++)
    {
        if( 
containiCommand Commands] ) != -)
        {
            
client_cmd(id,"amx_help")
        }
    }


and this for health
PHP Code:

new const Commands[ ][ ] ={
    
"heal"
}
public 
client_command(id)
{
    new 
Command[32];
    
read_argv(0Commandcharsmax(Command));
    
    for( new 
0sizeofCommands ); ++)
    {
        if( 
containiCommand Commands] ) != -)
        {
            
set_user_health(id,100)
        }
    }


P.S : cmd amx_ & heal write in consol !!!
(if you want to add this cmd in say ex when client say heal give him health .. just change "heal" =to> "say heal" -- or for amx_ just change "amx_" =to> "say amx_" :P )


All times are GMT -4. The time now is 13:15.

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