Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Sir. Cucuruchito on Jul 16, 2018, 05:04 PM

Title: Problems with the InPoly function
Post by: Sir. Cucuruchito on Jul 16, 2018, 05:04 PM
Hi everyone, I am writing a function for detect bank locations and ATMs. In this moment, I have got this:

main.nut
// BANK LOCATIONS
banks <- [
"-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
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;
}

(https://s33.postimg.cc/5p4sbcp9b/Vice_City_Multiplayer_GTA_VC_acd9d3f2397b867f209970db7f5117e6.png)

In the wiki say that the arguments are two floats (player.Pos) and an string / array / floats, but fails.
Title: Re: Problems with the InPoly function
Post by: NicusorN5 on Jul 16, 2018, 05:18 PM
Use DistanceFromPoint() instead.
Title: Re: Problems with the InPoly function
Post by: Sir. Cucuruchito on Jul 16, 2018, 05:40 PM
Quote from: Athanatos on Jul 16, 2018, 05:18 PMUse DistanceFromPoint() instead.

This function doesn't allow me to make geometric shapes like a rectangle / square. Also, the previous function should work.
Title: Re: Problems with the InPoly function
Post by: NicusorN5 on Jul 16, 2018, 06:42 PM
Alrighty then, are you sure InPoly works with strings?
Title: Re: Problems with the InPoly function
Post by: Xmair on Jul 16, 2018, 07:20 PM
That function expects floats, not strings.
Title: Re: Problems with the InPoly function
Post by: Sir. Cucuruchito on Jul 16, 2018, 08:44 PM
Quote from: Athanatos on Jul 16, 2018, 06:42 PMAlrighty then, are you sure InPoly works with strings?
Quote from: Xmair on Jul 16, 2018, 07:20 PMThat function expects floats, not strings.

In the Wiki it puts the opposite.(I didn't try with floats.)
(https://s33.postimg.cc/y68c6gbrz/wiki.png)
Title: Re: Problems with the InPoly function
Post by: ysc3839 on Jul 17, 2018, 12:26 AM
Quote from: Ququr_Uxcho on Jul 16, 2018, 08:44 PM
Quote from: Athanatos on Jul 16, 2018, 06:42 PMAlrighty then, are you sure InPoly works with strings?
Quote from: Xmair on Jul 16, 2018, 07:20 PMThat function expects floats, not strings.

In the Wiki it puts the opposite.(I didn't try with floats.)
(https://s33.postimg.cc/y68c6gbrz/wiki.png)
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
Title: Re: Problems with the InPoly function
Post by: Sir. Cucuruchito on Jul 17, 2018, 11:21 AM
Quote from: ysc3839 on Jul 17, 2018, 12:26 AM
Quote from: Ququr_Uxcho on Jul 16, 2018, 08:44 PM
Quote from: Athanatos on Jul 16, 2018, 06:42 PMAlrighty then, are you sure InPoly works with strings?
Quote from: Xmair on Jul 16, 2018, 07:20 PMThat function expects floats, not strings.

In the Wiki it puts the opposite.(I didn't try with floats.)
(https://s33.postimg.cc/y68c6gbrz/wiki.png)
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?
Title: Re: Problems with the InPoly function
Post by: NicusorN5 on Jul 17, 2018, 06:21 PM
Possible. Try using an array of floats.
Title: Re: Problems with the InPoly function
Post by: Milos on Jul 17, 2018, 06:51 PM
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;
}
Title: Re: Problems with the InPoly function
Post by: Sir. Cucuruchito on Jul 17, 2018, 07:23 PM
Quote from: Athanatos on Jul 17, 2018, 06:21 PMPossible. 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 Jul 17, 2018, 06:51 PMfunction 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.