AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Array as reference (https://forums.alliedmods.net/showthread.php?t=128350)

Sn!ff3r 05-31-2010 07:14

Array as reference
 
How ?

Bugsy 05-31-2010 08:42

Re: Array as reference
 
Are you asking how to pass an array by reference to a function? If so, they always are automatically; there are no operators or extra code needed.

Sn!ff3r 06-04-2010 17:13

Re: Array as reference
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Nowy Plugin"
#define VERSION "1.0"
#define AUTHOR "Sn!ff3r"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
}

public 
test(&array[])
{
    


How to do it?

#8 SickneSS 06-04-2010 17:14

Re: Array as reference
 
I still don't understand what you mean.

fysiks 06-04-2010 17:55

Re: Array as reference
 
PHP Code:

function(array[]) 

array is passed by reference.

Sn!ff3r 06-04-2010 18:02

Re: Array as reference
 
Just try to compile.

fysiks 06-04-2010 18:16

Re: Array as reference
 
Quote:

Originally Posted by fysiks (Post 1199852)
PHP Code:

function(array[]) 

array is passed by reference.

It's really not that hard to understand. Note that there is NO ampersand.

Vertricus 06-04-2010 18:32

Re: Array as reference
 
Code:

#include <amxmodx>
public plugin_init()
{
        register_plugin("a", "b", "c")
        new array[3]
        function(array)
        log_amx("%i %i %i", array[0],array[1],array[2])
}
public function(_array[3])
{
        _array[0] = 1;
        _array[1] = 2;
        _array[2] = 3;
}

and result:
Code:

L 06/05/2010 - 00:29:57: [aaa.amxx] 1 2 3
:o

fysiks 06-04-2010 19:17

Re: Array as reference
 
Quote:

Originally Posted by Vertricus (Post 1199875)
Code:

#include <amxmodx>
public plugin_init()
{
        register_plugin("a", "b", "c")
        new array[3]
        function(array)
        log_amx("%i %i %i", array[0],array[1],array[2])
}
public function(_array[3])
{
        _array[0] = 1;
        _array[1] = 2;
        _array[2] = 3;
}

and result:
Code:

L 06/05/2010 - 00:29:57: [aaa.amxx] 1 2 3
:o

To prevent any confusion the underscore (_) does absolutely nothing other than make it a different variable name.

Sn!ff3r 06-04-2010 20:48

Re: Array as reference
 
Uhm... fixed.


All times are GMT -4. The time now is 05:21.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.