Please help! array must be indexed (variable "inputtext")
#1

Hi guys.
PHP код:
    if(dialogid == 8)
        {
          if(
response)
          {
               if(
listitem == 0)
               {
               new 
name[MAX_PLAYER_NAME], file[256];
               
GetPlayerName(playeridnamesizeof(name));
               
format(filesizeof(file), PATHname);
               
dini_Set(file"WDCK"dini_Int(file"WDCK")+inputtext);//error
               
new string[128];
               
format(stringsizeof(string), "仓库 %d",  dini_Int(file"WDCK"));
               
ShowPlayerDialog(playerid9DIALOG_STYLE_INPUT"仓库"string"Okay""");
               }
          }
        } 
Someone can tell me how?I use Dini on my server.Or tell me use other code do it.
Reply
#2

inputtext is an array, specifically a string in this instance. You will need to convert the string to an integer to use the addition operator.
pawn Код:
// Maybe should be dini_SetInt?
dini_Set(file, "WDCK", dini_Int(file, "WDCK")+strval(inputtext));
Regardless, I suggest you switch to a database for data management (SQLite/MySQL). It will make your life much easier when you want to make more complex systems. Plus, dini is horribly outdated now days (and slow!).
Reply
#3

maybe use strlen?
u're trying to save inputtext as int (not as text)
so if u're sure that u want to save string length, u could use strlen(inputtext)
PHP код:
dini_Set(file"WDCK"dini_Int(file"WDCK")+strlen(inputtext)); 
Reply
#4

Quote:
Originally Posted by Grim_
Посмотреть сообщение
inputtext is an array, specifically a string in this instance. You will need to convert the string to an integer to use the addition operator.
pawn Код:
// Maybe should be dini_SetInt?
dini_Set(file, "WDCK", dini_Int(file, "WDCK")+strval(inputtext));
Regardless, I suggest you switch to a database for data management (SQLite/MySQL). It will make your life much easier when you want to make more complex systems. Plus, dini is horribly outdated now days (and slow!).
I`ll try this.But SQLite/MySQL which better?
Reply
#5

Both are good.

MySQL providing thread supported becomes faster (BUT ONLY IF YOU USE THREADED QUERIES).

SQLite runs on a single thread and is still fast than all of the saving systems.

MySQL provides way more functions because it's utilizing the latest version of MySQL while the SQLite version which SA-MP utilizes is outdated but not outdated that it would become obsolete. But I'd love to see an update in it.

I prefer SQLite over MySQL for SA-MP since MySQL is an overkill. And any INI system is idiocracy (not smart).
Reply
#6

^^^^
Reply
#7

Quote:
Originally Posted by Logic_
Посмотреть сообщение
MySQL provides way more functions because it's utilizing the latest version of MySQL while the SQLite version which SA-MP utilizes is outdated but not outdated that it would become obsolete. But I'd love to see an update in it.

I prefer SQLite over MySQL for SA-MP since MySQL is an overkill. And any INI system is idiocracy (not smart).
INI files have their use cases. They are generally used for settings, which is a good use-case, since they aren't access very frequently and only require a simple file format. In SA:MP however, we're usually storing different data than single key-value pairs, so they don't fit well. This is true for (some) user systems.

As far as SQLite vs MySQL, it really depends what you are working with. I had an idea for a gamemode once that would store roughly 1m values per player, with the potential for more. Due the massive amount of data, and the speed/stability performance of multithreading, MySQL would have been my choice. But most of the time, like you said, SQLite is a perfectly fine fit.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)