House system help -
NoDi522 - 16.05.2015
Hello guys.
So i made my house system and everything works fine but.. (there is always but >.<)
The problem is in the 3D texts and saving...
Here is my /makehouse command:
PHP код:
CMD:napravikucu(playerid,params[])
{
new Cijena, tip, SefMoney, ID,string[128], GetInterijer, svijet, Float:XInterior, Float:YInterior, Float:ZInterior, Interijer;
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Niste ulogirani na server");
if(PlayerInfo[playerid][pAdministrator] < 5) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Nemate dozvolu za tu komandu");
if(sscanf(params,"ddddfff",Cijena,tip,Interijer,SefMoney,XInterior,YInterior,ZInterior)) return SendClientMessage(playerid,-1,"Koristenje: {FFF1AF}/napravikucu [Cijena] [TIP] [Interijer] [Novac(sef)] [InteriorX] [InteriorY] [InteriorZ]");
if(Cijena < 100000 || Cijena > 1000000) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Odaberite cijenu: [$100.000-$100.000.00]");
if(tip < 0 || tip > 2) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Odaberite TIP: 0-2");
if(SefMoney < 0 || SefMoney > 150000) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Odaberite novac u sefu: $0 - $150.000");
{
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,A);
GetInterijer = GetPlayerInterior(playerid);
svijet = GetPlayerVirtualWorld(playerid);
for(new houseid = 1; houseid < MAX_KUCA; houseid++)
{
if(HouseInfo[houseid][hCijena] == 0)
{
ID = houseid;
break;
}
}
/* Proredak */
HouseInfo[ID][hUnutrasnjiInterijer] = Interijer;
HouseInfo[ID][hIzlazX] = XInterior;
HouseInfo[ID][hIzlazY] = YInterior;
HouseInfo[ID][hIzlazY] = ZInterior;
HouseInfo[ID][hOwned] = 0;
HouseInfo[ID][hCijena] = Cijena;
HouseInfo[ID][hTip] = tip;
HouseInfo[ID][hUlazX] = X;
HouseInfo[ID][hUlazY] = Y;
HouseInfo[ID][hUlazZ] = Z;
HouseInfo[ID][hUlazA] = A;
HouseInfo[ID][hZakljucan] = 1;
HouseInfo[ID][hInterijer] = GetInterijer;
HouseInfo[ID][hSvijet] = svijet;
KucaMapIcon = CreateDynamicMapIcon(X,Y,Z, 31, -1, -1 ,-1, -1, 100);
KucaPickup = CreateDynamicPickup(1273,1, X,Y,Z,-1,-1,-1, 100);
/* Proredak */
format(string, sizeof(string), "Nitko");
strmid(HouseInfo[ID][hVlasnik], string, 0, strlen(string), 255);
/* Proredak - Spremanje */
new hFile[40];
format(hFile,sizeof(hFile),hPATH,ID);
new INI:File = INI_Open(hFile);
{
INI_SetTag(File,"data");
INI_WriteInt(File,"Owned",HouseInfo[ID][hOwned]);
INI_WriteInt(File,"Cijena",HouseInfo[ID][hCijena]);
INI_WriteString(File,"Vlasnik",HouseInfo[ID][hVlasnik]);
INI_WriteInt(File,"Zakljucano",HouseInfo[ID][hZakljucan]);
INI_WriteInt(File,"House_Novac",HouseInfo[ID][hNovac]);
INI_WriteInt(File,"House_Gun",HouseInfo[ID][hGun]);
INI_WriteInt(File,"Tip",HouseInfo[ID][hTip]);
INI_WriteFloat(File,"UlazX",HouseInfo[ID][hUlazX]);
INI_WriteFloat(File,"UlazY",HouseInfo[ID][hUlazY]);
INI_WriteFloat(File,"UlazZ",HouseInfo[ID][hUlazZ]);
INI_WriteFloat(File,"UlazA",HouseInfo[ID][hUlazA]);
new poruka[256];
{
Kuca3D = format(poruka,sizeof(poruka),""COLOR_SIVA"~{FFFFFF} Kuca na prodaju "COLOR_SIVA"~\n{FFFFFF}TIP Kuce: {FFF1AF}%s\n{FFFFFF}Cijena: "COLOR_ZELENA"$%d\n\n{FFFFFF}Ukoliko zelite kupiti kucu: /kupikucu",KucaType(tip),HouseInfo[ID][hCijena]);
Create3DTextLabel(poruka,-1,HouseInfo[ID][hUlazX], HouseInfo[ID][hUlazY], HouseInfo[ID][hUlazZ], 30.0,0,0);
}
INI_WriteFloat(File,"IzlazX",HouseInfo[ID][hIzlazX]);
INI_WriteFloat(File,"IzlazY",HouseInfo[ID][hIzlazY]);
INI_WriteFloat(File,"IzlazZ",HouseInfo[ID][hIzlazZ]);
INI_WriteFloat(File,"IzlazA",HouseInfo[ID][hIzlazA]);
INI_WriteInt(File,"Interijer",HouseInfo[ID][hInterijer]);
INI_WriteInt(File,"Unutrasnji_Interijer",HouseInfo[ID][hUnutrasnjiInterijer]);
INI_WriteInt(File,"Svijet",HouseInfo[ID][hSvijet]);
INI_WriteInt(File,"Ikona",HouseInfo[ID][hIkona]);
INI_Close(File);
}
}
return 1;
}
Here is mine 'house saving'..
PHP код:
public SaveKuca(houseid)
{
new hFile[40];
format(hFile, sizeof(hFile), hPATH, houseid);
new INI:File = INI_Open(hFile);
{
INI_SetTag(File,"data");
INI_WriteInt(File,"Owned",HouseInfo[houseid][hOwned]);
INI_WriteInt(File,"Cijena",HouseInfo[houseid][hCijena]);
INI_WriteString(File,"Vlasnik",HouseInfo[houseid][hVlasnik]);
INI_WriteInt(File,"Zakljucano",HouseInfo[houseid][hZakljucan]);
INI_WriteInt(File,"House_Sef",HouseInfo[houseid][hNovac]);
INI_WriteInt(File,"House_Gun",HouseInfo[houseid][hGun]);
INI_WriteInt(File,"Tip", HouseInfo[houseid][hTip]);
INI_WriteFloat(File,"UlazX",HouseInfo[houseid][hUlazX]);
INI_WriteFloat(File,"UlazY",HouseInfo[houseid][hUlazY]);
INI_WriteFloat(File,"UlazZ",HouseInfo[houseid][hUlazZ]);
INI_WriteFloat(File,"UlazA",HouseInfo[houseid][hUlazA]);
INI_WriteFloat(File,"IzlazX",HouseInfo[houseid][hIzlazX]);
INI_WriteFloat(File,"IzlazY",HouseInfo[houseid][hIzlazY]);
INI_WriteFloat(File,"IzlazZ",HouseInfo[houseid][hIzlazZ]);
INI_WriteFloat(File,"IzlazA",HouseInfo[houseid][hIzlazA]);
INI_WriteInt(File,"Interijer",HouseInfo[houseid][hInterijer]);
INI_WriteInt(File,"UnutarnjiInterijer", HouseInfo[houseid][hUnutrasnjiInterijer]);
INI_WriteInt(File,"Svijet",HouseInfo[houseid][hSvijet]);
INI_WriteInt(File,"Ikona",HouseInfo[houseid][hIkona]);
}
return 1;
}
/buyhouse command:
PHP код:
CMD:kupikucu(playerid, params[])
{
new ID = IsPlayerNearHouse(playerid);
if(ID == -1 || ID == 0) return SendClientMessage(playerid, -1, ""COLOR_CRVENA"Greska:{FFFFFF} Ne nalazite se na mjestu kupovine.");
if(HouseInfo[ID][hOwned] != 0 || HouseInfo[ID][hCijena] == 0) return SendClientMessage(playerid, -1, ""COLOR_CRVENA"Greska:{FFFFFF} Odabrana kuca nije na prodaju.");
if(PlayerInfo[playerid][Kuca] != 0) return SendClientMessage(playerid, -1, ""COLOR_CRVENA"Greska:{FFFFFF} Vec posjedujete jednu kucu.");
if(GetPlayerMoney(playerid) < HouseInfo[ID][hCijena]) return SendClientMessage(playerid, -1, ""COLOR_CRVENA"Greska:{FFFFFF} Nemate dovoljno novca na racunu.");
{
PlayerInfo[playerid][Kuca] = 1;
GivePlayerMoney(playerid, -HouseInfo[ID][hCijena]);
HouseInfo[ID][hZakljucan] = 0;
HouseInfo[ID][hOwned] = 1;
HouseInfo[ID][hVlasnik] = GetName(playerid);
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Postali ste vlasnik kuce.");
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Sve prednosti pregledajte komandom: /kuca");
new poruka[128];
for(new idx = 1; idx < sizeof(BusinessInfo); idx++)
{
KucaPickupOwned = CreateDynamicPickup(19522,1, HouseInfo[idx][hUlazX],HouseInfo[idx][hUlazY],HouseInfo[idx][hUlazZ],-1,-1,-1, 100);
KucaMapIconOwned = CreateDynamicMapIcon(HouseInfo[idx][hUlazX],HouseInfo[idx][hUlazY],HouseInfo[idx][hUlazZ],32,-1,-1,-1,-1,100);
DestroyDynamicMapIcon(KucaMapIcon);
/* Proredak */
Kuca3DOwned = format(poruka,sizeof(poruka),"{FFFFFF}TIP Kuce: %s\nVlasnik: %s\nCijena:"COLOR_ZELENA" $%d{FFFFFF}\n\nPritisnite 'f' ili 'enter' za ulazak.\nIzravan nacin -"COLOR_ZELENA" (/enter)",KucaType(idx),HouseInfo[idx][hVlasnik],HouseInfo[idx][hCijena]);
Create3DTextLabel(poruka,-1,HouseInfo[idx][hUlazX],HouseInfo[idx][hUlazY],HouseInfo[idx][hUlazZ],30,0,0);
}
}
return 1;
}
..ModeInIt:
PHP код:
new poruka[40],poruka2[256];
for(new houseid = 1; houseid < MAX_KUCA; houseid++)
{
format(poruka,sizeof(poruka),hPATH,houseid);
INI_ParseFile(poruka, "LoadKuca_data_%d", .bExtra = true, .extra = houseid);
HouseInfo[houseid][hIkona] = CreateDynamicPickup(1273, 1, HouseInfo[houseid][hUlazX], HouseInfo[houseid][hUlazY], HouseInfo[houseid][hUlazZ], HouseInfo[houseid][hSvijet]);
if(HouseInfo[houseid][hOwned] == 1)
{
KucaPickupOwned = CreateDynamicPickup(19522,1, HouseInfo[houseid][hUlazX],HouseInfo[houseid][hUlazY],HouseInfo[houseid][hUlazZ],-1,-1,-1, 100);
KucaMapIconOwned = CreateDynamicMapIcon(HouseInfo[houseid][hUlazX],HouseInfo[houseid][hUlazY],HouseInfo[houseid][hUlazZ],32,-1,-1,-1,-1,100);
Kuca3DOwned = format(poruka2,sizeof(poruka2),"{FFFFFF}TIP Kuce: %s\nVlasnik: %s\nCijena:"COLOR_ZELENA" $%d{FFFFFF}\n\nPritisnite 'f' ili 'enter' za ulazak.\nIzravan nacin -"COLOR_ZELENA" (/enter)",KucaType(houseid),HouseInfo[houseid][hVlasnik],HouseInfo[houseid][hCijena]);
Create3DTextLabel(poruka,-1,HouseInfo[houseid][hUlazX],HouseInfo[houseid][hUlazY],HouseInfo[houseid][hUlazZ],30,0,0);
}
else
{
KucaPickup = CreateDynamicPickup(1273,1, HouseInfo[houseid][hUlazX],HouseInfo[houseid][hUlazY],HouseInfo[houseid][hUlazZ],-1,-1,-1, 100);
KucaMapIcon = CreateDynamicMapIcon(HouseInfo[houseid][hUlazX],HouseInfo[houseid][hUlazY],HouseInfo[houseid][hUlazZ], 31, -1, -1 ,-1, -1, 100);
Kuca3D = format(poruka2,sizeof(poruka2),""COLOR_SIVA"~{FFFFFF} Kuca na prodaju "COLOR_SIVA"~\n{FFFFFF}TIP Kuce: {FFF1AF}%s\n{FFFFFF}Cijena: "COLOR_ZELENA"$%d\n\n{FFFFFF}Ukoliko zelite kupiti kucu: /kupikucu",KucaType(houseid),HouseInfo[houseid][hCijena]);
Create3DTextLabel(poruka,-1,HouseInfo[houseid][hUlazX], HouseInfo[houseid][hUlazY], HouseInfo[houseid][hUlazZ], 30.0,0,0);
}
}
"news":
PHP код:
new Kuca3D;
new Kuca3DOwned;
new KucaMapIcon;
new KucaMapIconOwned;
new KucaPickup;
new KucaPickupOwned;
++ If you really don't understand some words and stuff like that just say i will translate.
++ So at the end problem is: When i buy house, 3D before this which is showing now didn't hide.
Also the problem is saving names I mean i bought house,left the server and in file still says "Nitko" ("Nobody" or "None" on English).
Thanks in advance.

!
Re: House system help -
NoDi522 - 16.05.2015
++ I am using this "new" codes but i get warnings tag mismatch and I know that is the problem sooooo. ?!
Re: House system help -
Konstantinos - 16.05.2015
Replace:
pawn Код:
HouseInfo[ID][hVlasnik] = GetName(playerid);
with:
pawn Код:
strcat((HouseInfo[ID][hVlasnik][0], HouseInfo[ID][hVlasnik]), GetName(playerid), MAX_PLAYER_NAME);
// replace "MAX_PLAYER_NAME" with the size of "hVlasnik" if you've set it to a lower value.
Also:
pawn Код:
new poruka[256];
{
Kuca3D = format(poruka,sizeof(poruka),""COLOR_SIVA"~{FFFFFF} Kuca na prodaju "COLOR_SIVA"~\n{FFFFFF}TIP Kuce: {FFF1AF}%s\n{FFFFFF}Cijena: "COLOR_ZELENA"$%d\n\n{FFFFFF}Ukoliko zelite kupiti kucu: /kupikucu",KucaType(tip),HouseInfo[ID][hCijena]);
Create3DTextLabel(poruka,-1,HouseInfo[ID][hUlazX], HouseInfo[ID][hUlazY], HouseInfo[ID][hUlazZ], 30.0,0,0);
}
pawn Код:
Kuca3DOwned = format(poruka,sizeof(poruka),"{FFFFFF}TIP Kuce: %s\nVlasnik: %s\nCijena:"COLOR_ZELENA" $%d{FFFFFF}\n\nPritisnite 'f' ili 'enter' za ulazak.\nIzravan nacin -"COLOR_ZELENA" (/enter)",KucaType(idx),HouseInfo[idx][hVlasnik],HouseInfo[idx][hCijena]);
Create3DTextLabel(poruka,-1,HouseInfo[idx][hUlazX],HouseInfo[idx][hUlazY],HouseInfo[idx][hUlazZ],30,0,0);
pawn Код:
Kuca3D = format(poruka2,sizeof(poruka2),""COLOR_SIVA"~{FFFFFF} Kuca na prodaju "COLOR_SIVA"~\n{FFFFFF}TIP Kuce: {FFF1AF}%s\n{FFFFFF}Cijena: "COLOR_ZELENA"$%d\n\n{FFFFFF}Ukoliko zelite kupiti kucu: /kupikucu",KucaType(houseid),HouseInfo[houseid][hCijena]);
Create3DTextLabel(poruka,-1,HouseInfo[houseid][hUlazX], HouseInfo[houseid][hUlazY], HouseInfo[houseid][hUlazZ], 30.0,0,0);
Why do you assign Kuca3D from format function (format doesn't return any value by the way)? It should be the 3D label ID which must have a tag and be an array for each house otherwise it will overwrite the value and you'll not be able to destroy the previous 3D labels.
Re: House system help -
NoDi522 - 16.05.2015
How should i assign Kuca3D instead of using format. I have no idea?

Maybe new 3DText:Kuca3D if i understand what are u trying to tell me.
Re: House system help -
Konstantinos - 16.05.2015
pawn Код:
// global:
// after declaring "HouseInfo" array..
new Text3D: Kuca3D[sizeof (HouseInfo)];
// OnGameModeInit (resetting all variables: in a loop):
Kuca3D[iterator_variable_here] = Text3D: INVALID_3DTEXT_ID;
// rest:
format(...);
Kuca3D[ID] = Create3DTextLabel(poruka,-1,HouseInfo[ID][hUlazX], ...);
format(...);
Kuca3D[houseid] = Create3DTextLabel(poruka,-1,HouseInfo[houseid][hUlazX], ...);
// etc..
// when destroying a 3D label:
Delete3DTextLabel(Kuca3D[index_here]);
Kuca3D[index_here] = Text3D: INVALID_3DTEXT_ID;
Re: House system help -
NoDi522 - 16.05.2015
Okay. What should I figure out here?! Could you please give more explanation I want to understand your code please ?

Thanks!!
Re: House system help -
NoDi522 - 17.05.2015
BUMP! Someone please

?
I didn't understand code which Konstantinos gave me.
Re: House system help -
Konstantinos - 17.05.2015
Sure.
You created a global variable without a tag (Text3D) to store the 3D Label ID but you tried to assign the value format returns (wiki says it doesn't return any specific value though) to it.
The code I posted do the following:
- Declaring a global array with correct tag with size equal to HouseInfo (as I wasn't aware of the size you use).
- In OnGameModeInit, you should reset all house variables including the one we made above. We also reset it to INVALID_3DTEXT_ID.
- Those three parts of code you did "Kuca3D = format(" will be replaced with those above. Format should be just called normally (without having a variable storing a value from it) and assigning the 3D Label ID from Create3DTextLabel to the array we created.
- Whenever you want to destroy a 3D Label, you should know the house index and then you can easily destroy it so it won't mess up with the rest and setting the variable to INVALID_3DTEXT_ID to avoid destroying another 3D Labels.
Re: House system help -
NoDi522 - 17.05.2015
Okay but do i need to change something with Kuca3DOwned?
Re: House system help -
Konstantinos - 17.05.2015
Remove "Kuca3DOwned" and "Kuca3D" completely and then follow:
http://forum.sa-mp.com/showpost.php?...76&postcount=5