Message repeats itself over and over.
#1

I created a buyhouse command. Now it messes up and spams them when they are not at a house. PLease help.


Код:
        {
            format(string, sizeof(string), "SERVER:{FFFFFF} You are not near a buyable house!");
            SendClientMessage(playerid, GREY, string);
        }
Reply
#2

you probably put it on the timer or OnPlayerUpdate.
Reply
#3

Quote:
Originally Posted by Dziugsas
Посмотреть сообщение
you probably put it on the timer or OnPlayerUpdate.
Well it's ment to be so that if you're not at the house and I've got this:
Код:
if(IsPlayerInRangeOfPoint(i, 1.5, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hOutsideInt] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hOutsideVir])
and that is the end.
Reply
#4

where you put this line of code?Under which calback?
Reply
#5

Quote:
Originally Posted by Dziugsas
Посмотреть сообщение
where you put this line of code?Under which calback?
under the command: buyhouse.
Reply
#6

can you show me whole command?And tell me where you place the cmd?
Reply
#7

Quote:
Originally Posted by Dziugsas
Посмотреть сообщение
can you show me whole command?And tell me where you place the cmd?
sure:

Код:
command(buyhouse, playerid, params[])
{
	new string[128];
    new pName[MAX_PLAYER_NAME]; //For the player's name - For the house
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME); //Get the name of the player and store it in pName
    for(new i = 0; i < MAX_HOUSES; i++) //Last time I'm gonna say it: Loop through all the houses
    {
        if(IsPlayerInRangeOfPoint(i, 1.5, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hOutsideInt] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hOutsideVir]) //Is player near house entrance, and if player is in interior of that house + virtual world (Last time I said this too!)
		{
            if(GetPlayerMoney(playerid) < HouseInfo[i][hPrice]) return SendClientMessage(playerid, GREY, "SERVER:{FFFFFF} You don't have enough money for this house!"); //Has player too less money? Send him a message!
			if(HouseInfo[i][hOwned]) return SendClientMessage(playerid, GREY, "SERVER:{FFFFFF} You are not near a buyable house!");
            HouseInfo[i][hOwned] = true; //The house is owned, where the player used /buyhouse
            strmid(HouseInfo[i][hOwner], pName, 0, false, strlen(pName)); //Put the players name into the "hOwner" of the house
            GivePlayerMoney(playerid, -HouseInfo[i][hPrice]); //Remove some money of the player.. The value of the house
            SendClientMessage(playerid, GREY, "House bought!"); //Send the player an message.
            SaveHouse(i);
            LoadHouseVisual(i, true); //Load House Visual. Now, I've added ', true': It will RELOAD now!
            return 1;
        }
        else
        {
            format(string, sizeof(string), "SERVER:{FFFFFF} You are not near a buyable house!");
            SendClientMessage(playerid, GREY, string);
        }
    }
    return 1;
}
Reply
#8

if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hOutsideInt] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hOutsideVir])

try this
Reply
#9

What i mean is that this code below gets repeated over and over.

Код:
{
            format(string, sizeof(string), "SERVER:{FFFFFF} You are not near a buyable house!");
            SendClientMessage(playerid, GREY, string);
        }
Reply
#10

Yes, it gets repeated because you are sending the message under check for every house. Create a variable, let's say id, set it to -1 and go through the loop. If the player is near the house, change the id. After the loop check if the id is equal to -1, if it is, send the message that player is not near any house.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)