House Sistem

Započeo DuxMaster, Februar 18, 2024, 15:57:58 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Pitanje/savjet: Kako da riješim problem vezano za house sistem, radim mod od 0, i imam problem prilikom pravljenja kuće.
Opširnije: Igrač kada kupi kuću i proda je državi i kupi novu te samim time prilikom izlaska iz kuće vrati ga ne prethodnu kuću koju je kupio, a drugi problem koji mi se javlja jeste da kada ugasim server te ponovo ga pokrenem i uđem u kuću baci mi negdje na kraj mape i ne očitava mi enterijer, jednostavno propadam kroz mapu.
Dodatno: Sistem iz skripte:
[pawn]enum hInfo
{
   hVlasnik[128],
   hOwned,
   hCijena,
   hLevel,
   hRent,
   hCijenaRenta,
   hNeaktivnost,
   hTip,
   hVW,
   hInt,
   Float:hX,
   Float:hY,
   Float:hZ,
   Float:hIzlazX,
   Float:hIzlazY,
   Float:hIzlazZ,
   Float:hAngle,
   hSef,
   hNovac,
   hZakljucana
};[/pawn]

Izlazak i ulazak u kuću
[pawn]      for(new i; i < MAX_HOUSES; i++)
      {
         if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ]))
         {
             if(PlayerInfo[playerid][pKuca] == i || HouseInfo[hZakljucana] == 0)
                {
               new idhouse,fhouse[80];
                 if(HouseInfo[hTip] == 1)
                {
                   SetPlayerPos(playerid, 223.0732,288.3668,1082.1406);
                   SetPlayerInterior(playerid, 1);
                   InteriorTimer(playerid);
                }
                    SetPlayerVirtualWorld(playerid, HouseInfo[hVW]);
                    SetPlayerInterior(playerid, HouseInfo[hInt]);
                    SetPlayerPos(playerid, HouseInfo[hIzlazX], HouseInfo[hIzlazY], HouseInfo[hIzlazZ]);
               InteriorTimer(playerid);
                    format(fhouse, sizeof(fhouse), HOUSEPATH, idhouse);
                    }
                else
                {
                    GameTextForPlayer(playerid,"~w~Kuca ~r~zakljucana ~w~- /zvoni",5000,3);
                    return 1;
                }
         }
            if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hIzlazX], HouseInfo[hIzlazY], HouseInfo[hIzlazZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[hVW])
           {
            if(HouseInfo[hTip] == 1)
            {
            SetPlayerPos(playerid, 223.0732,288.3668,1082.1406);
            SetPlayerInterior(playerid, 1);
             InteriorTimer(playerid);
            }
                SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0);
                SetPlayerPos(playerid, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ]);
            InteriorTimer(playerid);
                return 1;
          }
      }
   }[/pawn]
SAVE
[pawn]stock SaveHouse(id)
{
   new h_file[64];
   format(h_file, sizeof(h_file), HOUSEPATH, id);
   new INI:File = INI_Open(h_file);
   INI_WriteString(File, "Vlasnik", HouseInfo[id][hVlasnik]);
   INI_WriteInt(File, "Owned", HouseInfo[id][hOwned]);
   INI_WriteInt(File, "Cijena", HouseInfo[id][hCijena]);
   INI_WriteInt(File, "Level", HouseInfo[id][hLevel]);
   INI_WriteInt(File, "Int", HouseInfo[id][hInt]);
   INI_WriteInt(File, "Rent", HouseInfo[id][hRent]);
   INI_WriteInt(File, "CijenaRenta", HouseInfo[id][hCijenaRenta]);
   INI_WriteInt(File, "Neaktivnost", HouseInfo[id][hNeaktivnost]);
   INI_WriteInt(File, "VirtualWorld", HouseInfo[id][hVW]);
   INI_WriteInt(File, "Tip", HouseInfo[id][hTip]);
   INI_WriteFloat(File, "X", HouseInfo[id][hX]);
   INI_WriteFloat(File, "Y", HouseInfo[id][hY]);
   INI_WriteFloat(File, "Z", HouseInfo[id][hZ]);
   INI_WriteFloat(File, "hIzlazX", HouseInfo[id][hIzlazX]);
   INI_WriteFloat(File, "hIzlazY", HouseInfo[id][hIzlazY]);
   INI_WriteFloat(File, "hIzlazZ", HouseInfo[id][hIzlazZ]);
   INI_WriteFloat(File, "Angle", HouseInfo[id][hAngle]);
   INI_WriteInt(File, "Sef", HouseInfo[id][hSef]);
   INI_WriteInt(File, "Novac", HouseInfo[id][hNovac]);
   INI_WriteInt(File, "Zakljucana", HouseInfo[id][hZakljucana]);
   INI_Close(File);
}[/pawn]

Load sistem

[pawn]   for(new i = 0; i < MAX_HOUSES; i++)
   {
       new hfile[64];
       format(hfile, sizeof(hfile), HOUSEPATH, i);
       if(fexist(hfile))
       {
           INI_ParseFile(hfile, "LoadHouses", .bExtra = true, .extra = i);
           new str[32];
         if(HouseInfo[hTip] == 1) { format(str, sizeof(str), "Mala Kuca"); }
         if(HouseInfo[hTip] == 2) { format(str, sizeof(str), "Srednja Kuca"); }
         if(HouseInfo[hTip] == 3) { format(str, sizeof(str), "Velika Kuca"); }
         if(HouseInfo[hTip] == 4) { format(str, sizeof(str), "Vila"); }
         if(HouseInfo[hOwned] == 0)
         {
             new string[512];
             format(string, sizeof(string), "{4682B4}Kuca na prodaju\nVlasnik: {FFFFFF}Niko\n{4682B4}Cijena: {FFFFFF}%d\n{4682B4}Level: {FFFFFF}%d\n{4682B4}Tip: {FFFFFF}%s\n{4682B4}Adresa: {FFFFFF}%d\n{4682B4}/kupikucu", HouseInfo[hCijena], HouseInfo[hLevel], str, i);
             hPickup = CreatePickup(1273, 1, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ]);
             SetPos(hPickup, HouseInfo[hIzlazX], HouseInfo[hIzlazY], HouseInfo[hIzlazZ]);
             hLabel = Create3DTextLabel(string, COLOR_WHITE, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ], 10.0, 0, 0);
         }
         else
         {
             new string[512];
             format(string, sizeof(string), "{4682B4}Kuca na prodaju\nVlasnik: {FFFFFF}%s\n{4682B4}Cijena: {FFFFFF}%d\n{4682B4}Level: {FFFFFF}%d\n{4682B4}Tip: {FFFFFF}%s\n{4682B4}Adresa: {FFFFFF}%d", HouseInfo[hVlasnik], HouseInfo[hCijena], HouseInfo[hLevel], str, i);
             hPickup = CreatePickup(1272, 1, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ]);
             SetPos(hPickup, HouseInfo[hIzlazX], HouseInfo[hIzlazY], HouseInfo[hIzlazZ]);
             hLabel = Create3DTextLabel(string, COLOR_WHITE, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ], 10.0, 0, 0);
         }
       }
   }
   print("Ucitan house sistem");[/pawn]

OnGamemodeExit
[pawn]   for(new i = 0; i < MAX_HOUSES; i++)
   {
       SaveHouse(i);
   }[/pawn]
Jedina prava mudrost je
znati da ne znate ništa.



Citat: DuxMaster poslato Februar 18, 2024, 15:57:58 POSLE PODNE
Pitanje/savjet: Kako da riješim problem vezano za house sistem, radim mod od 0, i imam problem prilikom pravljenja kuće.
Opširnije: Igrač kada kupi kuću i proda je državi i kupi novu te samim time prilikom izlaska iz kuće vrati ga ne prethodnu kuću koju je kupio, a drugi problem koji mi se javlja jeste da kada ugasim server te ponovo ga pokrenem i uđem u kuću baci mi negdje na kraj mape i ne očitava mi enterijer, jednostavno propadam kroz mapu.
Dodatno: Sistem iz skripte:
[pawn]enum hInfo
{
   hVlasnik[128],
   hOwned,
   hCijena,
   hLevel,
   hRent,
   hCijenaRenta,
   hNeaktivnost,
   hTip,
   hVW,
   hInt,
   Float:hX,
   Float:hY,
   Float:hZ,
   Float:hIzlazX,
   Float:hIzlazY,
   Float:hIzlazZ,
   Float:hAngle,
   hSef,
   hNovac,
   hZakljucana
};[/pawn]

Izlazak i ulazak u kuću
[pawn]      for(new i; i < MAX_HOUSES; i++)
      {
         if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ]))
         {
             if(PlayerInfo[playerid][pKuca] == i || HouseInfo[hZakljucana] == 0)
                {
               new idhouse,fhouse[80];
                 if(HouseInfo[hTip] == 1)
                {
                   SetPlayerPos(playerid, 223.0732,288.3668,1082.1406);
                   SetPlayerInterior(playerid, 1);
                   InteriorTimer(playerid);
                }
                    SetPlayerVirtualWorld(playerid, HouseInfo[hVW]);
                    SetPlayerInterior(playerid, HouseInfo[hInt]);
                    SetPlayerPos(playerid, HouseInfo[hIzlazX], HouseInfo[hIzlazY], HouseInfo[hIzlazZ]);
               InteriorTimer(playerid);
                    format(fhouse, sizeof(fhouse), HOUSEPATH, idhouse);
                    }
                else
                {
                    GameTextForPlayer(playerid,"~w~Kuca ~r~zakljucana ~w~- /zvoni",5000,3);
                    return 1;
                }
         }
            if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hIzlazX], HouseInfo[hIzlazY], HouseInfo[hIzlazZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[hVW])
           {
            if(HouseInfo[hTip] == 1)
            {
            SetPlayerPos(playerid, 223.0732,288.3668,1082.1406);
            SetPlayerInterior(playerid, 1);
             InteriorTimer(playerid);
            }
                SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0);
                SetPlayerPos(playerid, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ]);
            InteriorTimer(playerid);
                return 1;
          }
      }
   }[/pawn]
SAVE
[pawn]stock SaveHouse(id)
{
   new h_file[64];
   format(h_file, sizeof(h_file), HOUSEPATH, id);
   new INI:File = INI_Open(h_file);
   INI_WriteString(File, "Vlasnik", HouseInfo[id][hVlasnik]);
   INI_WriteInt(File, "Owned", HouseInfo[id][hOwned]);
   INI_WriteInt(File, "Cijena", HouseInfo[id][hCijena]);
   INI_WriteInt(File, "Level", HouseInfo[id][hLevel]);
   INI_WriteInt(File, "Int", HouseInfo[id][hInt]);
   INI_WriteInt(File, "Rent", HouseInfo[id][hRent]);
   INI_WriteInt(File, "CijenaRenta", HouseInfo[id][hCijenaRenta]);
   INI_WriteInt(File, "Neaktivnost", HouseInfo[id][hNeaktivnost]);
   INI_WriteInt(File, "VirtualWorld", HouseInfo[id][hVW]);
   INI_WriteInt(File, "Tip", HouseInfo[id][hTip]);
   INI_WriteFloat(File, "X", HouseInfo[id][hX]);
   INI_WriteFloat(File, "Y", HouseInfo[id][hY]);
   INI_WriteFloat(File, "Z", HouseInfo[id][hZ]);
   INI_WriteFloat(File, "hIzlazX", HouseInfo[id][hIzlazX]);
   INI_WriteFloat(File, "hIzlazY", HouseInfo[id][hIzlazY]);
   INI_WriteFloat(File, "hIzlazZ", HouseInfo[id][hIzlazZ]);
   INI_WriteFloat(File, "Angle", HouseInfo[id][hAngle]);
   INI_WriteInt(File, "Sef", HouseInfo[id][hSef]);
   INI_WriteInt(File, "Novac", HouseInfo[id][hNovac]);
   INI_WriteInt(File, "Zakljucana", HouseInfo[id][hZakljucana]);
   INI_Close(File);
}[/pawn]

Load sistem

[pawn]   for(new i = 0; i < MAX_HOUSES; i++)
   {
       new hfile[64];
       format(hfile, sizeof(hfile), HOUSEPATH, i);
       if(fexist(hfile))
       {
           INI_ParseFile(hfile, "LoadHouses", .bExtra = true, .extra = i);
           new str[32];
         if(HouseInfo[hTip] == 1) { format(str, sizeof(str), "Mala Kuca"); }
         if(HouseInfo[hTip] == 2) { format(str, sizeof(str), "Srednja Kuca"); }
         if(HouseInfo[hTip] == 3) { format(str, sizeof(str), "Velika Kuca"); }
         if(HouseInfo[hTip] == 4) { format(str, sizeof(str), "Vila"); }
         if(HouseInfo[hOwned] == 0)
         {
             new string[512];
             format(string, sizeof(string), "{4682B4}Kuca na prodaju\nVlasnik: {FFFFFF}Niko\n{4682B4}Cijena: {FFFFFF}%d\n{4682B4}Level: {FFFFFF}%d\n{4682B4}Tip: {FFFFFF}%s\n{4682B4}Adresa: {FFFFFF}%d\n{4682B4}/kupikucu", HouseInfo[hCijena], HouseInfo[hLevel], str, i);
             hPickup = CreatePickup(1273, 1, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ]);
             SetPos(hPickup, HouseInfo[hIzlazX], HouseInfo[hIzlazY], HouseInfo[hIzlazZ]);
             hLabel = Create3DTextLabel(string, COLOR_WHITE, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ], 10.0, 0, 0);
         }
         else
         {
             new string[512];
             format(string, sizeof(string), "{4682B4}Kuca na prodaju\nVlasnik: {FFFFFF}%s\n{4682B4}Cijena: {FFFFFF}%d\n{4682B4}Level: {FFFFFF}%d\n{4682B4}Tip: {FFFFFF}%s\n{4682B4}Adresa: {FFFFFF}%d", HouseInfo[hVlasnik], HouseInfo[hCijena], HouseInfo[hLevel], str, i);
             hPickup = CreatePickup(1272, 1, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ]);
             SetPos(hPickup, HouseInfo[hIzlazX], HouseInfo[hIzlazY], HouseInfo[hIzlazZ]);
             hLabel = Create3DTextLabel(string, COLOR_WHITE, HouseInfo[hX], HouseInfo[hY], HouseInfo[hZ], 10.0, 0, 0);
         }
       }
   }
   print("Ucitan house sistem");[/pawn]

OnGamemodeExit
[pawn]   for(new i = 0; i < MAX_HOUSES; i++)
   {
       SaveHouse(i);
   }[/pawn]
Poslat cu ti PP discord, mozes se slobodno sad javit


forward LoadHouses(id, name[], value[]);
public LoadHouses(id, name[], value[])
{
   INI_String("Vlasnik", HouseInfo[id][hVlasnik], 128);
   INI_Int("Owned", HouseInfo[id][hOwned]);
   INI_Int("Cijena", HouseInfo[id][hCijena]);
   INI_Int("Level", HouseInfo[id][hLevel]);
   INI_Int("Rent", HouseInfo[id][hRent]);
    INI_Int("CijenaRenta", HouseInfo[id][hCijenaRenta]);
   INI_Int("Neaktivnost", HouseInfo[id][hNeaktivnost]);
   INI_Int("Tip", HouseInfo[id][hTip]);
   INI_Int("VirtualWorld", HouseInfo[id][hVW]);
   INI_Int("Int", HouseInfo[id][hInt]);
   INI_Float("X", HouseInfo[id][hX]);
   INI_Float("Y", HouseInfo[id][hY]);
   INI_Float("Z", HouseInfo[id][hZ]);
   INI_Float("IzlazX", HouseInfo[id][hIzlazX]);
   INI_Float("IzlazY", HouseInfo[id][hIzlazY]);
   INI_Float("IzlazZ", HouseInfo[id][hIzlazZ]);
   INI_Float("Angle", HouseInfo[id][hAngle]);
   INI_Int("Sef", HouseInfo[id][hSef]);
   INI_Int("Novac", HouseInfo[id][hNovac]);
   INI_Int("Zakljucana", HouseInfo[id][hZakljucana]);
   return true;
}
Jedina prava mudrost je
znati da ne znate ništa.



Riješeno je, lock.
Jedina prava mudrost je
znati da ne znate ništa.