AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   concmd arguments question (https://forums.alliedmods.net/showthread.php?t=92123)

ehha 05-10-2009 12:51

concmd arguments question
 
How can I tell the difference between the values of the 2nd argument, for example:
-amx_slap ehha 0
-amx_slap ehha

I want to make a concmd that does:
-something1 if 2nd arg is 0
-something2 if 2nd arg is not present
-something3 if 2nd arg is > 0
-nothing if 2nd arg is < 0

So how can I tell if the 2nd is 0 or nothing?

Thank you in advance.

Arkshine 05-10-2009 12:59

Re: concmd arguments question
 
read_argc()

Bugsy 05-10-2009 13:22

Re: concmd arguments question
 
Quote:

Originally Posted by ehha (Post 824979)
How can I tell the difference between the values of the 2nd argument, for example:
-amx_slap ehha 0
-amx_slap ehha

I want to make a concmd that does:
-something1 if 2nd arg is 0
-something2 if 2nd arg is not present
-something3 if 2nd arg is > 0
-nothing if 2nd arg is < 0

So how can I tell if the 2nd is 0 or nothing?

Thank you in advance.

read_argc returns the number of arguments that were passed. You then use read_argv to get the value.

http://www.amxmodx.org/funcwiki.php?go=func&id=175

PHP Code:

//command passed with no arguments
switch ( read_argc() )
{
    case 
1//command passed with no arguments
    
case 2//command passsed with 1 argument
    
case 3//etc
}

read_argv arg# , output_string[], len ) 


ehha 05-10-2009 15:44

Re: concmd arguments question
 
Cool! Thank you both.
I spend a hour or so trying with some (stupid) methods to get the to this only with read_argv :D Thanks again.


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

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