03.06.2014, 19:23
Good morning.
I have a function that checks if a player is in that position or not, here it is:
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:
++
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;
}
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;
}