02.11.2011, 13:19
Как сделать проверку на нахождения игрока в Los Santos, San Fierro или Las Venturas ??
stock PlayerInZone(playerid, Float: minx, Float: miny, Float: maxx, Float: maxy, Float: minz, Float: maxz) { new Float: x, Float: y, Float: z; GetPlayerPos(playerid, x, y, z); if(x > minx && x < maxx && y > miny && y < maxy && z > minz && z < maxz) { return 1; } else { return 0; } }
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; }
Ещё вариант:
Код:
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; } |
stock IsPlayerInRangeOfCube(playerid,Float:x,Float:y,Float:z,Float:rad)
{
new Float:px,Float:py,Float:pz;
GetPlayerPos(playerid,px,py,pz);
if(floatabs(px-x)>rad)return 0;
if(floatabs(py-y)>rad)return 0;
if(floatabs(pz-z)>rad)return 0;
return 1;
}
stock IsPlayerInRangeOfParallepiped(playerid,Float:x,Float:y,Float:z,Float:radx,Float:rady,Float:radz)
{
new Float:px,Float:py,Float:pz;
GetPlayerPos(playerid,px,py,pz);
if(floatabs(px-x)>radx)return 0;
if(floatabs(py-y)>rady)return 0;
if(floatabs(pz-z)>radz)return 0;
return 1;
}
stock ConvertMMCToCentralC(filename[],Float:minX,Float:maxX,Float:minY,Float:maxY,Float:minZ,Float:maxZ,comment[])
{
new str[128];
format(str,128,"%s_list.txt",filename);
new File:f=fopen(str,io_append);
if(maxX-minX == maxY-minY && maxX-minX==maxZ-minZ)
{
format(str,128,"IsPlayerInRangeOfCube(playerid,%f,%f,%f,%f);//%s\n",(maxX+minX)/2,(maxY+minY)/2,(maxZ+minZ)/2,maxX-minX,comment);
}
else
{//
format(str,128,"IsPlayerInRangeOfParallepiped(playerid,%f,%f,%f,%f,%f,%f);//%s\n",(maxX+minX)/2,(maxY+minY)/2,(maxZ+minZ)/2,maxX-minX,maxY-minY,maxZ-minZ,comment);
}
fwrite(f,str);
fclose(f);
}