27.01.2010, 13:24
Add this function first:
Then change a little your code:
Код:
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); //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz); if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { return 1; } } return 0; }
Код:
public isPlayerInArea() { new Float:X, Float:Y, Float:Z; for(new i=0; i < MAX_PLAYERS; i++) { if (PlayerToPoint(25.0(for example its the cover distance), i, x(the x coord), y(the x coord), z(the z coord)){ SetPlayerHealth(i, 0); } } }