SA-MP Forums Archive
This error - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: This error (/showthread.php?tid=611019)



This error - Alpay0098 - 01.07.2016

PHP Code:
            if(listitem == 0)
            {
                new 
stringad[100];
                foreach(
Playeri)
                {
                    if(
PlayerInfo[pAdvert] != "None"// Error line
                    
{
                        
format(stringadsizeof(string), "%s | Contact: %i\n",PlayerInfo[pAdvert], PlayerInfo[pPnumber]);
                    }
                    else
                    {
                        
format(stringadsizeof(string), "No Advertisement Yet");
                    }
                }
                
ShowPlayerDialog(playeridDIALOG_ADLISTDIALOG_STYLE_LIST"Advertisement List"stringad"Select""Cancel");
            } 
The error:
PHP Code:
error 033: array must be indexed (variable "-unknown-"



Re: This error - DTV - 01.07.2016

sizeof(string) should be sizeof(stringad), but can you show where you declare PlayerInfo?


Re: This error - Alpay0098 - 01.07.2016

Quote:
Originally Posted by DTV
View Post
sizeof(string) should be sizeof(stringad), but can you show where you declare PlayerInfo?
I already did that - It's just a simple enum that PlayerInfo[playerid][pAdvert] is defined like below:
PHP Code:
pAdvert[128



Re: This error - DTV - 01.07.2016

Then write it as PlayerInfo[i][pAdvert] since you're looping through all the players, same with pNumber.


Re: This error - Alpay0098 - 02.07.2016

Dude I already did that but still gives the error
PHP Code:
if(PlayerInfo[i][pAdvert] != "None"
Is there anything wrong with this


Re: This error - SyS - 02.07.2016

Quote:
Originally Posted by Alpay0098
View Post
Dude I already did that but still gives the error
PHP Code:
if(PlayerInfo[i][pAdvert] != "None"
Is there anything wrong with this
yes it have you cant compare strings like that use strcmp


Re: This error - VincenzoDrift - 02.07.2016

Delete this.
Quote:

if(PlayerInfo[pAdvert] != "None") // Error line

Write this.
Code:
if(!strcmp(PlayerInfo[pAdvert], "None", false, 128))
Read this
https://sampwiki.blast.hk/wiki/Strcmp