Szerző Téma: Házrendszer  (Megtekintve 1345 alkalommal)

Házrendszer
« Dátum: 2013. március 24. - 09:27:31 »
0 Show voters
Sziasztok! Egy kis problémám van a PPC házrendszerrel, amit az angol fórumról töltöttem le mint egy külön scritpet vagyis nem a kamionos modban van, remélem eddig érthetõ voltam :D. Szóval azvan, hogy lementi a házakat a Houses mappába de mikor restartolom a szervert nem tölti be a házakat...:( valakinek van valami ötlete?

Házrendszer
« Válasz #1 Dátum: 2013. március 24. - 09:34:01 »
+1 Show voters
Ugye PPC_Trucking gamemoden belül minden mentés a PPC_FileOperationsba van.Szóval nézd át, hogy nincs-e hiba a betöltésben vagy másold ki a ppcbõl a ház lementést és a ház betöltést.

Házrendszer
« Válasz #2 Dátum: 2013. március 24. - 09:42:19 »
0 Show voters
Mentés:



HouseFile_Save(HouseID)
{
new file[100], File:HFile, LineForFile[100], vid;
    // Construct the complete filename for this house
format(file, sizeof(file), HouseFile, HouseID);
    // Open the housefile for writing
HFile = fopen(file, io_write);
if (AHouseData[HouseID][Owned] == true) // Check if the house is owned
   format(LineForFile, 100, \"Owned Yes\\r\\n\"); // Construct the line: \"Owned Yes\"
else
   format(LineForFile, 100, \"Owned No\\r\\n\"); // Construct the line: \"Owned No\"
fwrite(HFile, LineForFile); // And save it to the file
format(LineForFile, 100, \"Owner %s\\r\\n\", AHouseData[HouseID][Owner]); // Construct the line: \"Owner <Owner>\"
fwrite(HFile, LineForFile); // And save it to the file
format(LineForFile, 100, \"HouseName %s\\r\\n\", AHouseData[HouseID][HouseName]); // Construct the line: \"HouseName <HouseName>\"
fwrite(HFile, LineForFile); // And save it to the file
format(LineForFile, 100, \"HouseX %f\\r\\n\", AHouseData[HouseID][HouseX]); // Construct the line: \"HouseX <HouseX>\"
fwrite(HFile, LineForFile); // And save it to the file
format(LineForFile, 100, \"HouseY %f\\r\\n\", AHouseData[HouseID][HouseY]); // Construct the line: \"HouseY <HouseY>\"
fwrite(HFile, LineForFile); // And save it to the file
format(LineForFile, 100, \"HouseZ %f\\r\\n\", AHouseData[HouseID][HouseZ]); // Construct the line: \"HouseZ <HouseZ>\"
fwrite(HFile, LineForFile); // And save it to the file
format(LineForFile, 100, \"HouseLevel %i\\r\\n\", AHouseData[HouseID][HouseLevel]); // Construct the line: \"HouseLevel <HouseLevel>\"
fwrite(HFile, LineForFile); // And save it to the file
format(LineForFile, 100, \"HouseMaxLevel %i\\r\\n\", AHouseData[HouseID][HouseMaxLevel]); // Construct the line: \"HouseMaxLevel <HouseMaxLevel>\"
fwrite(HFile, LineForFile); // And save it to the file
format(LineForFile, 100, \"HousePrice %i\\r\\n\", AHouseData[HouseID][HousePrice]); // Construct the line: \"HousePrice <HousePrice>\"
fwrite(HFile, LineForFile); // And save it to the file
if (AHouseData[HouseID][HouseOpened] == true) // Check if the house is open to the public
   format(LineForFile, 100, \"HouseOpened Yes\\r\\n\"); // Construct the line: \"HouseOpened Yes\"
else
   format(LineForFile, 100, \"HouseOpened No\\r\\n\"); // Construct the line: \"HouseOpened No\"
fwrite(HFile, LineForFile); // And save it to the file
if (AHouseData[HouseID][insurance] == true) // Check if the house has insurance for it\'s vehicles
   format(LineForFile, 100, \"Insurance Yes\\r\\n\"); // Construct the line: \"Insurance Yes\"
else
   format(LineForFile, 100, \"Insurance No\\r\\n\"); // Construct the line: \"Insurance No\"
fwrite(HFile, LineForFile); // And save it to the file
if (AHouseData[HouseID][staticHouse] == true) // Check if the house is a static house
   format(LineForFile, 100, \"StaticHouse Yes\\r\\n\"); // Construct the line: \"StaticHouse Yes\"
else
   format(LineForFile, 100, \"StaticHouse No\\r\\n\"); // Construct the line: \"StaticHouse No\"
fwrite(HFile, LineForFile); // And save it to the file
format(LineForFile, 100, \"CarSlots %i\\r\\n\", AHouseData[HouseID][CarSlots]); // Construct the line: \"CarSlots <CarSlots>\"
fwrite(HFile, LineForFile); // And save it to the file
fwrite(HFile, \"\\r\\n\"); // Add an empty line, just for readability
// Save the vehicle-data for every vehicle added to the house
for (new CarSlot; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
{
    // If a valid vehicle-id has been found
   if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
   {
      // Get the vehicle id
      vid = AHouseData[HouseID][VehicleIDs][CarSlot];
       format(LineForFile, 100, \"[Vehicle]\\r\\n\"); // Construct the line: \"[Vehicle]\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleModel %i\\r\\n\", AVehicleData[vid][Model]); // Construct the line: \"VehicleModel <VehicleModel>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehiclePaintJob %i\\r\\n\", AVehicleData[vid][PaintJob]); // Construct the line: \"VehiclePaintJob <VehiclePaintJob>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleSpoiler %i\\r\\n\", AVehicleData[vid][Components][0]); // Construct the line: \"VehicleSpoiler <VehicleSpoiler>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleHood %i\\r\\n\", AVehicleData[vid][Components][1]); // Construct the line: \"VehicleHood <VehicleHood>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleRoof %i\\r\\n\", AVehicleData[vid][Components][2]); // Construct the line: \"VehicleRoof <VehicleRoof>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleSideSkirt %i\\r\\n\", AVehicleData[vid][Components][3]); // Construct the line: \"VehicleSideSkirt <VehicleSideSkirt>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleLamps %i\\r\\n\", AVehicleData[vid][Components][4]); // Construct the line: \"VehicleLamps <VehicleLamps>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleNitro %i\\r\\n\", AVehicleData[vid][Components][5]); // Construct the line: \"VehicleNitro <VehicleNitro>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleExhaust %i\\r\\n\", AVehicleData[vid][Components][6]); // Construct the line: \"VehicleSpoiler <VehicleSpoiler>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleWheels %i\\r\\n\", AVehicleData[vid][Components][7]); // Construct the line: \"VehicleWheels <VehicleWheels>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleStereo %i\\r\\n\", AVehicleData[vid][Components][8]); // Construct the line: \"VehicleStereo <VehicleStereo>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleHydraulics %i\\r\\n\", AVehicleData[vid][Components][9]); // Construct the line: \"VehicleHydraulics <VehicleHydraulics>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleFrontBumper %i\\r\\n\", AVehicleData[vid][Components][10]); // Construct the line: \"VehicleFrontBumper <VehicleFrontBumper>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleRearBumper %i\\r\\n\", AVehicleData[vid][Components][11]); // Construct the line: \"VehicleRearBumper <VehicleRearBumper>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleVentRight %i\\r\\n\", AVehicleData[vid][Components][12]); // Construct the line: \"VehicleVentRight <VehicleVentRight>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleVentLeft %i\\r\\n\", AVehicleData[vid][Components][13]); // Construct the line: \"VehicleVentLeft <VehicleVentLeft>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"Color1 %i\\r\\n\", AVehicleData[vid][Color1]); // Construct the line: \"Color1 <Color1>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"Color2 %i\\r\\n\", AVehicleData[vid][Color2]); // Construct the line: \"Color2 <Color2>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleX %f\\r\\n\", AVehicleData[vid][spawnX]); // Construct the line: \"VehicleVentLeft <VehicleVentLeft>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleY %f\\r\\n\", AVehicleData[vid][spawnY]); // Construct the line: \"VehicleVentLeft <VehicleVentLeft>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleZ %f\\r\\n\", AVehicleData[vid][spawnZ]); // Construct the line: \"VehicleVentLeft <VehicleVentLeft>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"VehicleAngle %f\\r\\n\", AVehicleData[vid][spawnRot]); // Construct the line: \"VehicleVentLeft <VehicleVentLeft>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"Fuel %i\\r\\n\", INT_GetVehicleFuel(vid)); // Construct the line: \"Fuel <Fuel>\"
      fwrite(HFile, LineForFile); // And save it to the file
       format(LineForFile, 100, \"[/Vehicle]\\r\\n\"); // Construct the line: \"[/Vehicle]\"
      fwrite(HFile, LineForFile); // And save it to the file
      fwrite(HFile, \"\\r\\n\"); // Add an empty line, just for readability
   }
}
fclose(HFile); // Close the file
return 1;
}
 
Betöltés:



HouseFile_Load(HouseID)
{
// Setup local variables
new file[100], File:HFile, LineFromFile[100], ParameterName[50], ParameterValue[50];
    // Construct the complete filename for this house-file
format(file, sizeof(file), HouseFile, HouseID);
// Check if the HouseFile exists
if (fexist(file))
{
    // Open the housefile for reading
   HFile = fopen(file, io_read);
        // Read the first line of the file
   fread(HFile, LineFromFile);
   // Keep reading until the end of the file is found (no more data)
   // An empty line between data-segments still has the NewLine characters (\\r\\n) so it\'s not completely empty
   // Reading past the last line will read a completely empty line, therefore indicating the end of the file
   while (strlen(LineFromFile) > 0)
   {
      StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
      sscanf(LineFromFile, \"s[50]s[50]\", ParameterName, ParameterValue); // Extract parametername and parametervalue
      // Check if there is anything in the LineFromFile (skipping empty lines)
      if (strlen(LineFromFile) > 0)
      {
         // Store the proper value in the proper place
         if (strcmp(ParameterName, \"Owned\", false) == 0) // If the parametername is correct (\"Owned\")
         {
             if (strcmp(ParameterValue, \"Yes\", false) == 0) // If the value \"Yes\" was read
               AHouseData[HouseID][Owned] = true; // House is owned
            else
               AHouseData[HouseID][Owned] = false; // House is not owned
         }
         if (strcmp(ParameterName, \"Owner\", false) == 0) // If the parametername is correct (\"Owner\")
            // Store the Owner (Owner will hold \"1\" if there is no owner (empty string), done by \"sscanf\" I guess)
            // But this doesn\'t matter, as the owner will never be displayed when the house is not owned by someone
             format(AHouseData[HouseID][Owner], 24, ParameterValue);
         if (strcmp(ParameterName, \"HouseName\", false) == 0) // If the parametername is correct (\"HouseName\")
             format(AHouseData[HouseID][HouseName], 24, ParameterValue); // Store the HouseName
         if (strcmp(ParameterName, \"HouseX\", false) == 0) // If the parametername is correct (\"HouseX\")
            AHouseData[HouseID][HouseX] = floatstr(ParameterValue); // Store the HouseX
         if (strcmp(ParameterName, \"HouseY\", false) == 0) // If the parametername is correct (\"HouseY\")
            AHouseData[HouseID][HouseY] = floatstr(ParameterValue); // Store the HouseY
         if (strcmp(ParameterName, \"HouseZ\", false) == 0) // If the parametername is correct (\"HouseZ\")
            AHouseData[HouseID][HouseZ] = floatstr(ParameterValue); // Store the HouseZ
         if (strcmp(ParameterName, \"HouseLevel\", false) == 0) // If the parametername is correct (\"HouseLevel\")
            AHouseData[HouseID][HouseLevel] = strval(ParameterValue); // Store the HouseLevel
         if (strcmp(ParameterName, \"HouseMaxLevel\", false) == 0) // If the parametername is correct (\"HouseMaxLevel\")
            AHouseData[HouseID][HouseMaxLevel] = strval(ParameterValue); // Store the HouseMaxLevel
         if (strcmp(ParameterName, \"HousePrice\", false) == 0) // If the parametername is correct (\"HousePrice\")
            AHouseData[HouseID][HousePrice] = strval(ParameterValue); // Store the HousePrice
         if (strcmp(ParameterName, \"HouseOpened\", false) == 0) // If the parametername is correct (\"HouseOpened\")
         {
             if (strcmp(ParameterValue, \"Yes\", false) == 0) // If the value \"Yes\" was read
               AHouseData[HouseID][HouseOpened] = true; // House is open to the public (anyone can enter)
            else
               AHouseData[HouseID][HouseOpened] = false; // House is closed to the public, only house-owner can enter
         }
         if (strcmp(ParameterName, \"Insurance\", false) == 0) // If the parametername is correct (\"Insurance\")
         {
             if (strcmp(ParameterValue, \"Yes\", false) == 0) // If the value \"Yes\" was read
               AHouseData[HouseID][insurance] = true; // House has insurance for it\'s vehicles
            else
               AHouseData[HouseID][insurance] = false; // House doesn\'t have insurance
         }
         if (strcmp(ParameterName, \"StaticHouse\", false) == 0) // If the parametername is correct (\"StaticHouse\")
         {
             if (strcmp(ParameterValue, \"Yes\", false) == 0) // If the value \"Yes\" was read
               AHouseData[HouseID][staticHouse] = true; // House is static (not upgradable, fixed interior and carslots)
            else
               AHouseData[HouseID][staticHouse] = false; // House isn\'t static (upgradable, interior and carslots based on HouseLevel)
         }
         if (strcmp(ParameterName, \"CarSlots\", false) == 0) // If the parametername is correct (\"CarSlots\")
            AHouseData[HouseID][CarSlots] = strval(ParameterValue); // Store the CarSlots
      }
            // Read the next line of the file
      fread(HFile, LineFromFile);
   }
        // Close the file
   fclose(HFile);
   // Add a pickup and 3DText for this house
   House_UpdateEntrance(HouseID);
   // Count the amount of houses that are loaded
    TotalHouses++;
        // Return if the file was read correctly
   return 1;
}
else
    return 0; // Return 0 if the file couldn\'t be read (doesn\'t exist)
}

Nem elérhető ZyZu.

  • Globális moderátor
  • 8939
  • my turbo diesel forum
  • Discord: ZyZu.
    • Profil megtekintése
Házrendszer
« Válasz #3 Dátum: 2013. március 24. - 09:53:16 »
0 Show voters
Milyen mappában mented le ezeket? Mert lehet nem jó nevû mappában mented amiben kéne azért nem tölti be.

Házrendszer
« Válasz #4 Dátum: 2013. március 24. - 09:59:38 »
0 Show voters
Houses mappába és  le is menti, restart után a mappába megmaradnak a házak csak a játékba nem tölti be.... és a farm közepén a föld alatt van pár ház...

Házrendszer
« Válasz #5 Dátum: 2013. március 24. - 10:08:33 »
+1 Show voters
Öööö, ez is benne van?
 
// This function loads all houses
Housing_LoadAll()
{
// Loop through all houses and try to load them
for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
{
    // Try to load the file and check if it was succesfully loaded (file exists)
if (HouseFile_Load(HouseID) == 1)
{
   // Add a pickup and 3DText for this house
   House_CreateEntrance(HouseID);
   // Count the amount of houses that are loaded
    TotalHouses++;
}
}
return 1;
}

Házrendszer
« Válasz #6 Dátum: 2013. március 24. - 10:21:51 »
0 Show voters
nincs benne, rakjam bele?

Házrendszer
« Válasz #7 Dátum: 2013. március 24. - 10:27:00 »
+1 Show voters
Hát próbáld meg, mivel ez is a ház betöltéshez tartozik.

Házrendszer
« Válasz #8 Dátum: 2013. március 24. - 10:48:15 »
0 Show voters

Házrendszer
« Válasz #9 Dátum: 2013. március 24. - 10:55:32 »
+1 Show voters
Ahova menti a házakat abba a mappába, ott mind az összes háznak 1 a koordinátája vagy különbözõ?

Házrendszer
« Válasz #10 Dátum: 2013. március 24. - 11:00:31 »
0 Show voters
különbözõ...

Házrendszer
« Válasz #11 Dátum: 2013. március 24. - 11:38:12 »
0 Show voters
Ha gondolod el küldheted pmbe és megnézem neked.

Házrendszer
« Válasz #12 Dátum: 2013. március 24. - 15:53:59 »
0 Show voters
sikerült megoldanom, köszönöm a segítéget :D ++

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal