House System Problem
#2

Your biggest problem is that you are comparing hLockCode to the entered text for EVERY HOUSE. Before even performing any checks, you should have a function that obtains the closest house. Here is an example:

pawn Код:
stock GetClosestHouseID(playerid)
{
    new ClosestHouse;
    new Float:ClosestDistance = 10000000;
    for (new i = 1; i<MAX_HOUSES; i++)
    {
        new Float:Distance = GetPlayerDistanceFromPoint(playerid,HouseInfo[i][XPos],HouseInfo[i][YPos],HouseInfo[i][ZPos]);
        if(Distance<ClosestDistance)
        {
            ClosestDistance = Distance;
            ClosestHouse = i;
        }
    }
    return ClosestHouse;
}
The way the script is set up now, the message after "else" is sent every time that the hLockCode does not match the input text. If you have 500 houses, and only house id 400 has that Lock Code, you will get 399 messages before the loop is broken.

Also, I would perform the hHouseLocked check before the hLockCode check. It is easier for the server to compare two integers (0 or 1) than compare two strings.
Reply


Messages In This Thread
House System Problem - by MadSkillz - 06.06.2012, 21:09
Re: House System Problem - by Yuryfury - 07.06.2012, 01:43
Re: House System Problem - by MadSkillz - 07.06.2012, 08:54
Re: House System Problem - by MadeMan - 07.06.2012, 09:01
Re: House System Problem - by MadSkillz - 07.06.2012, 09:16
Re: House System Problem - by MadeMan - 07.06.2012, 09:24
Re: House System Problem - by MadSkillz - 07.06.2012, 09:25

Forum Jump:


Users browsing this thread: 1 Guest(s)