GarHouse V2.0 Buy button issue
#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


Messages In This Thread
GarHouse V2.0 Buy button issue - by Coz - 06.05.2013, 04:18
Re: GarHouse V2.0 Buy button issue - by ReV. - 06.05.2013, 04:23
Re: GarHouse V2.0 Buy button issue - by Coz - 06.05.2013, 15:26
Re: GarHouse V2.0 Buy button issue - by Coz - 07.05.2013, 22:52
Re: GarHouse V2.0 Buy button issue - by Najdobar - 22.01.2014, 21:20
Re: GarHouse V2.0 Buy button issue - by Flake. - 22.01.2014, 22:25
Re: GarHouse V2.0 Buy button issue - by Najdobar - 23.01.2014, 09:28

Forum Jump:


Users browsing this thread: 4 Guest(s)