SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/07/2019, 02:09 PM   #1
TechLunatic
Little Clucker
 
TechLunatic's Avatar
 
Join Date: Jun 2019
Location: Bangladesh
Posts: 10
Reputation: 0
Default error 006: must be assigned to an array

What is wrong here?

PHP Code:
enum ENUM_PLAYER_DATA
{
    
Age[32],
    
Gender,
    
Skin,
    
    
CachePlayer_Cache,
    
bool:LoggedIn
}



public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch (
dialogid)
    {
        case 
DIALOG_AGE:
        {
            if(!
response) return Kick(playerid);

            if( 
inputtext[playerid] < 18 || inputtext[playerid] > 50)
            
            {

                
SCM(playerid0x969696FF"Invalid AGE length, should be 18 - 50.");

                new 
String[100];

                
format(Stringsizeof(String), "{FFFFFF}Welcome %s.\n\n {0099FF}Please, input your age below to proceed.\n\n"pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_AGEDIALOG_STYLE_INPUT"Account Registration - Age"String"Proceed""Leave");
            }
            else
            {
                
pInfo[playerid][Age] = strlen(inputtext);
                new 
int[50];

                
format(intsizeof(int), "{FFFFFF}Welcome %s.\n\n {0099FF}Please, input your gender below to proceed. (1 - MALE || 2 - FEMALE) || 3 - OTHER\n\n"pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_GENDERDIALOG_STYLE_INPUT"Account Registration - Gender"int"Proceed""Leave");
            }
        }
        case 
DIALOG_GENDER:
        {
          if(!
response) return Kick(playerid);
          {
             if(
listitem || listitem 3)
             {
                new 
int[50];
                
                
format(intsizeof(int), "{FFFFFF}Welcome %s.\n\n {0099FF}Please, input your gender below to proceed. (1 - MALE || 2 - FEMALE || 3 - OTHER)\n\n"pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_GENDERDIALOG_STYLE_INPUT"Account Registration - Gender"int"Proceed""Leave");
             }
             
             
pInfo[playerid][Gender] = inputtext// ERROR 006: must be assigned to an array

             
switch(pInfo[playerid][Gender])
               {
                      case 
1:  pInfo[playerid][Skin] = 230SendClientMessage(playeridCOLOR_WHITE2"Alright, so you're a Male.");
                      case 
2:  pInfo[playerid][Skin] = 77SendClientMessage(playeridCOLOR_WHITE2"Alright, so you're a Female.");
                      case 
3:  pInfo[playerid][Skin] = 0SendClientMessage(playeridCOLOR_WHITE2"Alright, so you're in Other Gender, We give you CJ skin.");
               }
             new 
DB_Query[225];
             
mysql_format(DatabaseDB_Querysizeof(DB_Query), "INSERT INTO `PLAYERS` (`USERNAME`, `PASSWORD`, `SALT`, `SCORE`, `KILLS`, `CASH`, `DEATHS`, `AGE`, `GENDER`)\
             VALUES ('%e', '%s', '%e', '20', '0', '0', '0', '%i', '%i')"
pInfo[playerid][Name], pInfo[playerid][Password], pInfo[playerid][Salt], pInfo[playerid][Age], pInfo[playerid][Gender]);
             
mysql_tquery(DatabaseDB_Query"OnPlayerRegister""d"playerid);
               
            }
         }
        case 
DIALOG_REGISTER:
        {
            if(!
response) return Kick(playerid);

            if(
strlen(inputtext) <= || strlen(inputtext) > 60)
            {

                
SCM(playerid0x969696FF"Invalid password length, should be 5 - 60.");

                new 
String[150];

                
format(Stringsizeof(String), "{FFFFFF}Welcome %s.\n\n{0099FF}This account is not registered.\n\
                {0099FF}Please, input your password below to proceed.\n\n"
pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Account Registration"String"Register""Leave");
            }
            else
            {
                for (new 
010i++)
                {
                    
pInfo[playerid][Salt][i] = random(79) + 47;
                }

                
pInfo[playerid][Salt][10] = 0;
                
SHA256_PassHash(inputtextpInfo[playerid][Salt], pInfo[playerid][Password], 65);

                new 
String[100];
                
format(Stringsizeof(String), "{FFFFFF}Welcome %s.\n\n {0099FF}Please, input your age below to proceed.\n\n"pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_AGEDIALOG_STYLE_INPUT"Account Registration - AGE"String"Proceed""Leave");
           }
        }
    }
    return 
1;

TechLunatic is offline   Reply With Quote
Old 12/07/2019, 02:11 PM   #2
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 850
Reputation: 43
Default Re: error 006: must be assigned to an array

instead of Age[32], use Age,
__________________
here to help
Mugala is offline   Reply With Quote
Old 12/07/2019, 02:15 PM   #3
TechLunatic
Little Clucker
 
TechLunatic's Avatar
 
Join Date: Jun 2019
Location: Bangladesh
Posts: 10
Reputation: 0
Default Re: error 006: must be assigned to an array

Quote:
Originally Posted by Mugala View Post
instead of Age[32], use Age,
lmao, thanks but how to solve the error?
TechLunatic is offline   Reply With Quote
Old 12/07/2019, 02:17 PM   #4
Macronix
Huge Clucker
 
Macronix's Avatar
 
Join Date: Jul 2010
Location: Germany
Posts: 474
Reputation: 100
Default Re: error 006: must be assigned to an array

Gender needs to be a string and not an integer in this case. Or just use "strval(inputtext);"
Macronix is offline   Reply With Quote
Old 12/07/2019, 02:18 PM   #5
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 850
Reputation: 43
Default Re: error 006: must be assigned to an array

[32] is a number of total array for Age variable, which is used for... mdah I dunno how to explain.
imagine that you have 32 variable with save name but different numbers
for example Age[1] = 16, Age[2] = 18, Age[3] = 20 and so on...
also it's used for texts size for variable, better see tutorials, I'm bad in explains
__________________
here to help
Mugala is offline   Reply With Quote
Old 12/07/2019, 02:21 PM   #6
TechLunatic
Little Clucker
 
TechLunatic's Avatar
 
Join Date: Jun 2019
Location: Bangladesh
Posts: 10
Reputation: 0
Default Re: error 006: must be assigned to an array

Quote:
Originally Posted by Macronix View Post
Gender needs to be a string and not an integer in this case. Or just use "strval(inputtext);"
Thanks.
TechLunatic is offline   Reply With Quote
Old 12/07/2019, 02:42 PM   #7
TechLunatic
Little Clucker
 
TechLunatic's Avatar
 
Join Date: Jun 2019
Location: Bangladesh
Posts: 10
Reputation: 0
Default Re: error 006: must be assigned to an array

new problem:
When I try to register
on the Gender dialog if I enter 1 or 2 or 3 and than click proceed than the Gender Dialog just pops up again :/
I made columns in MySQL as well



PHP Code:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch (
dialogid)
    {
        case 
DIALOG_AGE:
        {
            if(!
response) return Kick(playerid);

            if( 
inputtext[playerid] < 18 || inputtext[playerid] > 50)
            
            {

                
SCM(playerid0x969696FF"Invalid AGE length, should be 18 - 50.");

                new 
String[100];

                
format(Stringsizeof(String), "{FFFFFF}Welcome %s.\n\n {0099FF}Please, input your age below to proceed.\n\n"pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_AGEDIALOG_STYLE_INPUT"Account Registration - Age"String"Proceed""Leave");
            }
            else
            {
                
pInfo[playerid][Age] = strlen(inputtext);
                new 
String[50];

                
format(Stringsizeof(String), "{FFFFFF}Welcome %s.\n\n {0099FF}Please, input your gender below to proceed. (1 - MALE || 2 - FEMALE) || 3 - OTHER\n\n"pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_GENDERDIALOG_STYLE_INPUT"Account Registration - Gender"String"Proceed""Leave");
            }
        }
        case 
DIALOG_GENDER:
        {
          if(!
response) return Kick(playerid);
          {
             if(
listitem || listitem 3)
             {
                new 
String[50];
                
                
format(Stringsizeof(String), "{FFFFFF}Welcome %s.\n\n {0099FF}Please, input your gender below to proceed. (1 - MALE || 2 - FEMALE || 3 - OTHER)\n\n"pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_GENDERDIALOG_STYLE_INPUT"Account Registration - Gender"String"Proceed""Leave");
             }
             
             
pInfo[playerid][Gender] = strval(inputtext);

             switch(
pInfo[playerid][Gender])
               {
                      case 
1:  pInfo[playerid][Skin] = 230SendClientMessage(playeridCOLOR_WHITE2"Alright, so you're a Male.");
                      case 
2:  pInfo[playerid][Skin] = 77SendClientMessage(playeridCOLOR_WHITE2"Alright, so you're a Female.");
                      case 
3:  pInfo[playerid][Skin] = 0SendClientMessage(playeridCOLOR_WHITE2"Alright, so you're in Other Gender, We give you CJ skin.");
               }
             new 
DB_Query[225];
             
mysql_format(DatabaseDB_Querysizeof(DB_Query), "INSERT INTO `PLAYERS` (`USERNAME`, `PASSWORD`, `SALT`, `SCORE`, `KILLS`, `CASH`, `DEATHS`, `AGE`, `GENDER`, `SKIN`)\
             VALUES ('%e', '%s', '%e', '20', '0', '0', '0', '%i', '%i', %i)"
pInfo[playerid][Name], pInfo[playerid][Password], pInfo[playerid][Salt], pInfo[playerid][Age], pInfo[playerid][Gender], pInfo[playerid][Skin]);
             
mysql_tquery(DatabaseDB_Query"OnPlayerRegister""d"playerid);
               
            }
         }
       case 
DIALOG_REGISTER:
        {
            if(!
response) return Kick(playerid);

            if(
strlen(inputtext) <= || strlen(inputtext) > 60)
            {

                
SCM(playerid0x969696FF"Invalid password length, should be 5 - 60.");

                new 
String[150];

                
format(Stringsizeof(String), "{FFFFFF}Welcome %s.\n\n{0099FF}This account is not registered.\n\
                {0099FF}Please, input your password below to proceed.\n\n"
pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Account Registration"String"Register""Leave");
            }
            else
            {
                for (new 
010i++)
                {
                    
pInfo[playerid][Salt][i] = random(79) + 47;
                }

                
pInfo[playerid][Salt][10] = 0;
                
SHA256_PassHash(inputtextpInfo[playerid][Salt], pInfo[playerid][Password], 65);

                new 
String[100];
                
format(Stringsizeof(String), "{FFFFFF}Welcome %s.\n\n {0099FF}Please, input your age below to proceed.\n\n"pInfo[playerid][Name]);
                
ShowPlayerDialog(playeridDIALOG_AGEDIALOG_STYLE_INPUT"Account Registration - AGE"String"Proceed""Leave");
           }
        }
    }
    return 
1;

TechLunatic is offline   Reply With Quote
Old 12/07/2019, 04:52 PM   #8
v1k1nG
Huge Clucker
 
v1k1nG's Avatar
 
Join Date: Feb 2018
Posts: 440
Reputation: 31
Default Re: error 006: must be assigned to an array

PHP Code:
inputtext[playerid
This way if playerid is 0 script will only check 1st bit of inputtext.
Use inputtext without the square braces.
v1k1nG is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error 006: must be assigned to an array Vaki Scripting Help 5 07/09/2015 05:06 PM
error 006: must be assigned to an array HerBan Scripting Help 1 29/08/2014 04:52 PM
error 006: must be assigned to an array TheDeath Scripting Help 3 25/04/2013 09:45 AM
error 006: must be assigned to an array(To array set string) gamelaster Scripting Help 4 02/02/2012 04:25 AM
error 006: must be assigned to an array ruarai Help Archive 5 28/09/2009 09:33 AM


All times are GMT. The time now is 10:26 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.