Y_ini issue
#1

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:
Код:
enum Property
{
	Houses,
	Businesses
}
new eStats[Property];
Basically followed the y_ini thread:
Код:
INI:properties[](name[], value[])
{
   	INI_Int("Houses", eStats[Houses]);
	INI_Int("Businesses", eStats[Businesses]);
	return 0;
}
The WHOLE command, look below for smaller parts where I explain it as well:
Код:
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;
	}
}
The newBiz is declared here:
Код:
new intID, Float:x, Float:y, Float:z, vw, iw, newBiz;
Should load the properties.ini and write the previous number +1 in the file:
Код:
		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);
Should write the x, y, z coordinates:
Код:
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);
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
Reply
#2

I'll post what I told you on Skype because this might assist someone in the future.

http://asylumofgamers.com/helpdesk/dynbiz.txt
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)