Please help! array must be indexed (variable "inputtext") -
3417512908 - 26.03.2018
Hi guys.
PHP код:
if(dialogid == 8)
{
if(response)
{
if(listitem == 0)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), PATH, name);
dini_Set(file, "WDCK", dini_Int(file, "WDCK")+inputtext);//error
new string[128];
format(string, sizeof(string), "仓库 %d", dini_Int(file, "WDCK"));
ShowPlayerDialog(playerid, 9, DIALOG_STYLE_INPUT, "仓库", string, "Okay", "");
}
}
}
Someone can tell me how?I use Dini on my server.Or tell me use other code do it.
Re: Please help! array must be indexed (variable "inputtext") -
Grim_ - 26.03.2018
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!).
Re: Please help! array must be indexed (variable "inputtext") -
Mugala - 26.03.2018
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));
Re: Please help! array must be indexed (variable "inputtext") -
3417512908 - 26.03.2018
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?
Re: Please help! array must be indexed (variable "inputtext") -
Logic_ - 26.03.2018
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).
Re: Please help! array must be indexed (variable "inputtext") -
v1k1nG - 26.03.2018
^^^^
Re: Please help! array must be indexed (variable "inputtext") -
Grim_ - 26.03.2018
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.