Raised This Month: $ Target: $400
 0% 

Array as reference


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 06-04-2010 , 17:14   Re: Array as reference
Reply With Quote #1

I still don't understand what you mean.
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-04-2010 , 17:55   Re: Array as reference
Reply With Quote #2

PHP Code:
function(array[]) 
array is passed by reference.
__________________
fysiks is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-04-2010 , 18:16   Re: Array as reference
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
PHP Code:
function(array[]) 
array is passed by reference.
It's really not that hard to understand. Note that there is NO ampersand.
__________________

Last edited by fysiks; 06-04-2010 at 18:19.
fysiks is offline
Vertricus
Junior Member
Join Date: Aug 2009
Location: Poland>Śląs
Old 06-04-2010 , 18:32   Re: Array as reference
Reply With Quote #4

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
Vertricus is offline
Send a message via Skype™ to Vertricus
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-04-2010 , 19:17   Re: Array as reference
Reply With Quote #5

Quote:
Originally Posted by Vertricus View Post
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
To prevent any confusion the underscore (_) does absolutely nothing other than make it a different variable name.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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