Vice City: Multiplayer

VC:MP Discussion => Support => Topic started by: vitosca on Jan 22, 2016, 01:59 PM

Title: [SERVER] GetWorldBounds
Post by: vitosca on Jan 22, 2016, 01:59 PM
Hello. I have latest server windows version x64.

How to parse GetWorldBounds data to float?
Example from http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/Bounds
function onScriptLoad()
{
    local boundaries = GetWorldBounds();
    print( "Worldboundaries has been set to :" + boundaries.maxX + "," + boundaries.minX + "," + boundaries.maxY + "," + boundaries.minY );
}
don't work for me. I got an error 'Member Variable not found'
Title: Re: [SERVER] GetWorldBounds
Post by: . on Jan 22, 2016, 02:16 PM
That's because if you look at the documentation history. You will see that it was created by nabs who don't give a f* about testing the code first.

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fs15.postimg.org%2Fi8xrdgt6z%2FUntitled.jpg&hash=ea206e6ff5c4971e355a51db7ca1aa0b4ba592eb)

According to the module source code. They begin with a capital letter as well.
Sqrat::RootTable().Bind(_SC("Bounds"), Sqrat::Class<Bounds>(Sqrat::DefaultVM::Get(), _SC("Bounds"))
        .Ctor<float, float, float, float>()

        .Var(_SC("MaxX"), &Bounds::maxX)
        .Var(_SC("MinX"), &Bounds::minX)
        .Var(_SC("MaxY"), &Bounds::maxY)
        .Var(_SC("MinY"), &Bounds::minY)
    );

And creating a piece of code to inspect the type I'm interested in:
foreach (k1, v1 in getroottable())
{
    if (k1 == "Bounds")
    {
        foreach (k2, v2 in v1)
        {
            print("name: " + k2 + " type: " + typeof(v2));

            if (typeof(v2) == "table")
            {
                foreach (k3, v3 in v2)
                {
                    print("-- name: " + k3 + " type: " + typeof(v3));
                }
            }
        }
    }
}

Gives me the following:
[MODULE]  Loaded SqVCMP 0.4 frontend by Stormeus. (v1.0)
[SCRIPT]  name: constructor type: function
[SCRIPT]  name: __setTable type: table
[SCRIPT]  -- name: MinY type: function
[SCRIPT]  -- name: MinX type: function
[SCRIPT]  -- name: MaxY type: function
[SCRIPT]  -- name: MaxX type: function
[SCRIPT]  name: __getTable type: table
[SCRIPT]  -- name: MinY type: function
[SCRIPT]  -- name: MinX type: function
[SCRIPT]  -- name: MaxY type: function
[SCRIPT]  -- name: MaxX type: function
[SCRIPT]  name: weakref type: function

Which confirms the fact that they begin with a capital letter.
Title: Re: [SERVER] GetWorldBounds
Post by: vitosca on Jan 22, 2016, 05:14 PM
Thank you so much. It's really a big problem with documentation for vc-mp.
Title: Re: [SERVER] GetWorldBounds
Post by: . on Jan 22, 2016, 05:20 PM
Quote from: vitosca on Jan 22, 2016, 05:14 PMIt's really a big problem with documentation for vc-mp.

You can always ask on the forum or via IRC (http://chat.mibbit.com/?server=irc.liberty-unleashed.co.uk&channel=%23SLC).
Title: Re: [SERVER] GetWorldBounds
Post by: vitosca on Jan 22, 2016, 09:19 PM
Sorry for dumb question. I have make that zone
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FqEVs4E7.png&hash=fd00262eaa7ccbb51b7056250be2ccc533ad185e)
function onScriptLoad()
{
   SetWorldBounds( -636, -720, 793, 703 );
}
but it no affect on game

edit: It's affects only after reconnect