06.07.2013, 14:31
Hi,
why this isn't working?
USAGE:
UpdateFileDetails2(10.0, 10.0, 10.0, 10.0, 10.0, "N/A", "N/A", "N/A", "N/A", "N/A");
UpdateFileDetails2(ccount[3][playerid], tops[0], tops[1], tops[2], tops[3], name[playerid], usrtops[0], usrtops[1], usrtops[2], usrtops[3]);
Variables:
by the way, i want to add option to my function that ables me to choose which keys change.
something like that:
by numargs functions (core.inc)
how can i do it?
And of course to choose the type, Float/String
i think i can do it with enumartion, something like KeysUpdateTypes and using switch + loop (for numargs)
It should work?
If there is a better way, I'd be happy to see it.
why this isn't working?
Код:
stock UpdateFileDetails2(Float: times[5], players[5][MAX_PLAYER_NAME+1]) { iniFile = INI_Open(fileToWrite); INI_SetTag(iniFile, "times"); new sValue[10]; for(new i = 0; i < 5; i++) { valstr(sValue, i); INI_WriteFloat(iniFile, sValue, times[i], 4); } INI_SetTag(iniFile, "players"); new arr[] = {"1st", "2nd", "2rd", "4th", "5th"}; for(new m = 0; m < 5; m++) INI_WriteString(iniFile, arr[m], players[m]); INI_Close(iniFile); }
UpdateFileDetails2(10.0, 10.0, 10.0, 10.0, 10.0, "N/A", "N/A", "N/A", "N/A", "N/A");
UpdateFileDetails2(ccount[3][playerid], tops[0], tops[1], tops[2], tops[3], name[playerid], usrtops[0], usrtops[1], usrtops[2], usrtops[3]);
Код:
ERRORS: MyCode.pwn(84) : error 035: argument type mismatch (argument 1) // UpdateFileDetails2(10.0, 10.0, 10.0, 10.0, 10.0, "N/A", "N/A", "N/A", "N/A", "N/A"); MyCode.pwn(85) : error 047: array sizes do not match, or destination array is too small // UpdateFileDetails2(ccount[3][playerid], tops[0], tops[1], tops[2], tops[3], pName[playerid], usrtops[0], usrtops[1], usrtops[2], usrtops[3]);
Код:
new Float: ccount[4][MAX_PLAYERS], Float: tops[5], usrtops[5][MAX_PLAYER_NAME + 1] ;
something like that:
Код:
UpdateFileDetails(key, value, key, value);
how can i do it?
And of course to choose the type, Float/String
i think i can do it with enumartion, something like KeysUpdateTypes and using switch + loop (for numargs)
Код:
enum KeysUpdateTypes { Float: times[5], players[5][MAX_PLAYER_NAME + 1] }; stock UpdateFileDetails({KeysUpdateTypes}:...) { iniFile = INI_Open(fileToWrite); for(new i = 0, n = numargs(); i < n; i++) switch(getarg(i)) { case times[0]: INI_WriteFloat(iniFile, "0", getarg(i+1), 4); // another times cases. case players[0]: INI_WriteString(iniFile, "1st", getarg(i+1)); } INI_Close(iniFile); return 1; }
If there is a better way, I'd be happy to see it.