Function does not always walking
#1

Good morning.

I have a function that checks if a player is in that position or not, here it is:

pawn Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        tempposx = (oldposx -x);
        tempposy = (oldposy -y);
        tempposz = (oldposz -z);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) return 1;
    }
    return 0;
}
However, from time to time for example the following case it does not work, and I have no idea why it does not work.

Here's how I use it:

pawn Код:
if(strcmp(subcmd, "appart", true) == 0)
        {
            for(new houseid = 0; houseid < totalhouses; houseid++)
            {
                if(PlayerToPoint(3, playerid, HouseInfo[houseid][hEntrancex], HouseInfo[houseid][hEntrancey], HouseInfo[houseid][hEntrancez]))
                {
                    if(HouseInfo[i][hAppart] == 0)
                    {
                        HouseInfo[i][hAppart] = 1;
                        UpdateHouseLabel(houseid, false);
                        UpdateHousePickup(houseid);
                    }
                    else
                    {
                        HouseInfo[i][hAppart] = 0;
                        UpdateHouseLabel(houseid, false);
                        UpdateHousePickup(houseid);
                    }
                }
            }
            return 1;
        }
++
Reply


Messages In This Thread
Function does not always walking - by TheSy - 03.06.2014, 19:23
Re: Function does not always walking - by KevinPRINCE - 03.06.2014, 19:27
Re: Function does not always walking - by TheSy - 03.06.2014, 19:47
Re: Function does not always walking - by TheSy - 03.06.2014, 20:05
Re: Function does not always walking - by KevinPRINCE - 03.06.2014, 20:17

Forum Jump:


Users browsing this thread: 4 Guest(s)