Issue information

Issue ID
#8642
Status
New
Severity
None
Started
Kpy!
Apr 20, 2015 21:23
Last Post
Kpy!
Apr 20, 2015 21:23
Confirmation
N/A

Kpy! - Apr 20, 2015 21:23

See the following test case:[code=auto:0] prontera,157,180,5 script test 81,{ donpcevent "test2::OnSetMyVar"; mes ".myvar: " + callsub(OnGetMyVar); //OK: displays ".myvar: 1" mes ".myvar: " + callsub(OnGetMyVar2); //ERROR: displays ".myvar: 0" .myvar = 2; mes ".myvar: " + callsub(OnGetMyVar2); //ERROR: displays ".myvar: 2" close; OnGetMyVar: .@myvar = getvariableofnpc(.myvar, "test2"); return .@myvar; OnGetMyVar2: return getvariableofnpc(.myvar, "test2"); } - script test2 -1,{ OnSetMyVar: .myvar = 1; end; } [/code]
The variable's (.myvar) ref is being removed by this code in the return function (script.c):[code=auto:5706] } else if ( name[0] == '.' /* && data->ref != NULL */ ) { data->ref = NULL; // Reference to the parent scope's script, remove reference pointer. } [/code]

EDIT:
Pull request: [url="https://github.com/HerculesWS/Hercules/pull/502"]https://github.com/HerculesWS/Hercules/pull/502[/url]

This post has been edited by Kpy! on Apr 21, 2015 12:01