Raised This Month: $ Target: $400
 0% 

a minor question about read_argc()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
breaddawson
Senior Member
Join Date: Jul 2004
Location: Beijing,China
Old 10-03-2004 , 04:39   a minor question about read_argc()
Reply With Quote #1

yes, i read the sticky tutorial

Code:
if (read_argc() == 0) {     console_print(id,"[AMXX] You must specify a user")     return PLUGIN_HANDLED }

Quote:
read_argc() returns the number of arguments after the command. If there are no arguments, then it prints "[AMXX] You must specify a user", and we stop code execution.
i tried that before,but it didn't work then
it is to say that when u type a single command without any argument
amx x still won't tell u "u must specify a user"
i thought it might be a small error
so i didn't care about it

but just at yesterday i modified a place
it was

Code:
read_argc() == 0

i changed it to

Code:
read_argc() == 1

then it works well
when u typed a single command without any argument
amx x will remind u to add one

then i'm puzzled
why "0" doesn't work?
__________________
i'm bread dawson ,a chinese boy
wish u be happy~
breaddawson is offline
Send a message via ICQ to breaddawson Send a message via MSN to breaddawson
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 10-03-2004 , 05:58  
Reply With Quote #2

cause the wirst arg is the name of the cmd
e.g.

amx_help 14

there are 2 arguments
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
breaddawson
Senior Member
Join Date: Jul 2004
Location: Beijing,China
Old 10-03-2004 , 07:20  
Reply With Quote #3

thank u for ur reply
i know that now
so,as what u said,the script i copied from the tutorial is wrong
is it??

and the id of the first argument must be 0 ,is it?
i said this because i found another block in the tutorial

Code:
read_argv(1,user,32)

Quote:
With this command, we get the first argument of the command, and put it into the user variable. The maximum length of the argument that we would get is 32 characters.
and as what u said ,the "first" here should be "second"

am i right??

thank u again~~
__________________
i'm bread dawson ,a chinese boy
wish u be happy~
breaddawson is offline
Send a message via ICQ to breaddawson Send a message via MSN to breaddawson
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 10-03-2004 , 11:36  
Reply With Quote #4

0 represents the First argument,
1 represents the second argument,
2 represents the third argument,
etc etc...

Basically it is like the indexing of arrays...

amx_slap someone 100

Arg_0 = amx_slap
Arg_1 = someone
Arg_2 = 100

read_argc() = 3

I hope that helps!
xeroblood is offline
Send a message via MSN to xeroblood
breaddawson
Senior Member
Join Date: Jul 2004
Location: Beijing,China
Old 10-03-2004 , 11:49  
Reply With Quote #5

xeroblood,thank u very much

maybe devicenull should modify his sticky tutorial
__________________
i'm bread dawson ,a chinese boy
wish u be happy~
breaddawson is offline
Send a message via ICQ to breaddawson Send a message via MSN to breaddawson
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 00:29.


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