AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to detect argument empty? (https://forums.alliedmods.net/showthread.php?t=19786)

[ --<-@ ] Black Rose 10-25-2005 13:20

How to detect argument empty?
 
if i type like amx_some_cmd argument1
i wanna know how it can be detected if argument1 is empty or not ( im not using numbers )

i tryed
Code:
if (equali(arg1, " ") )
that worked with my invis script but not with my vote...

help? :roll:

XxAvalanchexX 10-25-2005 13:49

Code:
#include <amxmisc> public command(id,level,cid) {    if(!cmd_access(id,level,cid,argument_count))       return PLUGIN_HANDLED; }

argument_count should be the number of arguments plus one, so if your command was amx_command <player> <action> then the number would be 3. This automatically checks admin flags and argument count and outputs text to the console.

[ --<-@ ] Black Rose 10-25-2005 13:58

okey... :? how does it know its 3? :? that only says argument_count...
so where do i pu the "3"?

it looks like this now
Code:
if (equali(arg1, "")) {         client_print(id, print_console, "You need a question to start a vote")         return PLUGIN_HANDLED     }     if (equali(arg2, "")) {         client_print(id, print_console, "You need at least Two answers (You typed in 0)")         return PLUGIN_HANDLED     }     if (equali(arg3, "")) {         client_print(id, print_console, "You need at least Two answers (You typed in 1)")         return PLUGIN_HANDLED     }     else {         new menubody[128], keys         if (equali(arg4, " ")) {             format(menubody, 127, "%s^n^n1. %s^n2. %s", arg1, arg2, arg3)             keys = MENU_KEY_1|MENU_KEY_2         }         if (equali(arg5, " ")) {             format(menubody, 127, "%s^n^n1. %s^n2. %s^n3. %s", arg1, arg2, arg3, arg4)             keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3         }         else {             format(menubody, 127, "%s^n^n1. %s^n2. %s^n3. %s^n4. %s", arg1, arg2, arg3, arg4, arg5)             keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4         }         for(new i = 0; i <= get_playersnum(); i++)             show_menu(i,keys,menubody,6,"voting")
how would i change that?

[ --<-@ ] Black Rose 10-25-2005 14:53

nvm :P i just changed
" " to "" and it worked :P

XxAvalanchexX 10-25-2005 15:07

argument_count is the only variable you actually have to change yourself, it doesn't actually magically know.

[ --<-@ ] Black Rose 10-25-2005 15:23

:?:
"nvm" means "never mind" dude...:idea:
how would argument_count know how many args i want?
i've got 6 different things happening if there are 0-5 arguments...

XxAvalanchexX 10-25-2005 15:55

argument_count doesn't know anything, you tell it what it is supposed to do, that's it. For example, cmd_access(id,level,cid,3), argument_count is not a predefined variable like the other three.

Hawk552 10-25-2005 16:29

I think you can also do "if(!my_arg) return 0".

[ --<-@ ] Black Rose 10-25-2005 17:35

Quote:

Originally Posted by XxAvalanchexX
argument_count doesn't know anything, you tell it what it is supposed to do, that's it. For example, cmd_access(id,level,cid,3), argument_count is not a predefined variable like the other three.

so that means if argument 3 is empty nothing happends?

but i wanna do if argument 5 is empty it goes to next thing... the thing with 4 arguments. and if argument 4 isn't found it will use next, the one with 3 arguments...
cani do it like this?:
(!0,0,0,5) {
lalala
}
(!0,0,0,4) {
something else
}
:?:
btw... wtf is level and cid?

and it still works... so it doesn't matters

BUT if i wanna show the result that got most votes in my votings, how do i do. i checked the adminvote but i got really confused :P lol
i have 2-4 options... can some1 just help me with the easiest way to do it :P

WaZZeR++ 10-26-2005 10:18

maybe read_argc()
http://www.amxmodx.org/funcwiki.php?go=func&id=177


All times are GMT -4. The time now is 23:38.

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