AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=7)
-   -   Solved Problem with callfunc_push_intrf (https://forums.alliedmods.net/showthread.php?t=311190)

_McHappy 10-07-2018 04:27

Problem with callfunc_push_intrf
 
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.

Mistrick 10-07-2018 06:12

Re: [BUG] callfunc_push_intref doesn't work
 
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);



_McHappy 10-07-2018 07:12

Re: [BUG] callfunc_push_intref doesn't work
 
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.

asherkin 10-07-2018 07:46

Re: [BUG] callfunc_push_intref doesn't work
 
You can edit your own topic by using advanced edit or double-clicking the title in the list


All times are GMT -4. The time now is 22:55.

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