Help me with this
#1

Hello,

I made a command that someone has to type a address from a house to buy the house,
but as soon as you buy the house it spams the chat with

Код:
[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

[16:50:51] You bought the house with address 4th Palin Street for $0.

x500
pawn Код:
command(buyproperty, playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 6, 355.0121,171.4519,1025.7891))
    {
        new Usage[128], Address[128], string[128];
        if(sscanf(params, "sz", Usage, Address))
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /buyproperty [usage] [address]");
            SendClientMessage(playerid, GREY, "Usage: House, Business");
        }
        else
        {
            if(strcmp(Usage, "house", true) == 0)
            {
                if(Player[playerid][House] == 0)
                {
                    for(new h = 0; h < sizeof(Houses); h++)
                    {
                        if(!strcmp(Houses[h][hAddress], Address, true))
                        {
                            if(strcmp(Houses[h][hOwner], "Nobody", true) == 0)
                            {
                                if(Houses[h][HousePrice] == -1)
                                {
                                    SendClientMessage(playerid, WHITE, "This house isn't purchasable.");
                                }
                                else
                                {
                                    if(Player[playerid][Hotel] == 0)
                                    {
                                        if(Player[playerid][Money] >= Houses[h][HousePrice])
                                        {
                                            Player[playerid][Money] -= Houses[h][HousePrice];
                                            GivePlayerMoney(playerid, -Houses[h][HousePrice]);
                                            format(Houses[h][hOwner], 128, "%s", GetName(playerid));
                                            format(string, sizeof(string), "You bought the house with address %s for $%d.", Address, Houses[h][HousePrice]);
                                            SendClientMessage(playerid, ADMINBLUE, string);
                                            Player[playerid][House] = h;
                                            DestroyDynamicPickup(Houses[h][HPickupID]);
                                            Houses[h][HPickupID] = CreateDynamicPickup(1318, 23, Houses[h][hExteriorX], Houses[h][hExteriorY], Houses[h][hExteriorZ], 0, -1, -1, 150.0);
                                            SaveHouse(h);
                                            SavePlayerData(playerid);
                                        }
                                        else
                                        {
                                            SendClientMessage(playerid, WHITE, "You do not have enough money to purchase this house.");
                                        }
                                    }
                                    else
                                    {
                                        SCM(playerid, RED, "You already live in a hotel");
                                    }
                                }
                            }
                            else
                            {
                                SendClientMessage(playerid, WHITE, "Sorry, this house is already bought!");
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, WHITE, "Sorry, but this address is not correct.");
                        }
                    }
                }
                else
                {
                    SendClientMessage(playerid, WHITE, "You already have a house, type /sellproperty house.");
                }
            }
        }
    }
    else
    {
        SCM(playerid, WHITE, "You are not at the property office");
    }
    return 1;
}
how to fix the spam?
Reply
#2

Try this:
pawn Код:
command(buyproperty, playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 6, 355.0121,171.4519,1025.7891))
    {
        new Usage[128], Address[128], string[128];
        if(sscanf(params, "sz", Usage, Address))
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /buyproperty [usage] [address]");
            SendClientMessage(playerid, GREY, "Usage: House, Business");
        }
        else
        {
            if(strcmp(Usage, "house", true) == 0)
            {
                if(Player[playerid][House] == 0)
                {
                    for(new h = 0; h < sizeof(Houses); h++)
                    {
                        if(!strcmp(Houses[h][hAddress], Address, true))
                        {
                            if(strcmp(Houses[h][hOwner], "Nobody", true) == 0)
                            {
                                if(Houses[h][HousePrice] == -1)
                                {
                                    SendClientMessage(playerid, WHITE, "This house isn't purchasable.");
                                }
                                else
                                {
                                    if(Player[playerid][Hotel] == 0)
                                    {
                                        if(Player[playerid][Money] >= Houses[h][HousePrice])
                                        {
                                            Player[playerid][Money] -= Houses[h][HousePrice];
                                            GivePlayerMoney(playerid, -Houses[h][HousePrice]);
                                            format(Houses[h][hOwner], 128, "%s", GetName(playerid));
                                            format(string, sizeof(string), "You bought the house with address %s for $%d.", Address, Houses[h][HousePrice]);
                                            SendClientMessage(playerid, ADMINBLUE, string);
                                            Player[playerid][House] = h;
                                            DestroyDynamicPickup(Houses[h][HPickupID]);
                                            Houses[h][HPickupID] = CreateDynamicPickup(1318, 23, Houses[h][hExteriorX], Houses[h][hExteriorY], Houses[h][hExteriorZ], 0, -1, -1, 150.0);
                                            SaveHouse(h);
                                            SavePlayerData(playerid);
                                            break;
                                        }
                                        else
                                        {
                                            SendClientMessage(playerid, WHITE, "You do not have enough money to purchase this house.");
                                        }
                                    }
                                    else
                                    {
                                        SCM(playerid, RED, "You already live in a hotel");
                                    }
                                }
                            }
                            else
                            {
                                SendClientMessage(playerid, WHITE, "Sorry, this house is already bought!");
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, WHITE, "Sorry, but this address is not correct.");
                        }
                    }
                }
                else
                {
                    SendClientMessage(playerid, WHITE, "You already have a house, type /sellproperty house.");
                }
            }
        }
    }
    else
    {
        SCM(playerid, WHITE, "You are not at the property office");
    }
    return 1;
}
Reply
#3

Gonna test it now thanks
Reply
#4

Worked, you get rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)