Does not get that I am at a certain location.
#1

First of all, thank you for reading this.

Alright, I've been creating my own house system and it used to work perfectly but now it does not. ( Still at the beginning though ) When I type /buyhouse it constantly tells me I am not at any house.

pawn Код:
if (strcmp("/buyhouse", cmdtext, true, 10) == 0)
    {
        for( new i = 0; i <= MAX_HOUSES; i++)
        {
            format(file, sizeof(file), "House_%d.ini", i );
            x = dini_Float(file, "enterX");
            y = dini_Float(file, "enterY");
            z = dini_Float(file, "enterZ");
            forSale = dini_Get(file, "ForSale");
            if(IsPlayerInRangeOfPoint(playerid, 3.0, x ,y ,z ))
            {
                if(strval(forSale) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: This house is not for sale!");
                GetPlayerName(playerid, name, sizeof(name));
                if(strval(name) == strval(dini_Get(file, "Owner"))) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You may not buy your own house!");
                SendClientMessage(playerid, 0xFFFFFFFF, "gsdgsdgsdsdgsdgsdgsdg");
                atHouse[playerid] = true;
            }
            if(atHouse[playerid] == false) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You are not at any house.");
        }
        return 1;
    }
NOTE: It currently has no price involved, as I test every line I add and now it does not work.
Reply
#2

EDIT: Your loop goes through all the houses, which is the source of your bug. You have to get the ID of the current house, use some stock or so. (e.g. GetHouseID(playerid)).
Reply
#3

Quote:
Originally Posted by zxc1
Посмотреть сообщение
Your cmd works like the following:
Gets the XYZ of the house, check if the player at the entrance, if yes continues into the brackets and with the code at the same time.
So you have to delay the checking, which is kinda not needed mess. I recommend you to delete the variable "atHouse". and return simply:
pawn Код:
else return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You are not at any house.");
But it's up to you.
It would send it at the amount of MAX_HOUSES, example: MAX_HOUSES = 50

You are not at any house x50 will be sent to the same player. That's why I am using a bool.
Reply
#4

I see. I will do that. I will reply here in a few hours after doing it. ( Not going to be at home for a while )

Thank you.
Reply
#5

I can not think of a way to do it as my mind is stuck in the same way as I done it above, getting the coordinates and if the player is at one of those houses it will set a certain bool to true etc..

Could you suggest any way to do it?

EDIT: I have this on my OnGameModeInit

pawn Код:
for( new i = 0; i <= MAX_HOUSES; i++)
    {
        format(file, sizeof(file), "House_%d", i);
        if(fexist(file))
        {
            x = dini_Float(file, "EnterX");
            y = dini_Float(file, "EnterY");
            z = dini_Float(file, "EnterZ");
            HouseInfo[i][EnterX] = x;
            HouseInfo[i][EnterY] = y;
            HouseInfo[i][EnterZ] = z;
        }
    }
But it still does the same problem.
Reply
#6

I've just noticed that I used dini_Float(file, "enterX"); instead of dini_Float(file, "EnterX""); although it did not change a single thing.
Reply
#7

Okay, so I made the following stock just to check if it works, and.. it does not:
pawn Код:
stock GetHouseID(playerid)
{
    for(new i = 0; i <= MAX_HOUSES; i++)
    {
        format(file, sizeof(file), "House_%d.ini", i);
        if(fexist(file))
        {
            x = dini_Float(file, "EnterX");
            y = dini_Float(file, "EnterY");
            z = dini_Float(file, "EnterZ");
            if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
            {
                                           format(str, sizeof(str), "%d", i); // Debugging.
                SendClientMessage(playerid, 0xFFFFFFFF, str); // Debugging.
            }
        }
    }
    return 1;
}
It just does not send the message as I used the same form as I used in /buyhouse. My mind is stuck in that form, I can not think about any other way. May anyone help me out with this?
Reply
#8

Okay, I modified it a bit and now it SendClientMessage the ID of the house as I wanted it to do. I'll work on the buyhouse and reply here as soon as I'm done. Thank you.
Reply
#9

One little question, how may I know if a player's name is the same as a certain pre-choesn name?
Simple words.. comparing two strings. I tried using strcmp but it kept saying that the player's name is the same as the chosen name but it was not.
Reply
#10

I can't think of any other way than 'strcmp'.
Perhaps you didn't changed the 'bool:ignorecase'.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)