House system bugs
#1

The house system has some bugs. Can someone help me fix the following: the dini doesn't create more than 1 created house, and "Owner = pName" is not being created, and "Owner" is not being created in the dini either, yet it doesn't give any errors.
Help would be really appreciated!
PHP код:
#define MAX_HOUSES 1000
#define CreateHouseDialog 1500
#define HousePriceDialog 1501
#define HouseInteriorDialog 1502
#define SaveHouseDialog 1503
#define RemoveIDHouseDialog 1504
 
enum hInfo
{
    
hPrice,
    
hInterior,
    
hNumber,
    
hLocked,
    
hOwned,
    
hPick,
    
hIcon,
    
hWorld,
    
hOwner[MAX_PLAYER_NAME],
    
Text3D:hLabel,
    
Float:hX,
    
Float:hY,
    
Float:hZ,
}
new 
HouseInfo[MAX_HOUSES][hInfo];
new 
houseidInHouse[MAX_PLAYERS][MAX_HOUSES];
new 
Float:hA[MAX_HOUSES][3];
 
CMD:chouse(playeridparams[])
{
        
ShowPlayerDialog(playeridCreateHouseDialogDIALOG_STYLE_MSGBOX"House options""Select your option.""Create""Remove");
        return 
1;
}
 
CMD:buyhouse(playeridparams[])
{
    new 
string[128], pName[MAX_PLAYER_NAME], Float:XFloat:YFloat:ZWorldHouses[75];
    
World GetPlayerVirtualWorld(playerid);
    
GetPlayerPos(playeridhA[houseid][0], hA[houseid][1], hA[houseid][2]);
    
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
    for(new 
0MAX_PLAYERSi++)
    {
        if(!
IsPlayerInRangeOfPoint(playerid5HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ])) return SendClientMessage(playeridCOLOR_RED"Error: You have to be near a house!");
        if(
HouseInfo[i][hOwner] == 1) return SendClientMessage(playeridCOLOR_RED"Error: You own this house already!");
        if(
HouseInfo[i][hOwned] == 1) return SendClientMessage(playeridCOLOR_RED"Error: The house is already purchased!");
        if(
GetPlayerMoney(playerid) < HouseInfo[i][hPrice]) return SendClientMessage(playeridCOLOR_RED"Error: You don't have enough money to purchase this house!");
        
DestroyPickup(HouseInfo[i][hPick]);
        
HouseInfo[i][hPick] = CreatePickup(12721hA[houseid][0], hA[houseid][1], hA[houseid][2], World);
        
HouseInfo[i][hIcon] = SetPlayerMapIcon(playerid33XYZ3200);
        
format(stringsizeof string"{15FF00}Owner: {FFFFFF}%s\n{FFEA00}Price: {FFFFFF}%i"pNameHouseInfo[i][hPrice]);
        
Update3DTextLabelText(HouseInfo[i][hLabel], COLOR_WHITEstring);
        
HouseInfo[i][hOwner] = pName;
        
HouseInfo[i][hOwned] = 1;
        
format(stringsizeof string"Congratulations! You have purchased the house for $%i dollars. Enjoy your stay!"HouseInfo[i][hPrice]);
        
SendClientMessage(playeridCOLOR_LIGHTGREENstring);
        
GivePlayerMoney(playerid, -HouseInfo[i][hPrice]);
        
format(Housessizeof Houses"Houses/%i.ini"i);
        if(
fexist(Houses))
        {
            
dini_IntSet(Houses"Owned"1);
            
dini_Set(Houses"Owner"pName);
        }
    }
    return 
1;
}
 
CMD:sellhouse(playeridparams[])
{
    new 
string[128], pName[MAX_PLAYER_NAME], Float:XFloat:YFloat:ZWorldHouses[75];
    
World GetPlayerVirtualWorld(playerid);
    
//GetPlayerPos(playerid, X, Y, Z);
    
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
    for(new 
0MAX_HOUSESi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid5HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]))
        {
            if(
HouseInfo[i][hOwned] == 0) return SendClientMessage(playeridCOLOR_RED"Error: This house has to be purchased first!");
            if(
HouseInfo[i][hOwner] == 0) return SendClientMessage(playeridCOLOR_RED"Error: This house is not owned by you!");
            
DestroyPickup(HouseInfo[i][hPick]);
            
HouseInfo[i][hPick] = CreatePickup(12731hA[houseid][0], hA[houseid][1], hA[houseid][2], World);
            
HouseInfo[i][hIcon] = SetPlayerMapIcon(playerid35XYZ3100);
            
format(stringsizeof string"{FFEA00}Price: $%i\nType /Buyhouse to purchase this house!"HouseInfo[i][hPrice]);
            
Update3DTextLabelText(HouseInfo[i][hLabel], COLOR_WHITEstring);
            
HouseInfo[i][hOwned] = 0;
            
HouseInfo[i][hOwner] = 0;
            
format(stringsizeof string"You have earned $%i dollars for selling your house!"HouseInfo[i][hPrice]);
            
SendClientMessage(playeridCOLOR_YELLOWstring);
            
GivePlayerMoney(playeridHouseInfo[i][hPrice]);
            {
                
dini_IntSet(Houses"Owned"0);
                
dini_IntSet(Houses"Owner"0);
            }
        }
        else
        {
            if(
HouseInfo[i][hOwner] == 1)
            {
                
SendClientMessage(playeridCOLOR_RED"Error: You must be near your house");
            }
        }
    }
   
    return 
1;
}
 
CMD:enter(playeridparams[])
{
    for(new 
0MAX_HOUSESi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid5HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]))
        {
            if(
HouseInfo[i][hOwned] == 0) return SendClientMessage(playeridCOLOR_RED"Error: This house has to be purchased first!");
            if(
HouseInfo[i][hLocked] == 1) return SendClientMessage(playeridCOLOR_RED"Error: This house is locked.");
            if(
HouseInfo[i][hNumber] == 1000)
            {
                
SetPlayerPos(playerid243.9951,304.9418,999.1484);
                
SetPlayerFacingAngle(playerid267.0980);
                
SetCameraBehindPlayer(playerid);
                
SetPlayerInterior(playerid1);
            }
            if(
HouseInfo[i][hNumber] == 2000)
            {
                
SetPlayerPos(playerid2259.6702,-1135.8542,1050.6328);
                
SetPlayerFacingAngle(playerid267.3974);
                
SetCameraBehindPlayer(playerid);
                
SetPlayerInterior(playerid10);
            }
            if(
HouseInfo[i][hNumber] == 3000)
            {
                
SetPlayerPos(playerid2308.8254,-1212.8070,1049.0234);
                
SetPlayerFacingAngle(playerid359.8550);
                
SetCameraBehindPlayer(playerid);
                
SetPlayerInterior(playerid6);
            }
            if(
HouseInfo[i][hNumber] == 4000)
            {
                
SetPlayerPos(playerid260.7436,1237.5563,1084.2578);
                
SetPlayerFacingAngle(playerid1.6415);
                
SetCameraBehindPlayer(playerid);
                
SetPlayerInterior(playerid9);
            }
            if(
HouseInfo[i][hNumber] == 5000)
            {
                
SetPlayerPos(playerid, -42.5742,1405.6521,1084.4297);
                
SetPlayerFacingAngle(playerid359.1347);
                
SetCameraBehindPlayer(playerid);
                
SetPlayerInterior(playerid8);
            }
        }
        
InHouse[playerid][i] = 1;
        
SendClientMessage(playeridCOLOR_GREEN"{FFA200}[House]: {FFFFFF}You have entered the house.");
    }
    return 
1;
}
 
CMD:exit(playeridparams[])
{
    for(new 
0MAX_HOUSESi++)
    {
        if(
InHouse[playerid][i] == 0) return SendClientMessage(playeridCOLOR_RED"Error: You are not in a house!");
        
SetPlayerPos(playeridHouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]);
        
InHouse[playerid][i] = 0;
    }
    
SendClientMessage(playeridCOLOR_GREEN"{FFA200}[House]: {FFFFFF}You have left the house.");
    return 
1;
}
 
CMD:lockhouse(playeridparams[])
{
    new 
pName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
    for(new 
0MAX_HOUSESi++)
    {
        if(
HouseInfo[i][hOwner] == 1) return SendClientMessage(playeridCOLOR_RED"Error: This house is not owned by you!");
        if(
HouseInfo[i][hLocked] == 1) return SendClientMessage(playeridCOLOR_RED"Error: You have locked your house already!");
        
HouseInfo[i][hLocked] = 1;
    }
    
SendClientMessage(playeridCOLOR_YELLOW"{FFA200}[House]: {FFFFFF}You have locked your house.");
    return 
1;
}
 
CMD:unlockhouse(playeridparams[])
{
    new 
pName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
    for(new 
0MAX_PLAYERSi++)
    {
        if(
HouseInfo[i][hOwner] != 1) return SendClientMessage(playeridCOLOR_RED"Error: This house is not owned by you!");
        if(
HouseInfo[i][hLocked] != 1) return SendClientMessage(playeridCOLOR_RED"Error: Your house is unlocked already!");
        
HouseInfo[i][hLocked] = 0;
    }
    
SendClientMessage(playeridCOLOR_YELLOW"{FFA200}[House]: {FFFFFF}You have unlocked your house.");
    return 
1;
}
 
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
                                                        
// HOUSE SYSTEM !!
 
    
if(dialogid == CreateHouseDialog)
    {
        if(
response)
        {
            
ShowPlayerDialog(playeridHousePriceDialogDIALOG_STYLE_INPUT"House Price""Enter the price of this house""Continue""Back");
        }
        else
        {
            
ShowPlayerDialog(playeridRemoveIDHouseDialogDIALOG_STYLE_INPUT"Remove House ID""Enter the house ID to be removed""Remove""Back");
        }
    }
 
    if(
dialogid == HousePriceDialog)
    {
        if(
response)
        {
            if(!
strlen(inputtext)) return ShowPlayerDialog(playeridHousePriceDialogDIALOG_STYLE_INPUT"House Price""Enter the price of this house""Continue""Back");
            
SendClientMessage(playeridCOLOR_WHITE"{FFA200}[House]: The entered price has been set as the house price.");
            
HouseInfo[houseid][hPrice] = strval(inputtext);
            
ShowPlayerDialog(playeridHouseInteriorDialogDIALOG_STYLE_LIST"Interiors""Interior 1\nInterior 2\nInterior 3\nInterior 4\nInterior 5""Continue""Back");
        }
        else
        {
            
ShowPlayerDialog(playeridCreateHouseDialogDIALOG_STYLE_MSGBOX"House options""Select a option""Create""Remove");
        }
    }
   
    if(
dialogid == HouseInteriorDialog)
    {
        switch(
listitem)
        {
            case 
0:
            {
                new 
string[128];
                
format(stringsizeof string"{288F88}House ID: {FF4D00}%i\n{33FF00}House Price: {FF4D00}%i\n{FF4D00}House Interior: {FF4D00}1"houseidHouseInfo[houseid][hPrice]);
                
ShowPlayerDialog(playeridSaveHouseDialogDIALOG_STYLE_MSGBOX"Save"string"Save""Back");
                
SendClientMessage(playeridCOLOR_ORANGE"{FFA200}[House]: Interior has been set. (Interior 1)");
                
HouseInfo[houseid][hInterior] = 3;
                
HouseInfo[houseid][hNumber] = 1000;
            }
            case 
1:
            {
                new 
string[128];
                
format(stringsizeof string"{288F88}House ID: {FF4D00}%i\n{33FF00}House Price: {FF4D00}%i\n{FF4D00}House Interior: {FF4D00}2"houseidHouseInfo[houseid][hPrice]);
                
ShowPlayerDialog(playeridSaveHouseDialogDIALOG_STYLE_MSGBOX"Save"string"Save""Back");
                
SendClientMessage(playeridCOLOR_ORANGE"{FFA200}[House]: Interior has been set. (Interior 2)");
                
HouseInfo[houseid][hInterior] = 3;
                
HouseInfo[houseid][hNumber] = 2000;
            }
            case 
2:
            {
                new 
string[128];
                
format(stringsizeof string"{288F88}House ID: {FF4D00}%i\n{33FF00}House Price: {FF4D00}%i\n{FF4D00}House Interior: {FF4D00}3"houseidHouseInfo[houseid][hPrice]);
                
ShowPlayerDialog(playeridSaveHouseDialogDIALOG_STYLE_MSGBOX"Save"string"Save""Back");
                
SendClientMessage(playeridCOLOR_ORANGE"{FFA200}[House]: Interior has been set. (Interior 3)");
                
HouseInfo[houseid][hInterior] = 2;
                
HouseInfo[houseid][hNumber] = 3000;
            }
            case 
3:
            {
                new 
string[128];
                
format(stringsizeof string"{288F88}House ID: {FF4D00}%i\n{33FF00}House Price: {FF4D00}%i\n{FF4D00}House Interior: {FF4D00}4"houseidHouseInfo[houseid][hPrice]);
                
ShowPlayerDialog(playeridSaveHouseDialogDIALOG_STYLE_MSGBOX"Save"string"Save""Back");
                
SendClientMessage(playeridCOLOR_ORANGE"{FFA200}[House]: Interior has been set. (Interior 4)");
                
HouseInfo[houseid][hInterior] = 2;
                
HouseInfo[houseid][hNumber] = 4000;
            }
            case 
4:orm_insert_inline()
            {
                new 
string[128];
                
format(stringsizeof string"{288F88}House ID: {FF4D00}%i\n{33FF00}House Price: {FF4D00}%i\n{FF4D00}House Interior: {FF4D00}5"houseidHouseInfo[houseid][hPrice]);
                
ShowPlayerDialog(playeridSaveHouseDialogDIALOG_STYLE_MSGBOX"Save"string"Save""Back");
                
SendClientMessage(playeridCOLOR_ORANGE"{FFA200}[House]: Interior has been set. (Interior 5)");
                
HouseInfo[houseid][hInterior] = 5;
                
HouseInfo[houseid][hNumber] = 5000;
            }
        }
        
//else
        //{
        //  ShowPlayerDialog(playerid, HousePriceDialog, DIALOG_STYLE_INPUT, "House Price", "Enter the price of this house", "Continue", "Back");
        //}
    
}
   
    if(
dialogid == SaveHouseDialog)
    {
        if(
response)
        {
            new 
string[128], pName[MAX_PLAYER_NAME], Float:XFloat:YFloat:ZWorldHouses[75];
            
World GetPlayerVirtualWorld(playerid);
            
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
            
format(stringsizeof string"{FFA200}[House]: {288F88}House ID: {FF4D00}%i {FFFFFF} has been created."houseid);
            
SendClientMessage(playerid, -1string);
            
GetPlayerPos(playeridXYZ);
            
HouseInfo[houseid][hX] = X;
            
HouseInfo[houseid][hY] = Y;
            
HouseInfo[houseid][hZ] = Z;
            
HouseInfo[houseid][hPick] = CreatePickup(12731XYZWorld);
            
HouseInfo[houseid][hIcon] = SetPlayerMapIcon(playerid34XYZ3100);
            
format(stringsizeof string"{FFA200}House ID: {FFFFFF}%i\n{FFA200}Price: {FFFFFF}%i\nType /Buyhouse to purchase this house!"houseidHouseInfo[houseid][hPrice]);
            
HouseInfo[houseid][hLabel] = Create3DTextLabel(string, -1XYZ2500);
            
format(Housessizeof Houses"Houses/%i.ini");
            if(!
fexist(Houses))
            {
                
dini_Create(Houses);
                
dini_IntSet(Houses"Price"HouseInfo[houseid][hPrice]);
                
dini_IntSet(Houses"Interior"HouseInfo[houseid][hInterior]);
                
dini_Int(Houses"Owned");
                
dini_Int(Houses"Owner");
                
dini_FloatSet(Houses"Position X"X);
                
dini_FloatSet(Houses"Position Y"Y);
                
dini_FloatSet(Houses"Position Z"Z);
            }
            
houseid++;
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED"Error: The house has been resetted.");
        }
    }
   
    if(
dialogid == RemoveIDHouseDialog)
    {
        if(
response)
        {
            new 
hIDHouses[75], string[128];
            
hID strval(inputtext);
            
format(Housessizeof Houses"Houses/%i.ini"hID);
            if(!
fexist(Houses))
            {
                
SendClientMessage(playeridCOLOR_RED"Error: The specified house id is not recognized.");
            }
            else
            {
                
HouseInfo[houseid][hPrice] = 0;
                
HouseInfo[hID][hLocked] = 0;
                
HouseInfo[hID][hOwned] = 0;
                
HouseInfo[hID][hOwner] = 0;
                
HouseInfo[hID][hX] = 0;
                
HouseInfo[hID][hY] = 0;
                
HouseInfo[hID][hZ] = 0;
                
DestroyPickup(HouseInfo[houseid][hPick]);
                
Update3DTextLabelText(HouseInfo[houseid][hLabel], COLOR_WHITE"");
                
format(stringsizeof string"{FFA200}[House]: {288F88}House ID: %i has been removed."hID);
                
SendClientMessage(playerid, -1string);
                
dini_Remove(Houses);
            }
        }
        else
        {
            
ShowPlayerDialog(playeridCreateHouseDialogDIALOG_STYLE_MSGBOX"House options""{FFFFFF}Please, select your option.""Create""Remove");
        }
    } 
Reply
#2

?? Anyone
Reply
#3

Have you considered updating to a better system like y_ini or MySQL?

Try this (uses y_ini): https://sampforum.blast.hk/showthread.php?tid=349466
Reply
#4

To be honest I haven't considered it, and I don't want it as I just went to dini. I'd like to have this fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)