#### Sir. Cucuruchito

• Newbie
• Tasty coding on Commando Miami 80's!
• Posts: 29
##### Problems with the InPoly function
«  »Last edited
Hi everyone, I am writing a function for detect bank locations and ATMs. In this moment, I have got this:

main.nut
Code: [Select]
`// BANK LOCATIONSbanks <- [ "-921.229, -355.514, -928.713, -326.602, -901.457, -326.602, -901.457, -355.519", // elBancoCorruptoGrande "357.028, 1127.34, 356.961, 1132.15, 359.17, 1132.33, 359.462, 1127.27", // atmMall "6.47041, -949.763, 1.30694, -949.764, 1.51372, -947.378, 6.33632, -947.53", // atmWashingtonMallRightSide "1.44156, -928.274, 6.39117, -928.274, 6.37502, -930.697, 1.46436, -930.314" // atmWashingtonMallLeftSide]`

another_one.nut
Code: [Select]
`function isPlayerIntoBank(player) {    local found = false;    for(local i = 0; i < banks.len() && !found; i++) {        if(InPoly(player.Pos.x, player.Pos.y, banks[i]))            found = true;    }    return found;}`

In the wiki say that the arguments are two floats (player.Pos) and an string / array / floats, but fails.
Commando Miami 80's
IP: 206.189.97.12:8192

#### Athanatos

• Hero Member
• Romania Cops N Robbers Lead Developer
• Posts: 839
##### Re: Problems with the InPoly function
« Reply #1,  »
Use DistanceFromPoint() instead.

#### Sir. Cucuruchito

• Newbie
• Tasty coding on Commando Miami 80's!
• Posts: 29
##### Re: Problems with the InPoly function
« Reply #2,  »
Quote from Athanatos on July 16th, 2018, 06:18 PM
Use DistanceFromPoint() instead.
This function doesn't allow me to make geometric shapes like a rectangle / square. Also, the previous function should work.
Commando Miami 80's
IP: 206.189.97.12:8192

#### Athanatos

• Hero Member
• Romania Cops N Robbers Lead Developer
• Posts: 839
##### Re: Problems with the InPoly function
« Reply #3,  »
Alrighty then, are you sure InPoly works with strings?

#### Xmair

• Wiki Contributor
• Posts: 889
##### Re: Problems with the InPoly function
« Reply #4,  »
That function expects floats, not strings.
VU Full Member | VCCNR Developer | KTB Developer | EAD Ex-Scripter

#### Sir. Cucuruchito

• Newbie
• Tasty coding on Commando Miami 80's!
• Posts: 29
##### Re: Problems with the InPoly function
« Reply #5,  »Last edited
Quote from Athanatos on July 16th, 2018, 07:42 PM
Alrighty then, are you sure InPoly works with strings?
Quote from Xmair on July 16th, 2018, 08:20 PM
That function expects floats, not strings.
In the Wiki it puts the opposite.(I didn't try with floats.)
Commando Miami 80's
IP: 206.189.97.12:8192

#### ysc3839

• VC:MP Beta Tester
• Posts: 620
##### Re: Problems with the InPoly function
« Reply #6,  »Last edited
Quote from Ququr_Uxcho on July 16th, 2018, 09:44 PM
Quote from Athanatos on July 16th, 2018, 07:42 PM
Alrighty then, are you sure InPoly works with strings?
Quote from Xmair on July 16th, 2018, 08:20 PM
That function expects floats, not strings.
In the Wiki it puts the opposite.(I didn't try with floats.)
Are you talking about client-side or server-side?
According to source code, server-side supports string.
https://bitbucket.org/stormeus/0.4-squirrel/src/cdeaf615b61b5c94d79f4a1e342d911b168c3cb3/FunctionHandler.cpp?at=newapi&fileviewer=file-view-default#FunctionHandler.cpp-2018

#### Sir. Cucuruchito

• Newbie
• Tasty coding on Commando Miami 80's!
• Posts: 29
##### Re: Problems with the InPoly function
« Reply #7,  »Last edited
Quote from ysc3839 on July 17th, 2018, 01:26 AM
Quote from Ququr_Uxcho on July 16th, 2018, 09:44 PM
Quote from Athanatos on July 16th, 2018, 07:42 PM
Alrighty then, are you sure InPoly works with strings?
Quote from Xmair on July 16th, 2018, 08:20 PM
That function expects floats, not strings.
In the Wiki it puts the opposite.(I didn't try with floats.)
Are you talking about client-side or server-side?
According to source code, server-side supports string.
https://bitbucket.org/stormeus/0.4-squirrel/src/cdeaf615b61b5c94d79f4a1e342d911b168c3cb3/FunctionHandler.cpp?at=newapi&fileviewer=file-view-default#FunctionHandler.cpp-2018
About server-side. Although It says It works with string but It tried It and It fails.
In my code they are string but it returns the previous garbage exception output. Is it possible that is a bug?
Commando Miami 80's
IP: 206.189.97.12:8192

#### Athanatos

• Hero Member
• Romania Cops N Robbers Lead Developer
• Posts: 839
##### Re: Problems with the InPoly function
« Reply #8,  »
Possible. Try using an array of floats.

#### Milos

• Jr. Member
• Posts: 83
##### Re: Problems with the InPoly function
« Reply #9,  »Last edited
Code: [Select]
`function isPlayerIntoBank(player) {    for(local i = 0; i < banks.len(); i++) {        if(InPoly(player.Pos.x, player.Pos.y, banks[i][0], banks[i][1], banks[i][2], banks[i][3], banks[i][4], banks[i][5], banks[i][6], banks[i][7]))        {            return true;            break;        }    }    return false;}`

#### Sir. Cucuruchito

• Newbie
• Tasty coding on Commando Miami 80's!
• Posts: 29
##### Re: Problems with the InPoly function
« Reply #10,  »
Quote from Athanatos on July 17th, 2018, 07:21 PM
Possible. Try using an array of floats.
I did, but that should not be the solution. If I can use floats, I should be able to use string or arrays.
@Stormeus I would like to know if it is an error or whatever.
Quote from Pop360 on July 17th, 2018, 07:51 PM
Code: [Select]
`function isPlayerIntoBank(player) {    for(local i = 0; i < banks.len(); i++) {        if(InPoly(player.Pos.x, player.Pos.y, banks[i][0], banks[i][1], banks[i][2], banks[i][3], banks[i][4], banks[i][5], banks[i][6], banks[i][7]))        {            return true;            break;        }    }    return false;}`
Yes, these is my current solution.
Commando Miami 80's
IP: 206.189.97.12:8192