Making this load OnGamemodeinit
#1

Alright, basically I have this code, In-Game I can create furniture and it saves in the .ini file but the issue is loading it.
This is the Loading thing, how do I make it exactly to load? I have no clue I been messing around with it for over 3hours on trying to create stocks etc..
But the issue I am having is how do I implement it so when the server starts it loads the furniture objects, if anyone could create the code for me I would really appreciate it.. It would help me analyse the script and understand on how its working.

Код:
forward LoadFurn(id);
public LoadFurn(id)
{
	new arrCoords[8][64], strFromFile2[255], string[255];
	format(string, sizeof(string), "housedata/%d.ini", id);
	if(!DOF2_FileExists(string)) return true;
	new File: file = fopen(string, io_read);
	if (file)
	{
		new idx;
		while (idx < MAX_HOUSE_OBJ)
		{
			fread(file, strFromFile2);
			split(strFromFile2, arrCoords, ',');
			if(strval(arrCoords[0]) >= 1)
			{
				HouseInfo[id][hoID][idx] = strval(arrCoords[0]);
				HouseInfo[id][hoX][idx] = floatstr(arrCoords[1]);
		    	HouseInfo[id][hoY][idx] = floatstr(arrCoords[2]);
				HouseInfo[id][hoZ][idx] = floatstr(arrCoords[3]);
		    	HouseInfo[id][horX][idx] = floatstr(arrCoords[4]);
		    	HouseInfo[id][horY][idx] = floatstr(arrCoords[5]);
				HouseInfo[id][horZ][idx] = floatstr(arrCoords[6]);
		    	HouseInfo[id][hoInt][idx] = strval(arrCoords[7]);
		    	//==========//
		    	HouseInfo[id][hObject][idx] = CreateDynamicObject(HouseInfo[id][hoID][idx], HouseInfo[id][hoX][idx], HouseInfo[id][hoY][idx], HouseInfo[id][hoZ][idx], HouseInfo[id][horX][idx], HouseInfo[id][horY][idx], HouseInfo[id][horZ][idx], id);
		    }
			idx++;
		}
	}
	fclose(file);
	return 1;
}
Reply
#2

can you try this and tell me what did it print?:

pawn Код:
forward LoadFurn(id);
public LoadFurn(id)
{
    new arrCoords[8][64], strFromFile2[255], string[255];
    format(string, sizeof(string), "housedata/%d.ini", id);
    if(!DOF2_FileExists(string)) return true;
    new File: file = fopen(string, io_read);
    if (file)
    {
        new idx;
        while (idx < MAX_HOUSE_OBJ)
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            if(strval(arrCoords[0]) >= 1)
            {
                HouseInfo[id][hoID][idx] = strval(arrCoords[0]);
                HouseInfo[id][hoX][idx] = floatstr(arrCoords[1]);
                HouseInfo[id][hoY][idx] = floatstr(arrCoords[2]);
                HouseInfo[id][hoZ][idx] = floatstr(arrCoords[3]);
                HouseInfo[id][horX][idx] = floatstr(arrCoords[4]);
                HouseInfo[id][horY][idx] = floatstr(arrCoords[5]);
                HouseInfo[id][horZ][idx] = floatstr(arrCoords[6]);
                HouseInfo[id][hoInt][idx] = strval(arrCoords[7]);
                //==========//
                HouseInfo[id][hObject][idx] = CreateDynamicObject(HouseInfo[id][hoID][idx], HouseInfo[id][hoX][idx], HouseInfo[id][hoY][idx], HouseInfo[id][hoZ][idx], HouseInfo[id][horX][idx], HouseInfo[id][horY][idx], HouseInfo[id][horZ][idx], id);
            }
                        print("Object Created!");
                        printf("ID:%d",id);
            idx++;
        }
    }
    fclose(file);
    return 1;
}
Reply
#3

Here is the function that should load it into the gamemode, I tried fiddling with the LoadFurn so it fits into LoadProperty but I can't do it.. it also says that the ID is undefined.

Код:
public LoadProperty()
{
    printf("Loading Properties and furniture...");
	new arrCoords[45][64], strFromFile2[256];
	new File: file = fopen("property.ini", io_read);
	if (file)
	{
		new idx;
		while (idx < sizeof(HouseInfo))
		{
			fread(file, strFromFile2);
			split(strFromFile2, arrCoords, ',');
			strmid(HouseInfo[idx][hName], arrCoords[0], 0, strlen(arrCoords[0]), 255);
			HouseInfo[idx][hLock] = strval(arrCoords[1]);
			HouseInfo[idx][hHours] = strval(arrCoords[2]);
			HouseInfo[idx][hPrice] = strval(arrCoords[3]);
			HouseInfo[idx][hEnterX] = floatstr(arrCoords[4]);
			HouseInfo[idx][hEnterY] = floatstr(arrCoords[5]);
			HouseInfo[idx][hEnterZ] = floatstr(arrCoords[6]);
			HouseInfo[idx][hExitX] = floatstr(arrCoords[7]);
			HouseInfo[idx][hExitY] = floatstr(arrCoords[8]);
			HouseInfo[idx][hExitZ] = floatstr(arrCoords[9]);
			strmid(HouseInfo[idx][hOwner], arrCoords[10], 0, strlen(arrCoords[10]), 255);
			HouseInfo[idx][hOwned] = strval(arrCoords[11]);
			HouseInfo[idx][hRentable] = strval(arrCoords[12]);
			HouseInfo[idx][hRent] = strval(arrCoords[13]);
			HouseInfo[idx][hInterior] = strval(arrCoords[14]);
			HouseInfo[idx][hMoney] = strval(arrCoords[15]);
			HouseInfo[idx][hGun][0] = strval(arrCoords[16]);
			HouseInfo[idx][hGunAmmo][0] = strval(arrCoords[17]);
			HouseInfo[idx][hWeed] = strval(arrCoords[18]);
			HouseInfo[idx][hCocaine] = strval(arrCoords[19]);
			HouseInfo[idx][hCrack] = strval(arrCoords[20]);
			HouseInfo[idx][hArmour] = floatstr(arrCoords[21]);
			HouseInfo[idx][hType] = strval(arrCoords[22]);
			HouseInfo[idx][hEInt] = strval(arrCoords[23]);
			HouseInfo[idx][hEWorld] = strval(arrCoords[24]);
			HouseInfo[idx][hTime] = strval(arrCoords[25]);
			HouseInfo[idx][hGun][1] = strval(arrCoords[26]);
			HouseInfo[idx][hGunAmmo][1] = strval(arrCoords[27]);
			HouseInfo[idx][hGun][2] = strval(arrCoords[28]);
			HouseInfo[idx][hGunAmmo][2] = strval(arrCoords[29]);
			HouseInfo[idx][hGun][3] = strval(arrCoords[30]);
			HouseInfo[idx][hGunAmmo][3] = strval(arrCoords[31]);
			HouseInfo[idx][hComd] = strval(arrCoords[32]);
			HouseInfo[idx][hGun][4] = strval(arrCoords[33]);
			HouseInfo[idx][hGunAmmo][4] = strval(arrCoords[34]);
			HouseInfo[idx][hGun][5] = strval(arrCoords[35]);
			HouseInfo[idx][hGunAmmo][5] = strval(arrCoords[36]);
			HouseInfo[idx][hGun][6] = strval(arrCoords[37]);
			HouseInfo[idx][hGunAmmo][6] = strval(arrCoords[38]);
			HouseInfo[idx][hGun][7] = strval(arrCoords[39]);
			HouseInfo[idx][hGunAmmo][7] = strval(arrCoords[40]);
			HouseInfo[idx][hGun][8] = strval(arrCoords[41]);
			HouseInfo[idx][hGunAmmo][8] = strval(arrCoords[42]);
			HouseInfo[idx][hGun][9] = strval(arrCoords[43]);
			HouseInfo[idx][hGunAmmo][9] = strval(arrCoords[44]);
		    	new string[128];
		    	format(string, sizeof(string), "housedata/%d.ini", id);
		    	if(DOF2_FileExists(string))
		    	{
		        	LoadFurn(id);
		    	}
			idx++;
		}
 }
	fclose(file);
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)