[FIXXED]
#1

I don't know how long i've been trying this, my final way to do this is to look at another scripts and attempt to make my own in a similar way.

Bascially, It reads from a file: scriptfiles/houses/house.cfg and creates pickups there:

The way I've created it to being in the house.cfg file is:
OwnerName, HouseCost, HouseId, HouseInterior, HouseXPos, HouseYPos, HouseZPos

Here is what I have in it:
Код:
None, 1000, 1, 4, -987908085, -1004970794, 1124372480
Here is the code I am trying to get to load that:
Код:
forward LoadHouse();
Код:
public LoadHouses()
{
	new arrCoords[29][64];
	new strFromFile2[256];
	new File: file = fopen("houses/house.cfg", io_read);
	if (file)
	{
		new idx;
		while (idx < sizeof(HouseInfo))
		{
			fread(file, strFromFile2);
			split(strFromFile2, arrCoords, ',');
 			strmid(HouseInfo[idx][hHouseOwnerName], arrCoords[13], 0, strlen(arrCoords[13]), 255);
 			HouseInfo[idx][hHouseCost] = strval(arrCoords[14]);
  			HouseInfo[idx][hHouseId] = strval(arrCoords[14]);
  			HouseInfo[idx][hHouseInterior] = strval(arrCoords[14]);
			HouseInfo[idx][hHousex] = floatstr(arrCoords[0]);
			HouseInfo[idx][hHousey] = floatstr(arrCoords[1]);
			HouseInfo[idx][hHousez] = floatstr(arrCoords[2]);
			CreatePickup(1273, 1, HouseInfo[idx][hHousex], HouseInfo[idx][hHousey], HouseInfo[idx][hHousez]);
			idx++;
		}
		fclose(file);
		}
	return 1;
}
Yes, if you are wondering I got the idea of the layout from The GodFather Script, It was a last resort as is asking you this! why is it not loading?
Reply
#2

Yes, I am bumping it because it went to the other page and no help was received.
Please assist
Thank you.
Reply
#3

I wanna help you with this. I will try and fix it and edit it in when I'm done.
Reply
#4

Another bump, since it is on the third page, any assistance please, I seriously need to solve this problem.
Reply
#5

Hmm.... Wow, I have tried to work out why it's not loading but sorry I couldn't find out why. Sorry.
Reply
#6

pawn Код:
public LoadHouses()
{
    new arrCoords[7][64];
    new strFromFile2[256];
    new File: file = fopen("houses/house.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(HouseInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            strmid(HouseInfo[idx][hHouseOwnerName], arrCoords[0], 0, strlen(arrCoords[0]), 255);
            HouseInfo[idx][hHouseCost] = strval(arrCoords[1]);
            HouseInfo[idx][hHouseId] = strval(arrCoords[2]);
            HouseInfo[idx][hHouseInterior] = strval(arrCoords[3]);
            HouseInfo[idx][hHousex] = floatstr(arrCoords[4]);
            HouseInfo[idx][hHousey] = floatstr(arrCoords[5]);
            HouseInfo[idx][hHousez] = floatstr(arrCoords[6]);
            CreatePickup(1273, 1, HouseInfo[idx][hHousex], HouseInfo[idx][hHousey], HouseInfo[idx][hHousez]);
            idx++;
        }
        fclose(file);
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by MadeMan
pawn Код:
public LoadHouses()
{
    new arrCoords[7][64];
    new strFromFile2[256];
    new File: file = fopen("houses/house.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(HouseInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            strmid(HouseInfo[idx][hHouseOwnerName], arrCoords[0], 0, strlen(arrCoords[0]), 255);
            HouseInfo[idx][hHouseCost] = strval(arrCoords[1]);
            HouseInfo[idx][hHouseId] = strval(arrCoords[2]);
            HouseInfo[idx][hHouseInterior] = strval(arrCoords[3]);
            HouseInfo[idx][hHousex] = floatstr(arrCoords[4]);
            HouseInfo[idx][hHousey] = floatstr(arrCoords[5]);
            HouseInfo[idx][hHousez] = floatstr(arrCoords[6]);
            CreatePickup(1273, 1, HouseInfo[idx][hHousex], HouseInfo[idx][hHousey], HouseInfo[idx][hHousez]);
            idx++;
        }
        fclose(file);
    }
    return 1;
}
That didn't work.
Reply
#8

Where do you use the function LoadHouses() ?
Reply
#9

OnGameModeInit
Reply
#10

Maybe try adding "/" to the file source.

pawn Код:
new File: file = fopen("/houses/house.cfg", io_read);
EDIT: I tested it and it works for me even if I don't add that extra "/".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)