House system help [+rep]
#1

Hello , I had some problems with my house system them not saving now it saves but i get a problem where if you buy it and the server restarts the interior is gone this is my save and load
pawn Код:
public LoadHouses()
{
    new arrCoords[23][64];
    new strFromFile2[256];
    new File: file = fopen("Houses.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(HouseInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            HouseInfo[idx][hOwned] = strval(arrCoords[0]);
            HouseInfo[idx][hPrice] = strval(arrCoords[1]);
            strmid(HouseInfo[idx][hOwner], arrCoords[2], 0, strlen(arrCoords[2]), 255);
            HouseInfo[idx][hLevel] = strval(arrCoords[3]);
            HouseInfo[idx][hLocked] = strval(arrCoords[4]);
            HouseInfo[idx][hRentable] = strval(arrCoords[5]);
            HouseInfo[idx][hRentPrice] = strval(arrCoords[6]);
            HouseInfo[idx][hGun1] = strval(arrCoords[7]);
            HouseInfo[idx][hGun2] = strval(arrCoords[8]);
            HouseInfo[idx][hGun3] = strval(arrCoords[9]);
            HouseInfo[idx][hMoney] = strval(arrCoords[10]);
            HouseInfo[idx][hEntranceX] = floatstr(arrCoords[11]);
            HouseInfo[idx][hEntranceY] = floatstr(arrCoords[12]);
            HouseInfo[idx][hEntranceZ] = floatstr(arrCoords[13]);
            HouseInfo[idx][hEntranceA] = floatstr(arrCoords[14]);
            HouseInfo[idx][hExitX] = floatstr(arrCoords[15]);
            HouseInfo[idx][hExitY] = floatstr(arrCoords[16]);
            HouseInfo[idx][hExitZ] = floatstr(arrCoords[17]);
            HouseInfo[idx][hExitA] = floatstr(arrCoords[18]);
            HouseInfo[idx][hInt] = strval(arrCoords[19]);
            HouseInfo[idx][hWorld] = strval(arrCoords[20]);
            HouseInfo[idx][hInsideInt] = strval(arrCoords[21]);
            HouseInfo[idx][hInsideWorld] = strval(arrCoords[22]);
            if(HouseInfo[idx][hOutsideIcon]) DestroyDynamicPickup(HouseInfo[idx][hOutsideIcon]);
            if(HouseInfo[idx][hInsideIcon]) DestroyDynamicPickup(HouseInfo[idx][hInsideIcon]);
            HouseInfo[idx][hOutsideIcon] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ], HouseInfo[idx][hWorld]);
            HouseInfo[idx][hInsideIcon] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hExitX], HouseInfo[idx][hExitY], HouseInfo[idx][hExitZ], HouseInfo[idx][hInsideWorld]);
            idx++;
        }
        fclose(file);
    }
    return 1;
}

public SaveHouses()
{
    new idx;
    new File: file2;
    while (idx < sizeof(HouseInfo))
    {
        new coordsstring[128];
        format(coordsstring, sizeof(coordsstring), "%d,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%d,%d,%d,%d\r\n",
        HouseInfo[idx][hOwned],
        HouseInfo[idx][hPrice],
      HouseInfo[idx][hOwner],
        HouseInfo[idx][hLevel],
        HouseInfo[idx][hLocked],
        HouseInfo[idx][hRentable],
        HouseInfo[idx][hRentPrice],
        HouseInfo[idx][hGun1],
        HouseInfo[idx][hGun2],
        HouseInfo[idx][hGun3],
        HouseInfo[idx][hMoney],
        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][hInt],
        HouseInfo[idx][hWorld],
        HouseInfo[idx][hInsideInt],
        HouseInfo[idx][hInsideWorld]);
        if(idx == 0)
        {
            file2 = fopen("Houses.cfg", io_write);
        }
        else
        {
            file2 = fopen("Houses.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
And what happends
pawn Код:
0,0,0,0,0,0,0,0,0,0,0,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0,0,0
0,100000,0,1,1,0,0,0,0,0,0,2741.324462,-2556.731201,14.201099,107.283454,2259.533935,-1135.811401,1050.632812,273.193237,0,0,100,0,,0,1,0,0,0,0,0,0,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0,0,0
The zeros are the basic lines but it just duplicates i hope anyone can help me.
Reply
#2

Well, check the Houses.cfg if the coordinates are set properly in the file. How are you handling the houses? Are these interiors that you can change or are these static interiors?
Reply
#3

Quote:
Originally Posted by Campbell-
Посмотреть сообщение
Well, check the Houses.cfg if the coordinates are set properly in the file. How are you handling the houses? Are these interiors that you can change or are these static interiors?
Its set automaticly to one interior But its like he writes another 000000.0.0.0.0.0.0 file afterwards and where the 100000 is it should save a name and it loads correct and stuff except the owner and when i enter the house then i get teleported in the sky fall down and die.
Reply
#4

Bump
Reply
#5

better use y_ini(from ******) or some other file system.......
Reply
#6

Yeah if you can explain it to me its fine but i am not that good with Y_INI i have read the topics of tuts and stuff but i dont seem to find out what to do.

But even so i managed to create a registation system off it.
Reply
#7

Quote:
Originally Posted by demonarn
Посмотреть сообщение
Yeah if you can explain it to me its fine but i am not that good with Y_INI i have read the topics of tuts and stuff but i dont seem to find out what to do.

But even so i managed to create a registation system off it.
Yeah Y_INI is quit difficult to understand.......
Reply
#8

try new coordsstring[256];
Reply
#9

Quote:
Originally Posted by Shabi RoxX
Посмотреть сообщение
Yeah Y_INI is quit difficult to understand.......
well i managed to do it but i get some errors if you know how to fix it ?

pawn Код:
D:\sa-mp server\gamemodes\Testmyshit.pwn(7242) : warning 219: local variable "fstring" shadows a variable at a preceding level
D:\sa-mp server\gamemodes\Testmyshit.pwn(7245) : error 028: invalid subscript (not an array or too many subscripts): "hInfo"
D:\sa-mp server\gamemodes\Testmyshit.pwn(7245) : warning 215: expression has no effect
D:\sa-mp server\gamemodes\Testmyshit.pwn(7245) : error 001: expected token: ";", but found "]"
D:\sa-mp server\gamemodes\Testmyshit.pwn(7245) : error 029: invalid expression, assumed zero
D:\sa-mp server\gamemodes\Testmyshit.pwn(7245) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
pawn Код:
public LoadHouseData(houseid,name[],value[])
{
    new fstring[10]; //The string for the file [format] // line 7243
    format(fstring, 10, "Houses/%d", houseid);
    if(!fexist(fstring))return 0;
    INI_Bool("Owned",fstring) ? true : false, hInfo[houseid][hOwned]); // line 7245
    INI_Int("price",fstring,hInfo[houseid][hPrice]);
    strmid(hInfo[houseid][hOwner], INI_String("Owner",fstring), 0, false, strlen(INI_String("Owner")));
    INI_Int("Level",fstring,hInfo[houseid][hLevel]);
    INI_Int("Locked",fstring,hInfo[houseid][hLocked]);
    INI_Float("EntranceX",fstring,hInfo[houseid][hEntranceX]);
    INI_Float("EntranceY",fstring,hInfo[houseid][hEntranceY);
    INI_Float("EntranceZ",fstring, hInfo[houseid][hEntranceZ]);
    INI_Float("EntranceA",fstring, hInfo[houseid][hEntranceA]);
    INI_Float("ExitX",fstring, hInfo[houseid][hExitX]);
    INI_Float("ExitY",fstring, hInfo[houseid][hExitY]);
    INI_Float("ExitZ",fstring, hInfo[houseid][hExitZ]);
    INI_Float("ExitA",fstring, hInfo[houseid][hExitA]);
    INI_Int("HouseInterior",fstring, hInfo[houseid][hInt]);
    INI_Int("HouseWorld",fstring, hInfo[houseid][hWworld]);
    INI_Int("InsideInt",fstring, hInfo[houseid][hInsideInt]);
    INI_Int("InsideWorld",fstring, hInfo[houseid][hInsideWorld]);
    INI_Int("InsideIcon",fstring, hInfo[houseid][pInsideIcon]);
    INI_Int("OutsideIcon",fstring, hInfo[houseid][hOutsideIcon]);
    return 0;
}
Reply
#10

pawn Код:
INI_Float("EntranceY", fstring, hInfo[houseid][hEntranceY]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)