Jump to content

návod Užitečné funkce


Recommended Posts

Ahoj, zakladam tohle tema protože se opičim po forum.sa-mp.com :) dejme sem funkce ktere se mužou nekomu hodit...
Klidně nemusi byt vaše ale aspon napište autora...

GetClosestVehicle (ZiskatNejbližšíAuto)

stock GetClosestVehicle(playerid) //By Darkrealm (edited by Gabrie "Larcius" Cordes)
{
if(IsPlayerConnected(playerid) && IsVehicleConnected(0))
{
new closestvehicle=0;
new Float:closestdist=GetDistanceToVehicle(playerid,0);
for(new vehicleid=0; vehicleid {
new Float:dist = GetDistanceToVehicle(playerid,vehicleid);
if ((dist < closestdist))
{
closestdist = dist;
closestvehicle = vehicleid;
}
}
return closestvehicle;
}
return -1;
}

stock GetDistanceBetweenPlayers(playerid, playeridnr2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playeridnr2,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+ floatpower(floatabs(floatsub(y2,y1)),2)+ floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}
stock GetClosestPlayer(playerid)
{
new Float:cdist, targetid = -1;
for (new i = 0; i < MAX_SLOTS; i++)
{
if (IsPlayerConnected(i) && playerid != i && (targetid < 0 || cdist > GetDistanceBetweenPlayers(playerid, i)))
{
targetid = i;
cdist = GetDistanceBetweenPlayers(playerid, i);
}
}
return targetid;
}
;>

 

Návod označen jako platný

Ten to návod byl označen jako platný.Návod může být kdykoli označen jako nevhodný či neplatný

Link to comment
Share on other sites

  • Replies 61
  • Created
  • Last Reply

Top Posters In This Topic

Tato funkce vám zjistí ID bota podle jména. ( vrací ID bota )

stock NPC(botnick[]){
if(strlen(botnick) == 0) return 1;
new id;
for(new i=0;i		if(IsPlayerConnected(i) && IsPlayerNPC(i)){
		new botname[MAX_PLAYER_NAME];
		GetPlayerName(i, botname, MAX_PLAYER_NAME);
		if(strcmp(botname, botnick, false) == 0){
		    id = i;
		    break;
		}
	}
}
return id;
}

příklad použití funkce v podmínce:

if(IsPlayerInAnyVehicle(NPC("Bot1")) // pokud je bot s jménem "Bot1" ve vozidle

Link to comment
Share on other sites

  • 1 month later...

Tady máš některé mé funkce ...:

 

takže funkce GivePlayerWantedLevel:

stock GivePlayerWantedLevel(playerid, level)
{
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + level);
return 1;
}

aneb touto funkcí můžeme přidat hráči WL napříkad takto:

GivePlayerWantedLevel(playerid, 9); // tímto přidáme hráči WantedLevel + 9.


funkce GivePlayerHealth:

stock GivePlayerHealth(playerid, Float:zdravi)
{
new Float:HP
SetPlayerHealth(playerid, GetPlayerHealth(playerid,HP) + zdravi);
return 1;
}

aneb touto funkcí můžeme přidat hráči zdraví napříkad takto:

GivePlayerHealth(playerid, 9); // tímto přidáme hráči zdraví + 9.


funkce GivePlayerDrunkLevel:

stock GivePlayerDrunkLevel(playerid, level)
{
SetPlayerDrunkLevel(playerid, GetPlayerDrunkLevel(playerid) + level);
return 1;
}

aneb touto funkcí můžeme přidat hráči picí level napříkad takto:

GivePlayerDrunkLevel(playerid, 9); // tímto přidáme hráči zdraví + 9.


funkce GiveMoneyForAll:

stock GiveMoneyForAll(suma)
{
for(new s=0; s< 500; s++)
{
if(IsPlayerConnected(s))
{
GivePlayerMoney(s, suma);
}
}
return 1;
}

aneb touto funkcí můžeme přidat všem hráčům peníze takto:

GiveMoneyForAll(9); // tímto přidáme všem hráčům peníze + 9$.


funkce GiveWeaponForAll:

stock GiveWeaponForAll(weapon_id, slots)
{
for(new w=0; w< 500; w++)
{
if(IsPlayerConnected(w))
{
GivePlayerWeapon(w, weapon_id, slots);
}
}
return 1;
}

aneb touto funkcí přidáme danou zbran s danýma nábojema všem hráčům například takto:

GiveWeaponForAll(30,100); // tímto přidáme všem hráčům zbran ID 30 s 100 slotama munice.

 

Link to comment
Share on other sites

  • 2 months later...

DisableBadWord(word[])

word[] - slovo které bude zakázáno (cenzurovano)

 

#define DisableBadword(%1) for(new i=0; i= i && a < i+strlen(%1)) text[a]='*'

 

misto text[a]='*' si mužete dat misto hvezdicky cokoli co se misto cenzurovaneho slova objevi

 

-- pon 19. dub 2010 16:04:41 --

 

hmm dobre!!

 

-----------------------------------------------------------------------------------

e42f6faf9221ade128e796a8dc40a1d93f48558a.jpg

 

 

nepište sem hmmm dobre, ale spíše piště také funkce!!

Link to comment
Share on other sites

Skore v Seznamu hracu "TAB"

 

Do public OnGameModeInit()

SetTimer("ScoreUpdate", 1000, true);

Pak nekam do modu

public ScoreUpdate()
{
for ( new i;i<200;i++)
{
SetPlayerScore(i,GetPlayerMoney(i));
}
}

Link to comment
Share on other sites

Tak sem pridám nejaké svoje funkcie možno niekomu pomôžu ;)

 

PortPlayer(playerid, car,interior,Float:x,Float:y,Float:z)

car - 1-port s autom 0-port bez auta

interior - ID interioru

Float:x,Float:y,Float:z - súradnice

forward PortPlayer(playerid, car,interior,Float:x,Float:y,Float:z);
public PortPlayer(playerid, car,interior,Float:x,Float:y,Float:z)
{
SetPlayerInterior(playerid,interior);
SetPlayerPos(playerid,Float:x,Float:y,Float:z);

if(car == 1) {
if(IsPlayerInAnyVehicle(playerid)) {
SetVehiclePos(GetPlayerVehicleID(playerid), Float:x,Float:y+2,Float:z);
PutPlayerInVehicle(playerid,GetPlayerVehicleID(playerid), 0);
}
}

return 1;
}

 

a funkcia na vytvorenie infoboxu

CreateBox(playerid, inputtext [])

inputtext - náš vlastný text

forward CreateBox(playerid, inputtext []);
public CreateBox(playerid,inputtext [])
{

  box = TextDrawCreate(17.000000, 142.000000,inputtext);
TextDrawBackgroundColor(box, 255);
TextDrawFont(box, 3);
TextDrawLetterSize(box, 0.519999, 1.200000);
TextDrawColor(box, -1);
TextDrawSetOutline(box, 0);
TextDrawSetProportional(box, 1);
TextDrawSetShadow(box, 1);
TextDrawUseBox(box, 1);
TextDrawBoxColor(box, 255);
TextDrawTextSize(box, 221.000000, 0.000000);


  TextDrawShowForPlayer(playerid, box);
SetTimerEx("skrybox",7000,0,"i",playerid);


return 1;
}
forward skrybox(playerid);
public skrybox(playerid)
{
TextDrawHideForPlayer(playerid, box);


}

 

a takto vyzerá náš infobox

testft.png

 

PS : môj prvý výtvor.

Link to comment
Share on other sites

Funkce která zjistí jestli se auto používá

stock IsVehicleInUse(vehicleid)
{
new temp;
for(new i=0;i	{
	if(IsPlayerConnected(i) && GetPlayerState(i)==PLAYER_STATE_DRIVER && GetPlayerVehicleID(i)==vehicleid)
	{
		temp++;
	}
}
if(temp > 0)
{
	return true;
}
else return false;
}

Link to comment
Share on other sites

taka kravinka...

 

stock

AddStaticVehicleInVirtualWorld(modelid,Float:spawn_x,Float:spawn_y,Float:spawn_z,Float:angle, color1, color2,vw)
  {
   SetVehicleVirtualWorld(AddStaticVehicle(modelid, spawn_x, spawn_y, spawn_z, angle, color1, color2), vw);
  }

je to staticke auto vo virtual worlde... inac ak date -1 tak to pojde vo vsetkych svetoch...

je do odo mna >D taka blbost...

Link to comment
Share on other sites

MultiLanguage Dialog

 

stock LanguageDialog(playerid, dialog, styldialog, czhlavicka[], enhlavicka[], czobsah[], enobsah[], cztlacidlo[], entlacidlo[], cztlacidlo2[],entlacidlo2[])
{
switch(Jazyk[playerid])
{
case 1: ShowPlayerDialog(playerid, dialog, styldialog, czhlavicka, czobsah, cztlacidlo, cztlacidlo2);
case 2: ShowPlayerDialog(playerid, dialog, styldialog, enhlavicka, enobsah, entlacidlo, entlacidlo2);
}
return 1;
}

 

- Je to jako normalní dialog až na to že je to rozdělene

 

Playerid : Znamená že se ukáže nějakému hráčovi kterého si vyberete

- Dialog : ID Dialogu kterého chcete vytvořit

- styldialog : Třeba dialog_style_list

- czhlavicka : Nádpis dialogu

- czobsah : Texty co budou v dialogu

- cztlacidlo : První Tlačítko

- cztlacidlo2 : Druhé Tlačítko

 

Druhá vrstva ( Anglická je stejna )

 

Copyright © 2010 - 2011 by B4RR0N & Nikdo jinný! xD

Link to comment
Share on other sites

  • 1 month later...

By MaverickCZE

 

Koukal jsem do apache.inc a jsou tam některé zajímavé stocky tak sem dám jen pár a zbytek si vemte samy - http://www.pawno.cz/include/apache.inc

 


 

A_SPMI - Zabranuje vytvareni MapIcon pro neexistujici hrace.

 

stock A_SPMI(playerid,iconid,Float:x,Float:y,Float:z,typ)
{
 if(IsPlayerConnected(playerid)) SetPlayerMapIcon(playerid,iconid,x,y,z,typ,0);
}

 

 

stock GetVehicleType - Zjistí jestli sedíte v autě, letadle, na motorce a vrátí danou hodnotu.

 

stock GetVehicleType(vehicleid) 
{
new model = GetVehicleModel(vehicleid);

if(model > 399 && model < 613)
{
switch(model)
{
case 590,569,537,538,570,449: return TYPE_TRAIN;
case 481,509,510,581,462,521,463,522,461,448,468,586: return TYPE_BIKES;
case 592,577,511,548,512,593,425,417,487,553,488,497,563,476,447,519,460,469,513,520: return TYPE_AIRPLANE;
case 472,473,493,595,484,430,453,452,446,454: return TYPE_BOATS;
case 441,464,594,465,501,564: return TYPE_RC;
default: return TYPE_CAR;
}
}
return false;
}

 

 

stock ResetPlayer // Resetuje hraci uplne vsechno. (Money, Weapon, Wanted...)

 

stock ResetPlayer(playerid)
{
if(IsPlayerConnected(playerid))
{
    ResetPlayerMoney(playerid);
    SetPlayerWantedLevel(playerid, 0);
    ResetPlayerWeapons(playerid);
    SetPlayerScore(playerid, 0);
    SetPlayerHealth(playerid, 100.0);
    SetPlayerArmour(playerid, 0.0);
    SetPlayerWeather(playerid, 10);
    DisablePlayerCheckpoint(playerid);
    DisablePlayerRaceCheckpoint(playerid);
    ClearAnimations(playerid);
    SetCameraBehindPlayer(playerid);
    SetPlayerVirtualWorld(playerid, 0);
    TogglePlayerSpectating(playerid, 0);
}
}

 

Link to comment
Share on other sites

  • 2 months later...

#define ForEx(%0,%1) for(new %0; %0<%1; %0++) 

#define ForConnected(%0,%1) for(new %0; %0<%1; %0++) if(IsPlayerConnected(%0))

jednoducho skrátene for

ForConnected => nemusíte dávať

for(new i; i < Players; i++){

if(IsPlayerConnected(i)){

..

}}

 

 

ale iba jednoducho

ForConnected(i,Players){

...

}

a ForEx je teoreticky to isté ale nie iba pre hráčov, npr. na zničenie objektov

new objects[10];

objects[0] = createobject...

objects[1] = createobject...

....

 

a potom

ForEx(i,10){

DestroyObject(objects);

}

 

Link to comment
Share on other sites

  • 2 weeks later...

stock GetDistanceBetweenVehicles(vehicleid, vehicleid2)
{
   new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
   new Float:tmpdis;
   GetVehiclePos(vehicleid,x1,y1,z1);
   GetVehiclePos(vehicleid2,x2,y2,z2);
   tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
   return floatround(tmpdis);
}

stock GetDistanceBetweenPlayers(playerid, playerid2)
{
   new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
   new Float:tmpdis;
   GetPlayerPos(playerid,x1,y1,z1);
   GetPlayerPos(playerid2,x2,y2,z2);
   tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
   return floatround(tmpdis);
}

 

stock GetPlayerVehicleModel(playerid)
{
   new vehicleid = GetPlayerVehicleID(playerid);
   new model = GetVehicleModel(vehicleid);
   return model;
}

Link to comment
Share on other sites

  • 3 weeks later...

stock GivePlayerHealth(playerid,Float:health){//by QWER :d

SetPlayerHealth(playerid,GetPlayerHealth(playerid)+health);

if(GetPlayerHealth(playerid) > 100) SetPlayerHealth(playerid,100);

}

 

Kuba5 to tvoje ani nešlo :d (ked má 6 wl tak mu pridá 6 xD ? :d )

Link to comment
Share on other sites

  • 4 months later...

#undef AddStaticVehicle AddStaticVehicleXX

stock AddStaticVehicleXX(spz[],modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2){

SetVehicleNumberPlate(AddStaticVehicle(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2), spz);

}

 

využitie ?

AddStaticVehicle("BA-146RH",522, 52, 50, 5, 359, -1, -1);

AddStaticVehicle("BA-536AR",522, 52, 50, 5, 359, -1, -1);

AddStaticVehicle("PK-444JK",522, 52, 50, 5, 359, -1, -1);

PK ? Akože PK ? akože že pezínsky koko* ? :d

užívajte v zdraví

 

čiže AddStaticVehicle s ŠPZ-tkou

Link to comment
Share on other sites

  • 1 month later...

stock GetWeaponSlot(model)
{
  switch(model)
     {
		case 0,1: return 0;
		case 2..9: return 1;
		case 10..15: return 10;
		case 16..18,39: return 8;
		case 22..24: return 2;
		case 25..27: return 3;
		case 28,29,32: return 4;
		case 30,31: return 5;
		case 33,34: return 6;
		case 35,36,37,38: return 7;
		case 41..43: return 9;
		case 44..46: return 11;
      }
      return -1;
}

Napriklad:

new zbran=GetPlayerWeapon(playerid);
new str[128];
format(str,128,"Drzis zbran %d, ktora patri do slotu cislo %d",zbran,GetWeaponSlot(zbran));

Link to comment
Share on other sites

  • 1 month later...

Ahoj všichni, jsem tady na fórku nový a tak bych zde chtěl jako první svůj příspěvek zveřejnit pár užitečných funkcí, které jsem vytvořil při tvorbě svých módů... Zezačátku pár funkcí, ale občas budu příspěvek aktualizovat a přidávat nové funkce...

 

PorovnatCisla(...)

- Funkce porovná vždy 2 čísla která jsou vedle sebe (např. v příkladu níže tyto čísla: 2 a 3; 4 a 5; 8 a 9; 10 a 6) a vrátí počet stejných čísel...

- Musí být zadaný sudý počet čísel

stock PorovnatCisla(...){
new stejnych = 0;

for(new i=0; i<(numargs() / 2); i++){
	if(getarg(i) == getarg((i + 1))) stejnych++;
}

return stejnych;
}

Příklad:

PorovnatCisla(2, 3, 4, 5, 8, 9, 10, 6);

 

PocetStejnychCisel(...)

- Podobná funkce jako předchozí, akorát funkce porovná každé číslo s každým... vhodné např. pro loterii.

stock PocetStejnychCisel(...){
new stejnych = 0;

for(new i=0; i	    for(new y=0; y	        if(y != i){
            if(getarg(i) == getarg(y)) stejnych++;
        }
    }
}

return stejnych;
}

Příklad:

PocetStejnychCisel(10, 5, 6, 8, 9, 10, 2, 10);

 

IsSkinFemale(skinid)

- Zjistí jestli zadaný skin je žena...

stock IsSkinFemale(skinid){
switch(skinid){
	case 9..13,31,39,40,41,54..56,63,64,69,75..77,85..90: return 1;
	case 92,93,129..131,138,140,141,145,148,150..152,157: return 1;
	case 169,172,178,190..199,201,205,207,211,214..216: return 1;
	case 218,219,224..226,231..233,237,238,243..246,251: return 1;
	case 256,257,263,298: return 1;
	default: return 0;
}

return 1;
}

 

UlozData(cesta[], ...)

- Jednoduché uložení dat do souboru (zatím pouze typu integer - čísla)

stock UlozData(cesta[], ...){
new soubor[64], polozka[64], id = 0;
   format(soubor, sizeof(soubor), "%s.txt", cesta);

   if(dini_Exists(soubor)){
       ulozeni_dat:
           for(new i=1; i<(numargs()); i++){
           	format(polozka, sizeof(polozka), "%d", id);
            dini_IntSet(soubor ,polozka, getarg(i, 0));
            id++;
           }
   } else {
	dini_Create(soubor);
	goto ulozeni_dat;
}
}

Příklad:

UlozData("test", playerid, GetPlayerWeapon(playerid));

- Vytvoří soubor test.txt ve složce scriptfiles a uloží do něj id hráče a aktuální zbraň kterou hráč drží...

 

NactiData(cesta[], index)

- Načte data ze souboru, který byl vytvořený funkcí ,,UlozData"...

forward NactiData(cesta[], index);
public NactiData(cesta[], index){
   new soubor[64], polozka[64];

   format(soubor, sizeof(soubor), "%s.txt", cesta);
   format(polozka, sizeof(polozka), "%d", index);

   if(dini_Exists(soubor)) return dini_Int(soubor, polozka);

   return -1;
}

Příklad:

NactiData("test", 0);

- Načte ze souboru test.txt první položku, která byla uložená funkcí ,,UlozData"... v našem případě je to playerid

Link to comment
Share on other sites

  • 3 weeks later...

vytaženo vše z mého INC

 

stock IsPlayerInWater(playerid) {
       new anim = GetPlayerAnimationIndex(playerid);
       if (((anim >=  1538) && (anim <= 1542)) || (anim == 1544) || (anim == 1250) || (anim == 1062)) return 1;
       return 0;
}

stock IsPlayerAiming(playerid) {
new anim = GetPlayerAnimationIndex(playerid);
if (((anim >= 1160) && (anim <= 1163)) || (anim == 1167) || (anim == 1365) ||
(anim == 1643) || (anim == 1453) || (anim == 220)) return 1;
   return 0;
}

 

stock PlayerIp(playerid)
{
     new ip[16];
  GetPlayerIp(playerid,ip,16);
  return ip;
}

stock IsNumeric(const string[]) {
  new length=strlen(string);
  if (length==0) return false;
  for (new i = 0; i < length; i++) {
     if (
     (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+')
     || (string[i]=='-' && i!=0)
     || (string[i]=='+' && i!=0)
     ) return false;
  }
  if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
  return true;
}

 

stock IsPlayerInLS(playerid)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
if(x >= 238.45492553711 && x <= 2920.5192871094 && y >= -2723.2412109375 && y <= 427.88403320313)
{
return 1;
}
return 0;
}

//=========================================================================== LV
stock IsPlayerInLV(playerid)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
if(x >= -528.79284667969 && x <= 3052.1303710938 && y >= 559.11853027344 && y <= 3149.9541015625)
{
return 1;
}
return 0;
}

stock SCMToAdmins(color, zprava[])
{
for(new i;i<=MAX_PLAYERS;i++)
     {
	if(IsPlayerAdmin(i) && IsPlayerConnected(i))
	{
	SendClientMessage(i, color, zprava);
	}
    }
}

 

tak aspon něco ode mě :)

Link to comment
Share on other sites

  • 1 month later...

Ahoj vytvoril som jednoduchú funkciu na usmrtenie všetkých hráčov...či to tu je to neviem ale viem, že toto som písal sám!

 

forward KillAllPlayers();
public KillAllPlayers()
{
       for(new i;i        {
               if(IsPlayerConnected(i))
               {
                       SetPlayerHealth(i,0);
               }
       }
       return 1;
}

 

Malo by to fungovať :)

Link to comment
Share on other sites

KickEx

 

stock KickEx(playerid,dovod)
{
       new dovod1[80];
       new meno[25];
       GetPlayerName(playerid,meno,25);
       format(dovod1,80,"Hráč %s bol vyhodený za %s",meno,dovod);
       SendClientMessageToAll(0xFFFFFFFF,dovod1);
       Kick(playerid);
       return 1;
}

 

...Neviem či sa to hodí do stocku, teraz som to napísal (No copy!)

Link to comment
Share on other sites

  • 1 month later...

IsPointInPolygon

autor: RyDeR (samp fórum)

Super funkce, která se může hodně lidem hodit.

Zjišťuje, jestli je určený bod ve vybrané oblasti.

 

Využití:

*Nepravidelné oblasti

*Pravidelné n-úhelníky (pro pravidelný 4úhelník rovnoběžný s osami je výhodnější použít IsPlayerInArea !!!)

 

Kód:

 

stock IsPointInPolygon(Float: point_X, Float: point_Y, { Float, _ }: ...)
{
    #define MAX_POINTS (32)
    
    new
        args_Total = numargs(),
        polygon_Sides = (args_Total - 2) / 2
    ;
    if((args_Total - 2) & 0b1 || MAX_POINTS <= polygon_Sides || polygon_Sides < 3)
        return 0;
        
    new
        Float: polygon_Data[2][MAX_POINTS],
        cross_Total
    ;
    #undef MAX_POINTS
    
    for(new i = 2, j; i < args_Total; i += 2, ++j)
    {
        polygon_Data[0][j] = Float: getarg(i);
        polygon_Data[1][j] = Float: getarg(i + 1);
    }
    for(new i, j = polygon_Sides - 1; i < polygon_Sides; j = i, ++i)
    {
        if(polygon_Data[1][i] < point_Y && polygon_Data[1][j] >= point_Y || polygon_Data[1][j] < point_Y && polygon_Data[1][i] >= point_Y)
        {
            if(polygon_Data[0][i] + (point_Y - polygon_Data[1][i]) / (polygon_Data[1][j] - polygon_Data[1][i]) * (polygon_Data[0][j] - polygon_Data[0][i]) < point_X)
            {
                cross_Total++;
            }
        }
    }
    return cross_Total & 0b1;   
}

 

 

Funkce vrací hodnoty 0,1

 

Zde máte i zobrazení, jak to celé funguje:

 

2iu3xhk.png

 

Modré body vyznačují námi zvolenou oblast a červené body jsou ty, u kterých zjišťujeme, zda jsou v oblasti nebo ne. Body číslo 1,2 se v oblasti nacházejí, číslo 3 nikoli.

 

A teď si ukážeme, jak zadat tuto funkci do pawna. Použijeme oblast z předchozí obrázku a budeme kontrolovat, zda je bod číslo 1 v oblasti.

 

if(IsPointInPolygon(1931.93, 958.42, //Souřadnice bodu 1

402.31, 944.28, //Souřadnice bodu A polygonu

1011.81, 1388.28, //Souřadnice bodu B polygonu

1797.5, 1208.28, //Souřadnice bodu C polygonu

2186.37, 666.28, //Souřadnice bodu D polygonu

1718.13, 1138.28, //Souřadnice bodu E polygonu

1232.44, 1218.28, //Souřadnice bodu F polygonu

1470.52, 358.28, //Souřadnice bodu G polygonu

359.45, 228.28, //Souřadnice bodu H polygonu

1091.17, 720.28 //Souřadnice bodu I polygonu

)) {

//Kód: Bod je v polygonu

 

ORIGINÁLNÍ TOPIC

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...