Raised This Month: $ Target: $400
 0% 

How to detect argument empty?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 10-25-2005 , 13:20   How to detect argument empty?
Reply With Quote #1

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?
[ --<-@ ] Black Rose is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-25-2005 , 13:49  
Reply With Quote #2

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.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 10-25-2005 , 13:58  
Reply With Quote #3

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 is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 10-25-2005 , 14:53  
Reply With Quote #4

nvm i just changed
" " to "" and it worked
[ --<-@ ] Black Rose is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-25-2005 , 15:07  
Reply With Quote #5

argument_count is the only variable you actually have to change yourself, it doesn't actually magically know.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 10-25-2005 , 15:23  
Reply With Quote #6


"nvm" means "never mind" dude...
how would argument_count know how many args i want?
i've got 6 different things happening if there are 0-5 arguments...
[ --<-@ ] Black Rose is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-25-2005 , 15:55  
Reply With Quote #7

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.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-25-2005 , 16:29  
Reply With Quote #8

I think you can also do "if(!my_arg) return 0".
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 10-25-2005 , 17:35  
Reply With Quote #9

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 lol
i have 2-4 options... can some1 just help me with the easiest way to do it
[ --<-@ ] Black Rose is offline
WaZZeR++
Veteran Member
Join Date: Mar 2005
Location: Sweden
Old 10-26-2005 , 10:18  
Reply With Quote #10

maybe read_argc()
http://www.amxmodx.org/funcwiki.php?go=func&id=177
WaZZeR++ is offline
Send a message via MSN to WaZZeR++
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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