AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with noob bug (https://forums.alliedmods.net/showthread.php?t=6924)

MC-Olivenoel 10-19-2004 10:44

help with noob bug
 
hi

simpel thing... but im noob :wink: and cant find the error

combiller say array out of bount

if i cange the array it says array mismasch .. *ARG*

Code:
    new varmenu0[2]     if (read_argc() == 0) {     //noargument ...     console_print(id,"- no argument")     varmenu0[2] = "00"     }else{     read_argv(1,varmenu0[0],2)     }     if (varmenu0[0] == '00'){     //blablabla


help please....

PM 10-19-2004 13:05

Please explain what you are trying to do :D

MC-Olivenoel 10-19-2004 13:14

ok

i make n command with argument ;)


so u can typ

amx_make
or
amx_make 00

and it will make the code behind 00

and if u say amx_make 11

then it will make the

code that stand under there in an secount if() with 11

and so on ;)

edit//
i want check if the arguments are true or not .... thats all

cucu

TotalNoobScripter 10-19-2004 19:42

yo this would officcally be the first person i helped so yay!

i think i see your problem. in
Code:
 new varmenu0[2]     if (read_argc() == 0) {     //noargument ...     console_print(id,"- no argument")     varmenu0[2] = "00"     }else{     read_argv(1,varmenu0[0],2)     }     if (varmenu0[0] == '00'){     //blablabla

where it says
Code:
varmenu0[2] = "00"
, you cant declare a array with [2] and expect it to have data for [2]. an array of [2] will have data for varmenu0[0] and varmenu0[1]. if u use the array with a array[2] when there is no vector there, its like an outa bound array, thus your error.

///EDIT i think i tealized somethign else but its probably nothin.
Code:
 read_argv(1,varmenu0[0],2)
what does the 2 mean in the last read_argv argument? if it means assign to varmenu[2] then theres a problem, as i stated above.

MC-Olivenoel 10-20-2004 01:42

hi

ok thx but i dont understand why to put n string "00" into n array :?:

:? ok im coding cb c c++ but this this this SMALL :twisted:

i want only do somthing like this

example but it dosent work ...

Code:
public func021(id,level,cid) { new var_menu0 // will be (00 - 99 and/or aa - zz) as STRING     if (read_argc() == 0) {     //noargument ...     console_print(id,"- no argument... set to 00")     var_menu0 = "00"     } else {     read_argv(1,var_menu0,2)     } if (var_menu0 == "00") { //make some nice things 1 return PLUGIN_HANDLED } if (var_menu0 == "01") { //make some nice things 2 return PLUGIN_HANDLED } if (var_menu0 == "03") { //make some nice things 3 return PLUGIN_HANDLED } //kill the PC LOL... user has wrong argument return PLUGIN_HANDLED }


:!: i dont understand this SMALL language *ARG*

if someone can make this work .... i can see how it works ... (dont understand .. shiting arrays with strings :roll: :?

cucu

MC-Olivenoel 10-20-2004 02:23

hi

ok i read the tutorial with array 1000000 times

Code:
public func021(id,level,cid) { new var_menu0[1] // will be (00 - 99 and aa - zz) as STRING     if (read_argc() == 0) {     //noargument ...     console_print(id,"- no argument... set to 00")     copy(var_menu0, 2, "00")     } else {     read_argv(1,var_menu0,2)    //is this right ???     } if ((var_menu0[0] == "0") && (var_menu0[1] == "0")) { //make some nice things 1 return PLUGIN_HANDLED } if ((var_menu0[0] == "0") && (var_menu0[1] == "1")) { //make some nice things 2 return PLUGIN_HANDLED } if ((var_menu0[0] == "0") && (var_menu0[1] == "2")) { //make some nice things 3 return PLUGIN_HANDLED } //kill the PC LOL... user has wrong argument return PLUGIN_HANDLED }

whats wrong ??? *AGR* i copy and copy arrays like in tut but then .. its n other error LOL

Code:


(32): warning 217: loose indentation
(40): warning 217: loose indentation
(40): error 033: array must be indexed (variable "-unknown-")
(45): error 033: array must be indexed (variable "-unknown-")
(50): error 033: array must be indexed (variable "-unknown-")

whats this ***********ing 'loose indentation' line 32 ???

line 32
Code:

    if (read_argc() == 0) {
whats wrong :cry:
and line 40 45 50 why :evil: i say "var_menu0[1]" ists n array for string with 2 space in it ... :?


all time it works and now :?:

HELP PLEASE

twistedeuphoria 10-20-2004 11:13

No, new var_menu0[1] creates an array with one variable: var_menu0[0] you need to declare var_menu0[2].

PM 10-20-2004 12:00

Try using '(value)' instead of "(value)".

Da Bishop 10-20-2004 14:56

Quote:

whats this ***********ing 'loose indentation' line 32 ???

line 32
Code:

if (read_argc() == 0) {


whats wrong Crying or Very sad
loose indentations are nothing to worry about, pretty useless warning actually. To make them go away add this to the code

Code:
#pragma tabsize 0

PM 10-20-2004 15:54

Quote:

Originally Posted by Da Bishop
loose indentations are nothing to worry about, pretty useless warning actually.

I would make them errors actually! Just like tag mismatch! Ha! :D


All times are GMT -4. The time now is 17:27.

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