SA-MP Forums Archive
[HELP] Code creates me 500 house files - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Code creates me 500 house files (/showthread.php?tid=576186)



[HELP] Code creates me 500 house files - NoDi522 - 01.06.2015

Hey guys. I have a problem here. So i am making another house system. So when i create house in game it doesn't create 1 house as it has to be,it create max_houses (500-as I set).

This is my /napravikucu - /makehouse command:

PHP код:
CMD:napravikucu(playerid,params[])
{
    new 
Cijena,Type,INInterijer,Svijet,Interijer,Float:X,Float:Y,Float:Z// Cijena = price,INInterijer = INInterior,Svijet = World, Interijer = Interijer
    
new Float:PlayerX,Float:PlayerY,Float:PlayerZ,Float:PlayerA// Some floats...
    
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Niste ulogirani na server");
    if(
sscanf(params,"dddfff",Cijena,Type,INInterijer,X,Y,Z)) return SendClientMessage(playerid,-1,""COLOR_CRVENA"[INFO]:{FFFFFF} /napravikucu [Cijena] [Tip] [Interijer] [X] [Y] [Z]");
    if(
Cijena 10000 || Cijena 1000000) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Odaberite cijenu izmedu: 10.000$ i 1.000.000$");
    if(
Type || Type 3) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Odaberite TIP izmedu: 0-3");
    for(new 
ID 1ID sizeof(HouseInfo); ID++) // I think this is causing problem..
    
{
        
GetPlayerPos(playerid,PlayerX,PlayerY,PlayerZ);
        
GetPlayerFacingAngle(playerid,PlayerA);
        
Interijer GetPlayerInterior(playerid);
        
Svijet GetPlayerVirtualWorld(playerid);
        
HouseInfo[ID][hOwned] = 0// New house is not owned!
        
HouseInfo[ID][hCijena] = Cijena// price
        
HouseInfo[ID][hVlasnik] = 0// owner
        
HouseInfo[ID][hZakljucan] = 1// locked
        
HouseInfo[ID][hTip] = Type// type
        
HouseInfo[ID][hUlazX] = X// coords x
        
HouseInfo[ID][hUlazY] = Y// y
        
HouseInfo[ID][hUlazZ] = Z// z
        
HouseInfo[ID][hIzlazX] = PlayerX// coords x
        
HouseInfo[ID][hIzlazY] = PlayerY// y
        
HouseInfo[ID][hIzlazZ] = PlayerZ// z
        
HouseInfo[ID][hIzlazA] = PlayerA// angle
        
HouseInfo[ID][hInt] = Interijer// interior
        
HouseInfo[ID][hINInt] = INInterijer// INinterior
        
HouseInfo[ID][hSvijet] = Svijet// world
        
HouseInfo[ID][hINSvijet] = ID// INWorld
        
new poruka[256];
        {
// Some 3ds,pickups,and icons on the map...
            
format(poruka,sizeof(poruka),""COLOR_ZELENA"[Kuca na prodaju]{FFFFFF}\n\n- Cijena:"COLOR_WG" $%d\n{FFFFFF}- Tip: %s\nPotreban Level: 3\n\nZa kupnju kuce upisite: "COLOR_SIVA"/kupikucu.",HouseInfo[ID][hCijena],HouseType(Type));
            
HouseInfo[ID][hVanjski3D] = Create3DTextLabel(poruka,-1,PlayerX,PlayerY,PlayerZ,30.0,0,0);
            
HouseInfo[ID][hVanjskiPickup] = CreatePickup(1273,1,PlayerX,PlayerY,PlayerZ,-1);
            
HouseInfo[ID][hIkona] = CreateDynamicMapIcon(PlayerX,PlayerY,PlayerZ,31,-1,-1,-1,-1,100);
        }
        
/* Spremanje Kuca */ // SAVING...
        
new INI:File INI_Open(HousePath(ID));
        
INI_SetTag(File,"Info");
        
INI_WriteInt(File,"Owned",HouseInfo[ID][hOwned]);
        
INI_WriteInt(File,"Cijena",HouseInfo[ID][hCijena]);
          
INI_WriteInt(File,"Vlasnik",HouseInfo[ID][hVlasnik]);
        
INI_WriteInt(File,"Zakljucan",HouseInfo[ID][hZakljucan]);
        
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]);
        
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,"OutInterijer",HouseInfo[ID][hInt]);
        
INI_WriteInt(File,"Interijer",HouseInfo[ID][hINInt]);
        
INI_WriteInt(File,"Svijet",HouseInfo[ID][hSvijet]);
        
INI_WriteInt(File,"INSvijet",HouseInfo[ID][hINSvijet]);
        
INI_WriteInt(File,"Ikona",HouseInfo[ID][hIkona]);
        
INI_WriteInt(File,"Vanjski3D",HouseInfo[ID][hVanjski3D]);
        
INI_WriteInt(File,"VanjskiPickup",HouseInfo[ID][hVanjskiPickup]);
        
INI_Close(File);
    }
    return 
1;

If you need my saving or loading just say but i think you won't need it. Thanks for support!

And yes i will rep+ for the code which helps me.


Re: [HELP] Code creates me 500 house files - NoDi522 - 01.06.2015

And if could you please explain that what you rechanged.


Re: [HELP] Code creates me 500 house files - FrankLucretti - 01.06.2015

Quote:
Originally Posted by NoDi522
Посмотреть сообщение
And if could you please explain that what you rechanged.
Hey bro!!
Please +1rep heres your code!

If mensuned it with the 2 && so that the Parameters are as same with the playerid which returns.
i changed the return to 1; , because before it has set up the system and blocked it.

PHP код:
CMD:napravikucu(playerid,params[]) 

    new 
Cijena,Type,INInterijer,Svijet,Interijer,Float:X,Float:Y,Float:Z// Cijena = price,INInterijer = INInterior,Svijet = World, Interijer = Interijer 
    
new Float:PlayerX,Float:PlayerY,Float:PlayerZ,Float:PlayerA// Some floats... 
    
if(!IsPlayerConnected(playerid)) return 1SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Niste ulogirani na server"); 
    if(
sscanf(params,"dddfff",Cijena,Type,INInterijer,X,Y,Z)) return SendClientMessage(playerid,-1,""COLOR_CRVENA"[INFO]:{FFFFFF} /napravikucu [Cijena] [Tip] [Interijer] [X] [Y] [Z]"); 
    if(
Cijena 10000 || Cijena 1000000) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Odaberite cijenu izmedu: 10.000$ i 1.000.000$"); 
    if(
Type || Type 3) return SendClientMessage onresp &&(playerid,-0, %+,""COLOR_CRVENA"Greska:{FFFFFF} Odaberite TIP izmedu: 0-3"); 
    for(new 
ID 1ID & < sizeofonplayerid (HouseInfo); ID++) // I think this is causing problem.. 
    

        
GetPlayerPos(playerid,PlayerX,PlayerY,PlayerZ); 
GetPlayerHousePos(playeridsizeofonplayeridHouseInfo); &&
        
GetPlayerFacingAngle(playerid,PlayerA); 
        
Interijer GetPlayerInterior(playerid); 
        
Svijet GetPlayerVirtualWorld(playerid); 
        
HouseInfo[ID][hOwned] = 0// New house is not owned! 
        
HouseInfo[ID][hCijena] = Cijena// price 
        
HouseInfo[ID][hVlasnik] = 0// owner 
        
HouseInfo[ID][hZakljucan] = 1// locked 
        
HouseInfo[ID][hTip] = Type// type 
        
HouseInfo[ID][hUlazX] = X// coords x 
        
HouseInfo[ID][hUlazY] = Y// y 
        
HouseInfo[ID][hUlazZ] = Z// z 
        
HouseInfo[ID][hIzlazX] = PlayerX// coords x 
        
HouseInfo[ID][hIzlazY] = PlayerY// y 
        
HouseInfo[ID][hIzlazZ] = PlayerZ// z 
        
HouseInfo[ID][hIzlazA] = PlayerA// angle 
        
HouseInfo[ID][hInt] = Interijer// interior 
        
HouseInfo[ID][hINInt] = INInterijer// INinterior 
        
HouseInfo[ID][hSvijet] = Svijet// world 
        
HouseInfo[ID][hINSvijet] = ID// INWorld 
        
new poruka[256]; 
        {
// Some 3ds,pickups,and icons on the map... 
            
format(poruka,sizeof(poruka),""COLOR_ZELENA"[Kuca na prodaju]{FFFFFF}\n\n- Cijena:"COLOR_WG" $%d\n{FFFFFF}- Tip: %s\nPotreban Level: 3\n\nZa kupnju kuce upisite: "COLOR_SIVA"/kupikucu.",HouseInfo[ID][hCijena],HouseType(Type)); 
            
HouseInfo[ID][hVanjski3D] = Create3DTextLabel(poruka,-1,PlayerX,PlayerY,PlayerZ,30.0,0,0); 
            
HouseInfo[ID][hVanjskiPickup] = CreatePickup(1273,1,PlayerX,PlayerY,PlayerZ,-1); 
            
HouseInfo[ID][hIkona] = CreateDynamicMapIcon(PlayerX,PlayerY,PlayerZ,31,-1,-1,-1,-1,100); 
        } 
        
/* Spremanje Kuca */ // SAVING... 
        
new INI:File INI_Open(HousePath(ID)); 
        
INI_SetTag(File,"Info"); 
        
INI_WriteInt(File,"Owned",HouseInfo[ID][hOwned]); 
        
INI_WriteInt(File,"Cijena",HouseInfo[ID][hCijena]); 
          
INI_WriteInt(File,"Vlasnik",HouseInfo[ID][hVlasnik]); 
        
INI_WriteInt(File,"Zakljucan",HouseInfo[ID][hZakljucan]); 
        
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]); 
        
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,"OutInterijer",HouseInfo[ID][hInt]); 
        
INI_WriteInt(File,"Interijer",HouseInfo[ID][hINInt]); 
        
INI_WriteInt(File,"Svijet",HouseInfo[ID][hSvijet]); 
        
INI_WriteInt(File,"INSvijet",HouseInfo[ID][hINSvijet]); 
        
INI_WriteInt(File,"Ikona",HouseInfo[ID][hIkona]); 
        
INI_WriteInt(File,"Vanjski3D",HouseInfo[ID][hVanjski3D]); 
        
INI_WriteInt(File,"VanjskiPickup",HouseInfo[ID][hVanjskiPickup]); 
        
INI_Close(File); 
    } 
    return 
1

Please 1+rep


Re: [HELP] Code creates me 500 house files - NoDi522 - 01.06.2015

PHP код:
for(new ID 1ID & < sizeofonplayerid (HouseInfo); ID++) 
What the fu*k you've done here?!


Re: [HELP] Code creates me 500 house files - MotherDucker - 01.06.2015

I don't see why you're looping this command? surely once the house has been created, then the command should finish, try removing the loop i.e.
remove this code
Код:
for(new ID = 1; ID < sizeof(HouseInfo); ID++)
remove the two open and closing brackets for that code and unindent the code that was inside of that code, then it should work.. in theory, Tell me how it went if you do this.


Re: [HELP] Code creates me 500 house files - FrankLucretti - 01.06.2015

Quote:
Originally Posted by NoDi522
Посмотреть сообщение
PHP код:
for(new ID 1ID & < sizeofonplayerid (HouseInfo); ID++) 
What the fu*k you've done here?!
I've fixed it.
+1rep please, I NEED REPP xD


Re: [HELP] Code creates me 500 house files - Konstantinos - 01.06.2015

Why do you use the loop then? Remove it and store the data to one house index only. Having a variable that counts how many houses have been created and if it doesn't exceed the bounds, creating a new house would be the best option.

@FrankLucretti: You fixed nothing, you still kept the loop..


Re: [HELP] Code creates me 500 house files - FrankLucretti - 01.06.2015

PHP код:
if(PlayerInfo[playerid][Vip] >= 2)
    {
        new 
weather;
        if(
sscanf(params"i"weather)) return SendClientMessage(playeridCOLOR_RED"[ERROR]: Usage /Dweather (Weather-Id)");
        if(
weather 45 || weather 0) return SendClientMessage(playeridCOLOR_RED"[ERROR]: Invalid Weather-Id.");
        
SendClientMessage(playeridCOLOR_BLUE"[SUCCESS]: Weather changed.");
        return 
SetPlayerWeather(playeridweather);
    } else return 
SendClientMessage(playeridCOLOR_RED ,"[ERROR]: You Need to be at least Donor Rank 2 To Use This Command");

PHP код:
CMD:napravikucu(playerid,params[])  
{  
    new 
Cijena,Type,INInterijer,Svijet,Interijer,Float:X,Float:Y,Float:Z// Cijena = price,INInterijer = INInterior,Svijet = World, Interijer = Interijer  
    
new Float:PlayerX,Float:PlayerY,Float:PlayerZ,Float:PlayerA// Some floats...  
    
if(!IsPlayerConnected(playerid)) return 1SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Niste ulogirani na server");  
    if(
sscanf(params,"dddfff",Cijena,Type,INInterijer,X,Y,Z)) return SendClientMessage(playerid,-1,""COLOR_CRVENA"[INFO]:{FFFFFF} /napravikucu [Cijena] [Tip] [Interijer] [X] [Y] [Z]");  
    if(
Cijena 10000 || Cijena 1000000) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Odaberite cijenu izmedu: 10.000$ i 1.000.000$");  
    if(
Type || Type 3) return SendClientMessage onresp &&(playerid,-0, %+,""COLOR_CRVENA"Greska:{FFFFFF} Odaberite TIP izmedu: 0-3");  
    for(new 
ID 1ID & < sizeofonplayerid (HouseInfo); ID++) // I think this is causing problem..  
    
{  
        
GetPlayerPos(playerid,PlayerX,PlayerY,PlayerZ);  
GetPlayerHousePos(playeridsizeofonplayeridHouseInfo); && 
        
GetPlayerFacingAngle(playerid,PlayerA);  
        
Interijer GetPlayerInterior(playerid);  
        
Svijet GetPlayerVirtualWorld(playerid);  
        
HouseInfo[ID][hOwned] = 0// New house is not owned!  
        
HouseInfo[ID][hCijena] = Cijena// price  
        
HouseInfo[ID][hVlasnik] = 0// owner  
        
HouseInfo[ID][hZakljucan] = 1// locked  
        
HouseInfo[ID][hTip] = Type// type  
        
HouseInfo[ID][hUlazX] = X// coords x  
        
HouseInfo[ID][hUlazY] = Y// y  
        
HouseInfo[ID][hUlazZ] = Z// z  
        
HouseInfo[ID][hIzlazX] = PlayerX// coords x  
        
HouseInfo[ID][hIzlazY] = PlayerY// y  
        
HouseInfo[ID][hIzlazZ] = PlayerZ// z  
        
HouseInfo[ID][hIzlazA] = PlayerA// angle  
        
HouseInfo[ID][hInt] = Interijer// interior  
        
HouseInfo[ID][hINInt] = INInterijer// INinterior  
        
HouseInfo[ID][hSvijet] = Svijet// world  
        
HouseInfo[ID][hINSvijet] = ID// INWorld  
        
new poruka[256];  
        {
// Some 3ds,pickups,and icons on the map...  
            
format(poruka,sizeof(poruka),""COLOR_ZELENA"[Kuca na prodaju]{FFFFFF}\n\n- Cijena:"COLOR_WG" $%d\n{FFFFFF}- Tip: %s\nPotreban Level: 3\n\nZa kupnju kuce upisite: "COLOR_SIVA"/kupikucu.",HouseInfo[ID][hCijena],HouseType(Type));  
            
HouseInfo[ID][hVanjski3D] = Create3DTextLabel(poruka,-1,PlayerX,PlayerY,PlayerZ,30.0,0,0);  
            
HouseInfo[ID][hVanjskiPickup] = CreatePickup(1273,1,PlayerX,PlayerY,PlayerZ,-1);  
            
HouseInfo[ID][hIkona] = CreateDynamicMapIcon(PlayerX,PlayerY,PlayerZ,31,-1,-1,-1,-1,100);  
        }  
        
/* Spremanje Kuca */ // SAVING...  
        
new INI:File INI_Open(HousePath(ID));  
        
INI_SetTag(File,"Info");  
        
INI_WriteInt(File,"Owned",HouseInfo[ID][hOwned]);  
        
INI_WriteInt(File,"Cijena",HouseInfo[ID][hCijena]);  
          
INI_WriteInt(File,"Vlasnik",HouseInfo[ID][hVlasnik]);  
        
INI_WriteInt(File,"Zakljucan",HouseInfo[ID][hZakljucan]);  
        
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]);  
        
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,"OutInterijer",HouseInfo[ID][hInt]);  
        
INI_WriteInt(File,"Interijer",HouseInfo[ID][hINInt]);  
        
INI_WriteInt(File,"Svijet",HouseInfo[ID][hSvijet]);  
        
INI_WriteInt(File,"INSvijet",HouseInfo[ID][hINSvijet]);  
        
INI_WriteInt(File,"Ikona",HouseInfo[ID][hIkona]);  
        
INI_WriteInt(File,"Vanjski3D",HouseInfo[ID][hVanjski3D]);  
        
INI_WriteInt(File,"VanjskiPickup",HouseInfo[ID][hVanjskiPickup]);  
        
INI_Close(File);  
if(
PlayerInfo[playerid][Vip] >= 2)
    {
        new 
weather;
        if(
sscanf(params"i"weather)) return SendClientMessage(playeridCOLOR_RED"[ERROR]: Usage /Dweather (Weather-Id)");
        if(
weather 45 || weather 0) return SendClientMessage(playeridCOLOR_RED"[ERROR]: Invalid Weather-Id.");
        
SendClientMessage(playeridCOLOR_BLUE"[SUCCESS]: Weather changed.");
        return 
SetPlayerWeather(playeridweather);
    } else return 
SendClientMessage(playeridCOLOR_RED ,"[ERROR]: You Need to be at least Donor Rank 2 To Use This Command");
}[/
    }  
    return 
1;  

Insert the Playerinfo, under the last Line.

@Konstantinos
as also a Greek, you should be nice with other greeks xd rep me.


Re: [HELP] Code creates me 500 house files - MotherDucker - 01.06.2015

@FrankLucretti
You still haven't changed anything.. Abd why'd you add a weather command to it...


Re: [HELP] Code creates me 500 house files - FrankLucretti - 01.06.2015

removed