House System [Please Help]
#1

Well the problem is, it loads the icon and creates the textdraw, but then when it loads the houses, it someone starts adding thousands of houses... Here is a example:

I create house at X, Y, Z

I can enter it but I can not exit from it, instead it takes me to some random house that it created, and I remove the other houses and they get added again... I dont know why this is doing so.

pawn Код:
#include <a_samp>

#define COLOR_BLUE 0x2641FEAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA

enum hInfo
{
    Float:hEntranceX,
    Float:hEntranceY,
    Float:hEntranceZ,
    Float:hEntranceA,
    Float:hExitX,
    Float:hExitY,
    Float:hExitZ,
    Float:hExitA,
    hOwner[MAX_PLAYER_NAME],
    hDescription[MAX_PLAYER_NAME],
    hValue,
    hRevenue,
    hHel,
    hArm,
    //
    nInt,
    //
    hInt,
    hWorld,
    hLock,
    hOwned,
    hRooms,
    hRent,
    hRentable,
    hPickup,
    //
    hSellprice,
};
new HouseInfo[1000][hInfo];

stock LoadHouse()
{
    new arrCoords[24][64];
    new strFromFile2[128];
    new File: file = fopen("houses.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(HouseInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            HouseInfo[idx][hEntranceX] = floatstr(arrCoords[0]);
            HouseInfo[idx][hEntranceY] = floatstr(arrCoords[1]);
            HouseInfo[idx][hEntranceZ] = floatstr(arrCoords[2]);
            HouseInfo[idx][hEntranceA] = floatstr(arrCoords[3]);
            HouseInfo[idx][hExitX] = floatstr(arrCoords[4]);
            HouseInfo[idx][hExitY] = floatstr(arrCoords[5]);
            HouseInfo[idx][hExitZ] = floatstr(arrCoords[6]);
            HouseInfo[idx][hExitA] = floatstr(arrCoords[7]);
            strmid(HouseInfo[idx][hOwner], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            strmid(HouseInfo[idx][hDescription], arrCoords[9], 0, strlen(arrCoords[9]), 255);
            HouseInfo[idx][hValue] = strval(arrCoords[10]);
            HouseInfo[idx][hRevenue] = strval(arrCoords[11]);
            HouseInfo[idx][hHel] = strval(arrCoords[12]);
            HouseInfo[idx][hArm] = strval(arrCoords[13]);
            HouseInfo[idx][nInt] = strval(arrCoords[14]);
            HouseInfo[idx][hInt] = strval(arrCoords[15]);
            HouseInfo[idx][hWorld] = strval(arrCoords[16]);
            HouseInfo[idx][hLock] = strval(arrCoords[17]);
            HouseInfo[idx][hOwned] = strval(arrCoords[18]);
            HouseInfo[idx][hRooms] = strval(arrCoords[19]);
            HouseInfo[idx][hRent] = strval(arrCoords[20]);
            HouseInfo[idx][hRentable] = strval(arrCoords[21]);
            HouseInfo[idx][hPickup] = strval(arrCoords[22]);
            HouseInfo[idx][hSellprice] = strval(arrCoords[23]);
            if(HouseInfo[idx][hOwned] == 0)
            {
                new string[126];
                format(string, sizeof(string), "Home For Sale \n Price: %d \n Type [/enter] To Go Inside", HouseInfo[idx][hValue]);
                Create3DTextLabel(string, COLOR_RED, HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ], 10, 0);
                HouseInfo[idx][hPickup] = CreatePickup(1273,1,HouseInfo[idx][hEntranceX],HouseInfo[idx][hEntranceY],HouseInfo[idx][hEntranceZ],0);
            }
            if(HouseInfo[idx][hOwned] == 1)
            {
                new string[126];
                format(string, sizeof(string), "Home Owner: %s \n Locked: %d \n Type [/enter] To Go Inside", HouseInfo[idx][hOwner], HouseInfo[idx][hLock]);
                Create3DTextLabel(string, COLOR_GREEN, HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ], 10, 0);
                HouseInfo[idx][hPickup] = CreatePickup(1239,1,HouseInfo[idx][hEntranceX],HouseInfo[idx][hEntranceY],HouseInfo[idx][hEntranceZ],0);
            }
            if(!strlen(HouseInfo[idx][hOwner]))
            {
                strmid(HouseInfo[idx][hOwner],"Fort Carson",0,10,255);
            }
            idx++;
        }
        print(" ");
        print("Dynamic Houses");
        print("---------------");
        printf("  Loaded %d dynamic houses.\n",sizeof(HouseInfo));
        fclose(file);
    }
    return 1;
}

stock SaveHouse()
{
    new idx;
    new File: file2;
    while (idx < sizeof(HouseInfo))
    {
        new coordsstring[128];
        format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%f,%f,%f,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
        HouseInfo[idx][hEntranceX],
        HouseInfo[idx][hEntranceY],
        HouseInfo[idx][hEntranceZ],
        HouseInfo[idx][hEntranceA],
        HouseInfo[idx][hExitX],
        HouseInfo[idx][hExitY],
        HouseInfo[idx][hExitZ],
        HouseInfo[idx][hExitA],
        HouseInfo[idx][hOwner],
        HouseInfo[idx][hDescription],
        HouseInfo[idx][hValue],
        HouseInfo[idx][hRevenue],
        HouseInfo[idx][hHel],
        HouseInfo[idx][hArm],
        //
        HouseInfo[idx][nInt],
        //
        HouseInfo[idx][hInt],
        HouseInfo[idx][hWorld],
        HouseInfo[idx][hLock],
        HouseInfo[idx][hOwned],
        HouseInfo[idx][hRooms],
        HouseInfo[idx][hRent],
        HouseInfo[idx][hRentable],
        HouseInfo[idx][hPickup],
        //
        HouseInfo[idx][hSellprice]);
        if(idx == 0)
        {
            file2 = fopen("houses.cfg", io_write);
        }
        else
        {
            file2 = fopen("houses.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)