20.12.2013, 20:34
So I am making a command for fun and I am mostly practicing y_ini as I do not have full knowledge about it yet, for instance with that INI_Parse thing but that's an other issue. My issue is that the command "/createbiz" is creating the "properties.ini" and "businesses.ini" file but when I create the next pickup it doesn't add up a new number on the integer "newBiz":
My enum keeping so far only two variables:
Basically followed the y_ini thread:
The WHOLE command, look below for smaller parts where I explain it as well:
The newBiz is declared here:
Should load the properties.ini and write the previous number +1 in the file:
Should write the x, y, z coordinates:
My theory is that it doesn't work because it doesn't load the file. It does actually create the file and set the first number to 1 but then it just makes a 1 after that. Loading must be wrong so then my question is, how would I load properly? :S
My enum keeping so far only two variables:
Код:
enum Property { Houses, Businesses } new eStats[Property];
Код:
INI:properties[](name[], value[]) { INI_Int("Houses", eStats[Houses]); INI_Int("Businesses", eStats[Businesses]); return 0; }
Код:
CMD:createbiz(playerid, params[]) { if(isPlayerAnAdmin(playerid, 4)) { new intID, Float:x, Float:y, Float:z, vw, iw, newBiz; if(sscanf(params, "i", intID)) return SCM(playerid, COLOR_GREY, "Usage: /createbiz [interior ID]"); GetPlayerPos(playerid, x, y, z); vw = GetPlayerVirtualWorld(playerid); iw = GetPlayerInterior(playerid); //Will add 1 to the properties count INI_Load("properties.ini"); newBiz = eStats[Businesses]; newBiz++; new INI:propFile = INI_Open("/Users/Stats/properties.ini"); INI_WriteInt(propFile, "Businesses", newBiz); INI_Close(propFile); //Will add the new pickup unique ID to an other file new u[128], tn[20]; format(u, sizeof(u), "%f, %f, %f", x, y, z); valstr(tn, newBiz); new INI:bizFile = INI_Open("/Users/Stats/businesses.ini"); INI_WriteString(bizFile, tn, u); INI_Close(bizFile); CreateDynamicPickup(1273, 1, x, y, z, vw, iw, -1, 100.0); //1273 = green house return 1; } else { NoAuth; return 1; } }
Код:
new intID, Float:x, Float:y, Float:z, vw, iw, newBiz;
Код:
INI_Load("properties.ini"); newBiz = eStats[Businesses]; newBiz++; new INI:propFile = INI_Open("/Users/Stats/properties.ini"); INI_WriteInt(propFile, "Businesses", newBiz); INI_Close(propFile);
Код:
new u[128], tn[20]; format(u, sizeof(u), "%f, %f, %f", x, y, z); valstr(tn, newBiz); new INI:bizFile = INI_Open("/Users/Stats/businesses.ini"); INI_WriteString(bizFile, tn, u); INI_Close(bizFile);