SetTimerEx on variable passed by reference
#1

Today I was testing one thing and I found out bug related to the SetTimerEx function. When I try to pass a variable by reference to the function it works fine. If there is a SetTimerEx set on that function things start to mess up. Small visualisation:

Code:
Code:
#include <a_samp>

public OnFilterScriptInit()
{
	new variable = 5;
	print("Direct calls:");
	function(variable);
	function(variable);
	function(variable);
	
	print("Timer calls:");
	SetTimerEx("function", 1000, 1, "d", variable);
}

forward function(&argument);
public function(&argument)
{
	argument++;
	printf("argument: %i", argument);
	return 1;
}
Output:
Code:
loadfs t70
Direct calls:
argument: 6
argument: 7
argument: 8
Timer calls:
  Filterscript 't70.amx' loaded.
argument: 115
argument: 116
argument: 117
argument: 118
argument: 119
argument: 120
argument: 121
argument: 122
argument: 123
argument: 124
argument: 125
argument: 126
argument: 127
I thought it was my mistake, because the variable was declared in the local scope and when the timer calls the function the variable is already destroyed but making this variable global doesn't help. Same thing happens.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)