. allows you to specify which values are used for which parameters.
For example, set_task header looks like this:
PHP Code:
set_task(Float:time, const function[], id = 0, const any:parameter[] = "", len = 0, const flags[] = "", repeat = 0);
A potential call would be:
PHP Code:
set_task(1.0, "func", 1234, "something", 10, "b")
and this means that time is set to 1.0, function is "func", id is 1234 etc. Basically, parameters are filled in the order in which they are declared in the header.
But, maybe you want to fill them in a different order or explicitly state which value is for which parameter(useful in natives with a lot of parameters to make it clear what parameter is being set to what value). Then you can do:
PHP Code:
set_task(.time = 1.0, .function = "func", .id = 1234)
or
PHP Code:
set_task(.id = 1234, .time = 1.0, .function = "func")
(notice I changed the order of parameters)
But, this alone is not terribly useful. The "true" usage of this is so you can skip some parameters you do not need while specifying a later parameter.
In your example you had:
PHP Code:
set_task(0.1, "function", .flags = "b")
time and function are normally specified(without ".") and then you have .flags = "b". Notice you skipped several parameters between "function" param and "flag" param. No values were specified for id, parameter, and len.
If you wanted to write this without the "."(dot notation) you would have to give all the intermediate parameters a value:
PHP Code:
set_task(0.1, "function", 0, "", 0, "b")
& for scalar values(simple variables, not arrays) means to pass a variable by reference(as opposed to passing by value when & is not used). When you pass by value a copy of the variable is passed to the function so if the function modifies that variable, the change will not be visible to the caller function.
When you pass by reference, informally, you pass the actual variable so if you change it inside the function, the change will be visible to the caller function.
PHP Code:
func(x, y)
{
//x and y here are copies of the x and y from plugin_init
x = 3
y = 4
//from this point on, inside this function, x will be 3 and y 4
}
plugin_init()
{
new x = 1
new y = 2
func(x, y)
//the changes made by func are not visible here
//x and y are still 1 and 2
}
Now, the same code, but using pass by reference:
PHP Code:
func(&x, &y)
{
//x and y here are the same variables as the ones from plugin_init
x = 3
y = 4
//from this point on, inside this function, x will be 3 and y 4
}
plugin_init()
{
new x = 1
new y = 2
func(x, y)
//the changes made by func are visible here
//x and y are now 3 and 4
}
& is used when you want to change a parameter and have that change visible to the caller function. It is useful when you want to return move values from a function. One of them is returned with "return" and the others are "returned" by using reference parameters.
In your example, with
cs_get_user_team, the model parameter can store/"return" the model id. It has to be a reference(&) in order to implement this functionality.
__________________