AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Array must be indexed O_O (https://forums.alliedmods.net/showthread.php?t=223336)

Podarok 08-12-2013 10:41

Array must be indexed O_O
 
i got this :

Code:
    static const g_Cost[][] = {     { "10000" },     { "13000" },     { "16000" },     { "5000" },     { "16000" },     { "12000" },     { "16000" },     { "15000" },     { "16000" } }

Code:
    cs_set_user_money(id, money-g_Cost[item])

Compiler says that array must be indexed ... It is already indexed, what the heck ?

YamiKaitou 08-12-2013 10:54

Re: Array must be indexed O_O
 
A String is not the same as an Integer. Either convert the array to a 1D Integer array or convert the value from a String to an Integer

Arkshine 08-12-2013 10:55

Re: Array must be indexed O_O
 
It's an array of string and the native needs an integer value. For sure it's not going to work.

Podarok 08-12-2013 11:04

Re: Array must be indexed O_O
 
Quote:

Originally Posted by YamiKaitou (Post 2011518)
A String is not the same as an Integer. Either convert the array to a 1D Integer array or convert the value from a String to an Integer

Using str_to_num ?

YamiKaitou 08-12-2013 11:06

Re: Array must be indexed O_O
 
Quote:

Originally Posted by Podarok (Post 2011526)
Using str_to_num ?

If it must be an array of strings, then yes. Seeing as they are all numbers, why can't you switch it to a 1D array?

Podarok 08-13-2013 04:11

Re: Array must be indexed O_O
 
Quote:

Originally Posted by YamiKaitou (Post 2011527)
If it must be an array of strings, then yes. Seeing as they are all numbers, why can't you switch it to a 1D array?

I had a long brake in scripting. Could u tell me how would that look like in code?

YamiKaitou 08-13-2013 07:06

Re: Array must be indexed O_O
 
Quote:

Originally Posted by Podarok (Post 2011971)
I had a long brake in scripting. Could u tell me how would that look like in code?

Code:

    static const g_Cost[] = {
    10000,
    13000,
    16000,
    5000,
    16000,
    12000,
    16000,
    15000,
    16000
}


Black Rose 08-13-2013 07:21

Re: Array must be indexed O_O
 
The curly brackets are not necessary.

YamiKaitou 08-13-2013 07:47

Re: Array must be indexed O_O
 
Quote:

Originally Posted by Black Rose (Post 2012082)
The curly brackets are not necessary.

Forgot, updated


All times are GMT -4. The time now is 15:58.

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