07.10.2016, 22:08
Alright, so the include has been updated! It has completely new functions in addition to newly introduced string-related functions and global no-data-type-specific functions (therefore, I don't feel the need in replying to the replies above), that are vastly better and more useful (since the initial attempt ended up having to use ugly loops outside the functions, not to mention the loop inside each function to get a count so it could be used in another loop...).
Anyhow, this ugly mess:
Turns into (which is also a lot more efficient as SSCANF does most of the work now):
The best part is that you can specify the amount of cells the functions will build up in order to split strings (think of it as query used in SQL functions, but inverse). Meaning, there's no limit and it will speed up short to long processes (the more cells there are, the longer it takes).
Check out the main post for more information, and for the download link! Don't forget to check out the example file too!
Also, thanks to everyone!
Anyhow, this ugly mess:
PHP код:
new integers[MAX_INV_ITEMS*2], count, limit = sizeof (aInventory[])/2;
for (new i, k, j = split_integers(item_info, "|", integers); i < j; i++)
{
for (k = 0; k < sizeof (aInventory[][]); k++) // I removed "new" and added it to the main loop too, because it's better for optimization. (Creating stuff in loops = bad idea)
{
aInventory[playerid][count][eInventory: k] = integers[count+k];
}
count++;
if (count == limit)
break;
}
PHP код:
new sscanf_format[30];
SplitIntegers_IndexesEnum(string_to_split, "|", aInventory[playerid], "ii", "ii", sscanf_format);
Check out the main post for more information, and for the download link! Don't forget to check out the example file too!
Also, thanks to everyone!