Vice City: Multiplayer

Off-Topic => Off-Topic General => Topic started by: MEGAMIND on Aug 08, 2018, 02:11 PM

Title: what do these mean?
Post by: MEGAMIND on Aug 08, 2018, 02:11 PM
I have seen many scripters using this :: Before using some codes like ::createvehicle so what do these mean?, do? Are neccessary or not?
Title: Re: what do these mean?
Post by: ysc3839 on Aug 08, 2018, 02:42 PM
http://www.squirrel-lang.org/squirreldoc/reference/language/execution_context.html#variables
QuoteGlobal variables are stored in a table called the root table. Usually in the global scope the environment object is the root table, but to explicitly access the closure root of the function from another scope, the slot name must be prefixed with '::' (::foo).
If this code is in a class, '::' is necessary to access the global function.

Edit: It seems that I'm wrong?
class test_class
{
function print1()
{
::print("print1");
}

function print2()
{
print("print2");
}
}

function global_print1()
{
::print("global_print1");
}

function global_print2()
{
print("global_print2");
}

global_print1();
global_print2();

local test = test_class();
test.print1();
test.print2();
This code outputs:
[SCRIPT]  global_print1
[SCRIPT]  global_print2
[SCRIPT]  print1
[SCRIPT]  print2

This code shows differences:
class test_class
{
function print1()
{
::print("print1");
}

function print2()
{
print("print2");
}

function print(text)
{
::print("!!!" + text + "!!!");
}
}

function global_print1()
{
::print("global_print1");
}

function global_print2()
{
print("global_print2");
}

global_print1();
global_print2();

local test = test_class();
test.print1();
test.print2();
[SCRIPT]  global_print1
[SCRIPT]  global_print2
[SCRIPT]  print1
[SCRIPT]  !!!print2!!!
Title: Re: what do these mean?
Post by: . on Aug 08, 2018, 03:51 PM
https://forum.vc-mp.org/?topic=861.msg5558#msg5558