AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can not understand how to fix error 033: array must be indexed (https://forums.alliedmods.net/showthread.php?t=220039)

Mofforg 07-06-2013 05:05

Can not understand how to fix error 033: array must be indexed
 
Here's a part of code on say hook, i've just checked current variable of setinfo 'translit' and then if it's 0 i set to 1, if it's 1 i set to 0.

PHP Code:

    else if(containi(say_args"/lang") != -)
    {
        
get_user_info(id,"translit",lang,2)
        if(
lang == 0
            
set_user_info(id,"translit","1");
        else if(
lang == 1
            
set_user_info(id,"translit","0");
        return 
PLUGIN_HANDLED
    


But it returns an error:
PHP Code:

error 033: array must be indexed (variable "lang"

Please help me - how to fix? What's wrong there?

Arkshine 07-06-2013 05:16

Re: Can not understand how to fix error 033: array must be indexed
 
lang variable must be a string.

Mofforg 07-06-2013 05:19

Re: Can not understand how to fix error 033: array must be indexed
 
Quote:

Originally Posted by Arkshine (Post 1984421)
lang variable must be a string.

How to do that?

I have this
PHP Code:

static lang[2


Arkshine 07-06-2013 05:31

Re: Can not understand how to fix error 033: array must be indexed
 
Misread. You have to convert "lang" to an integer, like str_to_num( lang ), or if contain only 0 or 1, you could also checking like "lang[0] == '1'" ;

Mofforg 07-06-2013 05:44

Re: Can not understand how to fix error 033: array must be indexed
 
Quote:

Originally Posted by Arkshine (Post 1984430)
Misread. You have to convert "lang" to an integer, like str_to_num( lang ), or if contain only 0 or 1, you could also checking like "lang[0] == '1'" ;

thx. lang[0] looks easier =)

fysiks 07-06-2013 14:51

Re: Can not understand how to fix error 033: array must be indexed
 
Quote:

Originally Posted by Mofforg (Post 1984440)
thx. lang[0] looks easier =)

But realize that this only works when it is a single digit.


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

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