Vice City: Multiplayer

VC:MP Discussion => General Discussion => Topic started by: Kelvin Garcia Mendoza on Mar 04, 2019, 05:27 AM

Title: question
Post by: Kelvin Garcia Mendoza on Mar 04, 2019, 05:27 AM
hello, I've been asking myself what's '::' and what's its usage

example:
::Message( text );
instead of
Message( text );
can you please explain me how and when to use it?

regards!
Title: Re: question
Post by: DizzasTeR on Mar 04, 2019, 05:40 AM
Its used to reach out a variable/data outside of scopes.
function onScriptLoad() {
    local a = 1;
    { // Starting a general scope inside script load
        local a = 3;
        print(format("local scope a: %i, outside local scope a: %i", a, ::a));
    }
}

Usually used in classes/tables instead of general scopes like above
function LOGINFO(s) { print("[LOG] " + s); }

function CPlayer::Foo() {
    LOGINFO("Called player method Foo"); // Error, LOGINFO is not present in CPlayer class
    ::LOGINFO("..."); // Look for it outside the CPlayer scope
}

I haven't touched squirrel for quite a while now so it could be abit rusty :P
Title: Re: question
Post by: Kelvin Garcia Mendoza on Mar 04, 2019, 06:14 AM
Quote from: Doom_Kill3R on Mar 04, 2019, 05:40 AM-
Thank you @Doom_Kill3R for explaining! :)
Title: Re: question
Post by: Milos on Mar 13, 2019, 12:30 PM
What about the client side?
Some scripters use:
myVar <- 0;
function Script::ScriptLoad() {
    ::myVar = 1;
    Console.Print("Test: " + ::myVar);
}
or
myVar <- 0;
function Script::ScriptLoad() {
    myVar = 1;
    Console.Print("Test: " + myVar);
}
Both work, but...
Is this necessary for variables called from outside the function?
What is the correct way to use this in client?