SA-MP Forums Archive
Detect edge of area - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Detect edge of area (/showthread.php?tid=465053)



Detect edge of area - xqz - 20.09.2013

Hello!

I'm trying to do some objects if player is near of edge of area.


It's mean;


+____+
|.........|
|.........|
|.........|im stay here
|____ |


How to detect these point in range ~10meters about me along to border?


I made this code:

Код:
forward omg(playerid);
public omg(playerid)
{
new Float:asd[3];
GetPlayerPos(playerid,asd[0],asd[1],asd[2]);
for(new id=0; id<MAX_AREAS; id++)
{
new asd1 = floatround(floatsub(Area_Table[id][areamaxX] ,Area_Table[id][areaminX]));
     new asd3 = floatround(floatsub(Area_Table[id][areamaxY] ,Area_Table[id][areaminY]));
for(new i=0; i<asd1/2; i++)
{
   if(IsPlayerInRangeOfPoint(playerid,10.0,Area_Table[id][areaminX]+(i*2),Area_Table[id][areaminY],asd[2])){
   CreateDynamicObject(1318,Area_Table[id][areaminX]+(i*2),Area_Table[id][areaminY],asd[2],0,0,0);
            SendClientMessage(playerid,-1,"Blisko!");}
}
for(new i=0; i<asd3/2; i++)
{
   if(IsPlayerInRangeOfPoint(playerid,10.0,Area_Table[id][areaminX],Area_Table[id][areamaxY]-(i*2),asd[2])){
   CreateDynamicObject(1318,Area_Table[id][areaminX],Area_Table[id][areamaxY]-(i*2),asd[2],0,0,0);
            SendClientMessage(playerid,-1,"Blisko!");}
}
for(new i=0; i<asd1/2; i++)
{
   if(IsPlayerInRangeOfPoint(playerid,10.0,Area_Table[id][areamaxX]-(i*2),Area_Table[id][areamaxY],asd[2])){
   CreateDynamicObject(1318,Area_Table[id][areamaxX]-(i*2),Area_Table[id][areamaxY],asd[2],0,0,0);
            SendClientMessage(playerid,-1,"Blisko!");}
}
for(new i=0; i<asd3/2; i++)
{
   if(IsPlayerInRangeOfPoint(playerid,10.0,Area_Table[id][areamaxX],Area_Table[id][areaminY]+(i*2),asd[2])){
   CreateDynamicObject(1318,Area_Table[id][areamaxX],Area_Table[id][areaminY]+(i*2),asd[2],0,0,0);
            SendClientMessage(playerid,-1,"Blisko!");}
}
}
return 1;
}
But it's not optimally. Is it possible to do that more optymized?


Re: Detect edge of area - xqz - 21.09.2013

delete pls