alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
499 stars 203 forks source link

set_param_byref is not working #899

Closed TheProjectPioneer closed 4 years ago

TheProjectPioneer commented 4 years ago

Hey,

Tried using the set_param_byref command to change a by-reference variable's value in a native, but it ain't working. You can imagine it like in the most basic way.

public plugin_natives()
{
    register_native("test_native", "native_test_native")
}

public native_test_native(plugin_id, param_num)
{
    set_param_byref(1, 131)
}
native test_native(variable)

new testVariable

public plugin_init()
{
    test_native(testVariable)
    console_print(0, "%d", testVariable)
}

With this code I get 0

note: I wrote it by hand and now in my browser, so can be possible mistakes. While testing I wrote it much more carefully

Edit: I'm using the newest(dev) amxmodx.

Arkshine commented 4 years ago

You miss the & in the native declaration;

native test_native(&variable)

TheProjectPioneer commented 4 years ago

You miss the & in the native declaration;

native test_native(&variable)

Yeah, this was the problem. Enormous thanks and sry for being foolish