Raised This Month: $51 Target: $400
 12% 

get_param and get_param_byref


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 08-31-2011 , 00:06   get_param and get_param_byref
Reply With Quote #1

I understand how to use get_param, but what I'm curious about is how useful get_param_byref is. I played around with it thinking that if I did something like...

PHP Code:
            new get_param_byref(3);
            
i++; 
Thinking that the parameter entered would change. It didn't. So can anyone tell me the purpose of this with a usage? (Yes, I know that you can do set_param_byref to change the by reference value.)
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-31-2011 , 00:38   Re: get_param and get_param_byref
Reply With Quote #2

It does the same thing in Pawn, so you don't see a difference.
The module is written differently, but the byref function makes no sense to even exist.

Code:
//get a byvalue parameter
//get_param(num)
static cell AMX_NATIVE_CALL get_param(AMX *amx, cell *params)
{
	if (!g_pCurNative || (g_pCurNative->amx != amx))
	{
		LogError(amx, AMX_ERR_NATIVE, "Not currently in a dynamic native");
		return 0;
	}
	if (g_pCurNative->style)
	{
		LogError(amx, AMX_ERR_NATIVE, "Wrong style of dynamic native");
		return 0;
	}
	//get parameter index to read from
	int p = params[1];

	//return value from the stored params in the function (new memory space)
	return g_Params[p];
}

//get_param_byref(num)
static cell AMX_NATIVE_CALL get_param_byref(AMX *amx, cell *params)
{
	if (!g_pCurNative || (g_pCurNative->amx != amx))
	{
		LogError(amx, AMX_ERR_NATIVE, "Not currently in a dynamic native");
		return 0;
	}
	if (g_pCurNative->style)
	{
		LogError(amx, AMX_ERR_NATIVE, "Wrong style of dynamic native");
		return 0;
	}
	//get parameter index to read from
	int p = params[1];

	//get the memory address of the variable
	cell *addr = get_amxaddr(g_pCaller, g_Params[p]);

	//return the value from the memory address
	return addr[0];
}
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 21:33.


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