20.07.2016, 23:40
Answer to your question (in your other topic)
@offtopic
I am just wondering about the usage of cos and sin in IsPlayerNearWater if you only check for North / East / South / West
Also if its a small loop you should unroll it for speed
You should add a IsPlayerNearWater check in /fish if it isn't already there
@offtopic
I am just wondering about the usage of cos and sin in IsPlayerNearWater if you only check for North / East / South / West
Also if its a small loop you should unroll it for speed
PHP код:
IsPlayerNearWater(playerid) {
const
Float: THRESHOLD = 20.0,
Float: RADIUS = 4.0;
new
Float: x,
Float: y,
Float: z;
if(GetPlayerPos(playerid, x, y, z) && (-THRESHOLD < z < THRESHOLD)) {
MapAndreas_FindZ_For2DCoord(x, y + RADIUS, z);
if(z == 0.0) return true;
MapAndreas_FindZ_For2DCoord(x + RADIUS, y, z);
if(z == 0.0) return true;
MapAndreas_FindZ_For2DCoord(x, y - RADIUS, z);
if(z == 0.0) return true;
MapAndreas_FindZ_For2DCoord(x - RADIUS, y, z);
if(z == 0.0) return true;
}
return false;
}