House System Not Writing File
#1

How comes my house saves but writes nothing in the file


Here is the code


pawn Код:
#define HPATH "/Houses/%s.ini"

pawn Код:
stock HousePath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),HPATH,playername);
    return string;
}

pawn Код:
CMD:createhouse(playerid, params[])
{
    new Usage[128], string[128];
    if(sscanf(params, "s", Usage))
    {
        if(PlayerData[playerid][AdminLevel] >= 5)
        {
            SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /createhouse [usage]");
            SendClientMessage(playerid, COLOR_GREY, "Usage: Interior, Exterior or Complete.");
        }
    }
    else
    {
        if(PlayerData[playerid][AdminLevel] >= 5)
        {
            if(strcmp(Usage, "exterior", true) == 0)
            {
                PlayerStats[playerid][HouseExterior]++;
                PlayerStats[playerid][hExtID] = GetPlayerInterior(playerid);
                GetPlayerPos(playerid, PlayerStats[playerid][hExtX], PlayerStats[playerid][hExtY], PlayerStats[playerid][hExtZ]);
                format(string, sizeof(string), "Exterior set! (X: %f, Y: %f, Z: %f).", PlayerStats[playerid][hExtX], PlayerStats[playerid][hExtY], PlayerStats[playerid][hExtZ]);
                SendClientMessage(playerid, COLOR_WHITE, string);
                print("Exterior");
            }
            if(strcmp(Usage, "interior", true) == 0)
            {
                PlayerStats[playerid][HouseInterior]++;
                PlayerStats[playerid][hIntID] = GetPlayerInterior(playerid);
                GetPlayerPos(playerid, PlayerStats[playerid][hIntX], PlayerStats[playerid][hIntY], PlayerStats[playerid][hIntZ]);
                format(string, sizeof(string), "Interior set! (X: %f, Y: %f, Z: %f).", PlayerStats[playerid][hIntX], PlayerStats[playerid][hIntY], PlayerStats[playerid][hIntZ]);
                SendClientMessage(playerid, COLOR_WHITE, string);
                print("Interior");
            }
            if(strcmp(Usage, "complete", true) == 0)
            {
                if(PlayerStats[playerid][HouseInterior] > 0 || PlayerStats[playerid][HouseExterior] > 0)
                {
                    new NewHouseID = SpawnedHouses+1;

                    if(NewHouseID >= MAX_HOUSES)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "Too many houses are currently spawned!");
                    }
                        else
                 {
                        format(string, sizeof(string), "Houses/House_%d.ini", NewHouseID);

                        if(!fexist(string))
                        {
                            HouseData[NewHouseID][hInteriorID] = PlayerStats[playerid][hIntID];
                            HouseData[NewHouseID][hExteriorID] = PlayerStats[playerid][hExtID];
                            HouseData[NewHouseID][hInteriorX] = PlayerStats[playerid][hIntX];
                            HouseData[NewHouseID][hInteriorY] = PlayerStats[playerid][hIntY];
                            HouseData[NewHouseID][hInteriorZ] = PlayerStats[playerid][hIntZ];
                            HouseData[NewHouseID][hExteriorX] = PlayerStats[playerid][hExtX];
                            HouseData[NewHouseID][hExteriorY] = PlayerStats[playerid][hExtY];
                            HouseData[NewHouseID][hExteriorZ] = PlayerStats[playerid][hExtZ];
                            format(HouseData[NewHouseID][hOwner], 255, "Nobody");
                            HouseData[NewHouseID][LockStatus] = 0;
                            HouseData[NewHouseID][HPickupID] = CreateDynamicPickup(1273, 23, HouseData[NewHouseID][hExteriorX], HouseData[NewHouseID][hExteriorY], HouseData[NewHouseID][hExteriorZ], 0, -1, -1, 150.0);

                            new INI:File = INI_Open(HousePath(playerid));
                            INI_SetTag(File,"HouseData");
                            INI_WriteInt(File,"InteriorID", HouseData[NewHouseID][hInteriorID]);
                            INI_WriteFloat(File,"InteriorX", HouseData[NewHouseID][hInteriorX]);
                            INI_WriteFloat(File,"InteriorY", HouseData[NewHouseID][hInteriorY]);
                            INI_WriteFloat(File,"InteriorZ", HouseData[NewHouseID][hInteriorZ]);

                            INI_WriteInt(File,"HousePrice", 0);

                            INI_WriteInt(File,"ExteriorID", 0);
                            INI_WriteFloat(File,"ExteriorX", HouseData[NewHouseID][hExteriorX]);
                            INI_WriteFloat(File,"ExteriorY", HouseData[NewHouseID][hExteriorY]);
                            INI_WriteFloat(File,"ExteriorZ", HouseData[NewHouseID][hExteriorZ]);

                            INI_WriteInt(File,"VaultMoney", -1);

                            INI_WriteInt(File,"HouseCocaine", -1);
                            INI_WriteInt(File,"HousePot", -1);
                            INI_WriteInt(File,"HouseMaterials", -1);

                            INI_WriteString(File,"Owner", "Nobody");

                            INI_WriteInt(File,"LockStatus", HouseData[NewHouseID][LockStatus]);

                            INI_WriteInt(File,"WeaponSlot1", HouseData[NewHouseID][WeaponSlot1]);
                            INI_WriteInt(File,"WeaponSlot2", HouseData[NewHouseID][WeaponSlot2]);
                            INI_WriteInt(File,"WeaponSlot3", HouseData[NewHouseID][WeaponSlot3]);
                            print("Written File");

                            PlayerStats[playerid][HouseExterior]--;
                            PlayerStats[playerid][HouseInterior]--;

                            SpawnedHouses++;
                            SendClientMessage(playerid, COLOR_GREEN, "Successfully created house!");
                            SetPlayerInterior(playerid, HouseData[NewHouseID][hExteriorID]);
                            SetPlayerPos(playerid, HouseData[NewHouseID][hExteriorX], HouseData[NewHouseID][hExteriorY], HouseData[NewHouseID][hExteriorZ]);
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "Error: File already exists!");
                        }
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_WHITE, "You must select an exterior and an interior first!");
                }
            }
        }
    }
    return 1;
}

Thank You


Please Help Me Please
Reply


Messages In This Thread
House System Not Writing File - by Scripter12345 - 20.05.2012, 22:18
Re: House System Not Writing File - by Scripter12345 - 21.05.2012, 07:57

Forum Jump:


Users browsing this thread: 1 Guest(s)