This error
#1

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-"
Reply
#2

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

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
Reply
#4

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

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

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
Reply
#7

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)