SetTimerEx problem
#1

Today I read the articles about timer that ****** wrote and I try to use the SetTimer function with delayed loading.
However, I got some questions and I made some testes:
Код:
#include <a_samp>

forward RunTimer(const funcname[]);

public OnGameModeInit()
{
    SetTimerEx("RunTimer",100,false,"s","message");
    SetTimerEx("RunTimer",1000,false,"s","message2");
}

public RunTimer(const funcname[])
{
	new string[128];
	format(string,sizeof(string),"%s",funcname);
	print(string);
	printf("%s",funcname);
	print(funcname);
	return 1;
}
and the first
Код:
SetTimerEx("RunTimer",100,false,"s","message");
won't work.
Both prints message2.

Seems that it's impossible to call the same function with different interval at the same time?

Also,I found that the string passed in SetTimerEx cannot be outputted directly. It must be formatted or it'll just print null string. What's the problem?

Sorry for my bad English but please help.

EDIT:
Now I found that only strings will act like that.
Passing integers will be normal.
See the testing code:
Код:
#include <a_samp>

forward RunTimer(num,string2[]);

public OnGameModeInit()
{
    SetTimerEx("RunTimer",1000,false,"ds",1,"abc");
    SetTimerEx("RunTimer",1000,false,"ds",0,"def");
}

public RunTimer(num,string2[])
{
	new string[128];
	format(string,sizeof(string),"%d %s",num,string2);
    print(string);
	return 1;
}
and it prints:
Код:
1 def
0 def
Weird...
Reply
#2

I have always had problems with strings in SetTimerEx, and also CallRemoteFunction

I solved the problem by not using strings in these functions.
A possible workaround is to use a string array, and pass the reference in the timer function. I used foreach and Iter_Add to ensure the array id is unique
Reply
#3

I also got problems on CallRemoteFunction before,
but the only problem is that it's unable to pass null strings but "\1\0".
You'll need to pass null like that and use isnull function to check it.
Reply
#4

i belive its
pawn Код:
SetTimerEx("blank here", time, false/true, "d", whatever here);
Reply
#5

Quote:
Originally Posted by fangoth1
Посмотреть сообщение
i belive its
pawn Код:
SetTimerEx("blank here", time, false/true, "d", whatever here);
Do you even know what does this d, i, s and all means?
Reply
#6

Quote:
Originally Posted by fangoth1
Посмотреть сообщение
i belive its
pawn Код:
SetTimerEx("blank here", time, false/true, "d", whatever here);
D stands for integer, he's trying to print a string. Therefor `s`
Reply
#7

So any idea for why it acts like that?
Reply
#8

You must report http://forum.sa-mp.com/forumdisplay.php?f=20
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)