GarHouse V2.0 Buy button issue
#1

I'm trying to implement this GarHouse v2.0 system into my gamemode and I'm having an issue getting it to work. After I create a house, which works fine, I walk up to it and the option to buy pops up. Well the "buy" button does nothing and doesn't work. I've read it could be a problem with the OnDialogReponse, but I'm not sure exactly what's wrong with the code. It seems to be correct but it's just not working. Anybody else have this problem with it or a solution? Thanks
Reply
#2

Check the ID of that dialog under OnDialogResponse, the issue is there for sure. Personally I wouldn't recommend using garhouse if you dont have a good amount of scripting knowledge as there are alot of bugs to it.
Reply
#3

Ok, I'm not sure where in the code the problem is

pawn Code:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        new string[256], tmpstring[50];
        foreach(Houses, h)
        {
            if(checkpointid == HouseCPOut[h])
            {
                SetPVarInt(playerid, "LastHouseCP", h);
                if(!strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE))
                {
                    SetPlayerHouseInterior(playerid, h);
                    ShowInfoBoxEx(playerid, COLOUR_INFO, I_HMENU);
                    break;
                }
                format(tmpstring, sizeof(tmpstring), "HouseKeys_%d", h);
                if(GetPVarInt(playerid, tmpstring) == 1)
                {
                    SetPlayerHouseInterior(playerid, h);
                    break;
                }
                if(strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE) && strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE))
                {
                    if(hInfo[h][HousePassword] == udb_hash("INVALID_HOUSE_PASSWORD"))
                    {
                        switch(hInfo[h][ForSale])
                        {
                            case 0: ShowInfoBox(playerid, LABELTEXT2, hInfo[h][HouseName], hInfo[h][HouseOwner], hInfo[h][HouseValue], h);
                            case 1:
                            {
                                switch(hInfo[h][HousePrivacy])
                                {
                                    case 0: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In", "Select", "Cancel");
                                    case 1: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In\nEnter House", "Select", "Cancel");
                                }
                            }
                        }
                        break;
                    }
                    if(hInfo[h][HousePassword] != udb_hash("INVALID_HOUSE_PASSWORD"))
                    {
                        switch(hInfo[h][ForSale])
                        {
                            case 0:
                            {
                                switch(hInfo[h][HousePrivacy])
                                {
                                    case 0: ShowPlayerDialog(playerid, HOUSEMENU+28, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Enter House Using Password\nBreak In", "Select", "Cancel");
                                    case 1: ShowPlayerDialog(playerid, HOUSEMENU+28, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Enter House Using Password\nBreak In\nEnter House", "Select", "Cancel");
                                }
                            }
                            case 1: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In\nEnter House", "Select", "Cancel");
                        }
                        break;
                    }
                }
                if(!strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE) && hInfo[h][HouseValue] > 0 && GetPVarInt(playerid, "JustCreatedHouse") == 0)
                {
                    format(string, sizeof(string), HMENU_BUY_HOUSE, hInfo[h][HouseValue]);
                    ShowPlayerDialog(playerid, HOUSEMENU+4, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
                    break;
                }
            }
            if(checkpointid == HouseCPInt[h])
            {
                switch(GetPVarInt(playerid, "HousePreview"))
                {
                    case 0: ExitHouse(playerid, h);
                    #if GH_HINTERIOR_UPGRADE == true
                    case 1:
                    {
                        GetPVarString(playerid, "HousePrevName", tmpstring, 50);
                        format(string, sizeof(string), HMENU_BUY_HINTERIOR, tmpstring, GetPVarInt(playerid, "HousePrevValue"));
                        ShowPlayerDialog(playerid, HOUSEMENU+17, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
                    }
                    #endif
                }
                break;
            }
        }
    }
    return 1;
}
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPVarInt(playerid, "JustCreatedHouse") == 1)
    {
        foreach(Houses, h)
        {
            if(checkpointid == HouseCPOut[h])
            {
                DeletePVar(playerid, "JustCreatedHouse");
                break;
            }
        }
    }
    return 1;
}
#else
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        new string[256], tmpstring[50];
        foreach(Houses, h)
        {
            if(pickupid == HousePickupOut[h])
            {
                SetPVarInt(playerid, "LastHouseCP", h);
                if(!strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE))
                {
                    SetPlayerHouseInterior(playerid, h);
                    ShowInfoBoxEx(playerid, COLOUR_INFO, I_HMENU);
                    break;
                }
                format(tmpstring, sizeof(tmpstring), "HouseKeys_%d", h);
                if(GetPVarInt(playerid, tmpstring) == 1)
                {
                    SetPlayerHouseInterior(playerid, h);
                    break;
                }
                if(strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE) && strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE))
                {
                    if(hInfo[h][HousePassword] == udb_hash("INVALID_HOUSE_PASSWORD"))
                    {
                        switch(hInfo[h][ForSale])
                        {
                            case 0: ShowInfoBox(playerid, LABELTEXT2, hInfo[h][HouseName], hInfo[h][HouseOwner], hInfo[h][HouseValue], h);
                            case 1:
                            {
                                switch(hInfo[h][HousePrivacy])
                                {
                                    case 0: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In", "Select", "Cancel");
                                    case 1: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In\nEnter House", "Select", "Cancel");
                                }
                            }
                        }
                        break;
                    }
                    if(hInfo[h][HousePassword] != udb_hash("INVALID_HOUSE_PASSWORD"))
                    {
                        switch(hInfo[h][ForSale])
                        {
                            case 0:
                            {
                                switch(hInfo[h][HousePrivacy])
                                {
                                    case 0: ShowPlayerDialog(playerid, HOUSEMENU+28, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Enter House Using Password\nBreak In", "Select", "Cancel");
                                    case 1: ShowPlayerDialog(playerid, HOUSEMENU+28, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Enter House Using Password\nBreak In\nEnter House", "Select", "Cancel");
                                }
                            }
                            case 1: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In\nEnter House", "Select", "Cancel");
                        }
                        break;
                    }
                }
                if(!strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE) && hInfo[h][HouseValue] > 0 && GetPVarInt(playerid, "JustCreatedHouse") == 0)
                {
                    format(string, sizeof(string), HMENU_BUY_HOUSE, hInfo[h][HouseValue]);
                    ShowPlayerDialog(playerid, HOUSEMENU+4, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
                    break;
                }
            }
            if(pickupid == HousePickupInt[h])
            {
                switch(GetPVarInt(playerid, "HousePreview"))
                {
                    case 0: ExitHouse(playerid, h);
                    #if GH_HINTERIOR_UPGRADE == true
                    case 1:
                    {
                        GetPVarString(playerid, "HousePrevName", tmpstring, 50);
                        format(string, sizeof(string), HMENU_BUY_HINTERIOR, tmpstring, GetPVarInt(playerid, "HousePrevValue"));
                        ShowPlayerDialog(playerid, HOUSEMENU+17, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
                    }
                    #endif
                }
                break;
            }
        }
    }
    return 1;
}
#endif
stock Float:DistanceToPoint(Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2) return Float:floatsqroot(((X2 - X1) * (X2 - X1)) + ((Y2 - Y1) * (Y2 - Y1)) + ((Z2 - Z1) * (Z2 - Z1)));
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new string[400], _tmpstring[256], INI:file, filename[HOUSEFILE_LENGTH], h = GetPVarInt(playerid, "LastHouseCP"), amount = floatround(strval(inputtext));
    format(filename, sizeof(filename), FILEPATH, h);
    if(dialogid == HOUSEMENU && response)
    {
        switch(listitem)
        {
            case 0: ShowPlayerDialog(playerid, HOUSEMENU+19, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Set House For Sale\nCancel Active House Sale\nSell House", "Select", "Cancel");
            case 1:
            {
                #if GH_USE_HOUSESTORAGE == false
                    ShowInfoBoxEx(playerid, COLOUR_INFO, E_NO_HOUSESTORAGE);
                #else
                    #if GH_USE_WEAPONSTORAGE == true
                        ShowPlayerDialog(playerid, HOUSEMENU+18, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Money Storage\nWeapon Storage", "Select", "Cancel");
                    #else
                        ShowPlayerDialog(playerid, HOUSEMENU+10, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Deposit Money\nWithdraw Money\nCheck Balance", "Select", "Cancel");
                    #endif
                #endif
            }
            case 2: ShowPlayerDialog(playerid, HOUSEMENU+14, DIALOG_STYLE_INPUT, INFORMATION_HEADER, "Type In The New House Name Below:\n\nPress 'Cancel' To Cancel", "Done", "Cancel");
            case 3: ShowPlayerDialog(playerid, HOUSEMENU+13, DIALOG_STYLE_INPUT, INFORMATION_HEADER, "Type In The New House Password Below:\nLeave The Box Empty If You Want To Keep Your Current House Password.\nPress 'Remove' To Remove The House Password.", "Done", "Remove");
            case 4:
            {
                #if GH_HINTERIOR_UPGRADE == true
                    ShowPlayerDialog(playerid, HOUSEMENU+16, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Preview House Interior\nBuy House Interior", "Select", "Cancel");
                #else
                    ShowPlayerDialog(playerid, HOUSEMENU+24, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Open House For Visitors\nClose House For Visitors", "Select", "Cancel");
                #endif
            }
            case 5:
            {
                #if GH_HINTERIOR_UPGRADE == true
                    ShowPlayerDialog(playerid, HOUSEMENU+24, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Open House For Visitors\nClose House For Visitors", "Select", "Cancel");
                #else
                new tmpcount = 1, total = (CountPlayersInHouse(h) - 1);
                if(CountPlayersInHouse(h) == 0) return ShowInfoBoxEx(playerid, COLOUR_SYSTEM, E_NONE_IN_HOUSE);
                CMDSString = "";
                foreach(Player, i)
                {
                    if(!IsPlayerInHouse(i, h)) continue;
                    if(playerid == i) continue;
                    if(tmpcount == total)
                    {
                        format(_tmpstring, sizeof(_tmpstring), "{00BC00}%d.\t{FFFF2A}%s in %s", tmpcount, pNick(i), i);
                    }
                    else format(_tmpstring, sizeof(_tmpstring), "{00BC00}%d.\t{FFFF2A}%s (%d)\n", tmpcount, pNick(i), i);
                    strcat(CMDSString, _tmpstring);
                    tmpcount++;
                }
                ShowPlayerDialog(playerid, HOUSEMENU+25, DIALOG_STYLE_LIST, INFORMATION_HEADER, CMDSString, "Select", "Cancel");
                #endif
            }
            case 6:
            {
                #if GH_HINTERIOR_UPGRADE == true
                new tmpcount = 1, total = (CountPlayersInHouse(h) - 1);
                if(CountPlayersInHouse(h) == 0) return ShowInfoBoxEx(playerid, COLOUR_SYSTEM, E_NONE_IN_HOUSE);
                CMDSString = "";
                foreach(Player, i)
                {
                    if(!IsPlayerInHouse(i, h)) continue;
                    if(playerid == i) continue;
                    if(tmpcount == total)
                    {
                        format(_tmpstring, sizeof(_tmpstring), "{00BC00}%d.\t{FFFF2A}%s in %s", tmpcount, pNick(i), i);
                    }
                    else format(_tmpstring, sizeof(_tmpstring), "{00BC00}%d.\t{FFFF2A}%s (%d)\n", tmpcount, pNick(i), i);
                    strcat(CMDSString, _tmpstring);
                    tmpcount++;
                }
                ShowPlayerDialog(playerid, HOUSEMENU+25, DIALOG_STYLE_LIST, INFORMATION_HEADER, CMDSString, "Select", "Cancel");
                #else
                    ShowPlayerDialog(playerid, HOUSEMENU+27, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House Alarm\t\t$"#HUPGRADE_ALARM"\nBuy Security Camera\t\t$"#HUPGRADE_CAMERA"\nBuy House Security Dog\t$"#HUPGRADE_DOG"\nBuy Better Houselock\t\t$"#HUPGRADE_UPGRADED_HLOCK"", "Select", "Cancel");
                #endif
            }
            case 7: ShowPlayerDialog(playerid, HOUSEMENU+27, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House Alarm\t\t$"#HUPGRADE_ALARM"\nBuy Security Camera\t\t$"#HUPGRADE_CAMERA"\nBuy House Security Dog\t$"#HUPGRADE_DOG"\nBuy Better Houselock\t\t$"#HUPGRADE_UPGRADED_HLOCK"", "Select", "Cancel");
        }
        return 1;
    }
And also, if this house system has too many bugs, do you recommend a one that works good, that has the beacon system you walk into when buying/entering. I dont like the green house icon code. I much prefer the red circle you can walk into. Thanks
Reply
#4

Ok garsino solved it for me personally and it wasnt a OnDialogResponse issue. If u are having same problem, PM me
Reply
#5

Please help me I have the same problem ... e-mail borjan_98bt@hotmail.com or pm me here how to solve it !
Reply
#6

Quote:
Originally Posted by Coz
View Post
Ok garsino solved it for me personally and it wasnt a OnDialogResponse issue. If u are having same problem, PM me
Wouldn't it be better if you just posted the part of the code he fixed for you here and explain what he changed to help other people out down the track?
Reply
#7

Guys I found the solution. Your OnDialogResponse callback has to return 0 and you have to put "GarHouse" first in your server.cfg where you define which filterscripts you gonna use !
ex. filterscripts GarHouse [all_your_other_FS]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)