Raised This Month: $32 Target: $400
 8% 

Solved Problem with callfunc_push_intrf


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
_McHappy
New Member
Join Date: Jul 2017
Old 10-07-2018 , 04:27   Problem with callfunc_push_intrf
Reply With Quote #1

Hi.
I have a problem with callfunc_push_intrf. The function is not working as expected - just take a look at this plugin:

Code:
#include <amxmodx>

public plugin_init()
{
	register_plugin("Tests", "1.0", "Nvm");

	register_concmd("test_intref", "test_intref");
}

public test_intref(id)
{
	new testing_param;

	if(callfunc_begin("test_func") == 1)
	{
		callfunc_push_intrf(testing_param);
		callfunc_end();

		// console output: "test_intref - testing_param value: 0"
		log_amx("test_intref - testing_param value: %d", testing_param);
	}
}

public test_func(param)
{
	// console output: "test_func - param value (pre): 628"
	log_amx("test_func - param value (pre): %d", param);

	param = 5;

	// console output: "test_func - param value (post): 5"
	log_amx("test_func - param value (post): %d", param);
}
Tested on fresh HLDS (updated via SteamCMD) and ReHLDS with metamod/metamod-r and AMXX 1.8.2/1.9.0-git5229 on windows 10 64bit.

Any ideas why does it behave like that?
Regards.

Last edited by _McHappy; 10-07-2018 at 09:29.
_McHappy is offline
Mistrick
Senior Member
Join Date: Aug 2012
Location: Russia
Old 10-07-2018 , 06:12   Re: [BUG] callfunc_push_intref doesn't work
Reply With Quote #2

You missed &
PHP Code:
public test_func(&param)// there
{
    
// console output: "test_func - param value (pre): 628"
    
log_amx("test_func - param value (pre): %d"param);

    
param 5;

    
// console output: "test_func - param value (post): 5"
    
log_amx("test_func - param value (post): %d"param);

Mistrick is offline
_McHappy
New Member
Join Date: Jul 2017
Old 10-07-2018 , 07:12   Re: [BUG] callfunc_push_intref doesn't work
Reply With Quote #3

Oh, my bad. Now it works as expected.
I swear blind that I tried to solve this that way (as in the classic case of using references), but the compiler was throwing an error.
Anyway - thank you.
_McHappy is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 10-07-2018 , 07:46   Re: [BUG] callfunc_push_intref doesn't work
Reply With Quote #4

You can edit your own topic by using advanced edit or double-clicking the title in the list
__________________
asherkin is offline
Reply


Thread Tools
Display Modes

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 19:46.


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