Help with house pickup
#1

Guys i have PPC_House script and i am getting a problem with house pickup i made a client message when house is not owned by someone it will say this property is for sale and if owned by someone then this property is owned but when i go on house id 1's pickup it showing perfect and when i go on 2 id's house it spams the message about property info here is the code and function


pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{

    // Setup local variables

    // Check if the player isn't inside a vehicle (the player must be on foot to use this command)
    if (GetPlayerVehicleSeat(playerid) == -1)
    {
        new HouseID;
        for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
        {
           
            // Check if the house exists
            if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
            {
                // Check if the player is in range of the house-pickup
                if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
                {
                    // Check if the house isn't owned yet
                    if (AHouseData[HouseID][Owned] == false)
                    {
                        if(isOnHouse[playerid] == 0)
                        {
                        // Check if the player can afford this house
                        new string[180];

                        format(string, sizeof(string), "~g~Available $%i",AHouseData[HouseID][HousePrice]);
                        GameTextForPlayer(playerid, string, 4000, 3);

                        format(string, sizeof(string), "This property is for sale at a cost of $%i. type /buyprop to buy it",AHouseData[HouseID][HousePrice]);
                        SendClientMessage(playerid,0xFFFF00AA,string);
                        isOnHouse[playerid] = 1;
                        }
                       
                    }
                    else
                    {
                         if(isOnHouse[playerid] == 0)
                         {
                         new string[180],File2[200],string2[200];
                         format(File2, sizeof(File2), "Saves/%s.ini", AHouseData[HouseID][Owner]);

                         if(dini_Int(File2,"Month") == 1) { dtext = "January"; }
                         else if(dini_Int(File2,"Month") == 2) { dtext = "February"; }
                         else if(dini_Int(File2,"Month") == 3) { dtext = "March"; }
                         else if(dini_Int(File2,"Month") == 4) { dtext = "April"; }
                         else if(dini_Int(File2,"Month") == 5) { dtext = "May"; }
                         else if(dini_Int(File2,"Month") == 6) { dtext = "June"; }
                         else if(dini_Int(File2,"Month") == 7) { dtext = "July"; }
                         else if(dini_Int(File2,"Month") == 8) { dtext = "August"; }
                         else if(dini_Int(File2,"Month") == 9) { dtext = "September"; }
                         else if(dini_Int(File2,"Month") == 10) { dtext = "October"; }
                         else if(dini_Int(File2,"Month") == 11) { dtext = "November"; }
                         else if(dini_Int(File2,"Month") == 12) { dtext = "December"; }


                         if(dini_Int(File2,"Day") == 1) { ddtext = "1st"; }
                         else if(dini_Int(File2,"Day") == 2) { ddtext = "2nd"; }
                         else if(dini_Int(File2,"Day") == 3) { ddtext = "3rd"; }
                         else if(dini_Int(File2,"Day") == 4) { ddtext = "4th"; }
                         else if(dini_Int(File2,"Day") == 5) { ddtext = "5th"; }
                         else if(dini_Int(File2,"Day") == 6) { ddtext = "6th"; }
                         else if(dini_Int(File2,"Day") == 7) { ddtext = "7th"; }
                         else if(dini_Int(File2,"Day") == 8) { ddtext = "8th"; }
                         else if(dini_Int(File2,"Day") == 9) { ddtext = "9th"; }
                         else if(dini_Int(File2,"Day") == 10) { ddtext = "10th"; }
                         else if(dini_Int(File2,"Day") == 11) { ddtext = "11th"; }
                         else if(dini_Int(File2,"Day") == 12) { ddtext = "12th"; }
                         else if(dini_Int(File2,"Day") == 13) { ddtext = "13th"; }
                         else if(dini_Int(File2,"Day") == 14) { ddtext = "14th"; }
                         else if(dini_Int(File2,"Day") == 15) { ddtext = "15th"; }
                         else if(dini_Int(File2,"Day") == 16) { ddtext = "16th"; }
                         else if(dini_Int(File2,"Day") == 17) { ddtext = "17th"; }
                         else if(dini_Int(File2,"Day") == 18) { ddtext = "18th"; }
                         else if(dini_Int(File2,"Day") == 19) { ddtext = "19th"; }
                         else if(dini_Int(File2,"Day") == 20) { ddtext = "20th"; }
                         else if(dini_Int(File2,"Day") == 21) { ddtext = "21th"; }
                         else if(dini_Int(File2,"Day") == 22) { ddtext = "22th"; }
                         else if(dini_Int(File2,"Day") == 23) { ddtext = "23th"; }
                         else if(dini_Int(File2,"Day") == 24) { ddtext = "24th"; }
                         else if(dini_Int(File2,"Day") == 25) { ddtext = "25th"; }
                         else if(dini_Int(File2,"Day") == 26) { ddtext = "26th"; }
                         else if(dini_Int(File2,"Day") == 27) { ddtext = "27th"; }
                         else if(dini_Int(File2,"Day") == 28) { ddtext = "28th"; }
                         else if(dini_Int(File2,"Day") == 29) { ddtext = "29th"; }
                         else if(dini_Int(File2,"Day") == 30) { ddtext = "30th"; }
                         else if(dini_Int(File2,"Day") == 31) { ddtext = "31th"; }
                            // Let the player know that this house is already owned by a player

                         format(string, sizeof(string), "~b~Property Owned");
                         GameTextForPlayer(playerid, string, 4000, 3);
                         format(string, sizeof(string), "Welcome to %s's home.",AHouseData[HouseID][Owner]);
                         SendClientMessage(playerid,0xFFFF00AA,string);
                         format(string2,sizeof(string2),"%s was last active on %s %s %d.", AHouseData[HouseID][Owner],ddtext,dtext,dini_Int(File2,"Year"));
                         SendClientMessage(playerid,0xFFFFFFFF,string2);
                         isOnHouse[playerid] = 1;
                         }
                    }
                }
            }
        }

    }
    else
        SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You can't buy a house when you're inside a vehicle");

    // Let the server know that this was a valid command
    return 1;
}

forward OnHousePickupEx(playerid);
public OnHousePickupEx(playerid)
{
    for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
        {
                return 1;
        }
        else
        {
            isOnHouse[playerid] = 0;
        }
    }
    return 1;
}
// public OnFilterScriptInit()
SetTimer("OnHousePickupEx",100,1);
Reply
#2

How many times do I need to say this, get the "HouseID" inside the loop, then do all the "if owned" checks or w.e outside.. The loop is the reason messages get spammed, try it for HouseId 499 or whatever is MAX_HOUSES-1, it will print that many messages to the client.
Reply
#3

can you set this code with what you want to say? i can't understand
Reply
#4

If you can't understand this yourself, then you shouldn't be helping others either, search!
No spoon feeding you code! I'll put this in most vague words I can think of:
In the "for" loop when you get to "IsPlayerInRangeOfPoint" check "break;" out of the "for" loop,
OUTSIDE the loop (meaning not in it) do your other "if" checks, like if the house is owned, etc.

Protip: stop using f#kin Dini!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)