SA-MP Forums Archive
A tricky one (funcname[]) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: A tricky one (funcname[]) (/showthread.php?tid=422331)



A tricky one (funcname[]) - Lookin - 13.03.2013

im curious about is
is it possible to remove the "funcname[]) from SetTimer(funcname[], interval, repeating)

for a simple and clear example

from
SetTimer(funcname[], interval, repeating)
to
SetTimer(interval, repeating)


thanks in advance

Lookin

EDIT: btw im just curious Timers have nothing to do with why im wondering it was just the simplest code so that there where no hassles in the question


Re: A tricky one (funcname[]) - Vince - 13.03.2013

Set a timer to do what? You're not making any sense.


Re: A tricky one (funcname[]) - Dan.. - 13.03.2013

#define SetMyTimer(%1,%2) SetTimer(#MyTimer,%1,%2)

If that's what you mean.


Re: A tricky one (funcname[]) - Sinner - 13.03.2013

Quote:
Originally Posted by Dan..
Посмотреть сообщение
#define SetMyTimer(%1,%2) SetTimer(#MyTimer,%1,%2)

If that's what you mean.
That doesn't make sense either.


Re: A tricky one (funcname[]) - MP2 - 13.03.2013

Timers execute the code in a function after a set interval. Setting a timer without specifying the function is like displaying a transparent textdraw to a player!


Re: A tricky one (funcname[]) - cessil - 13.03.2013

you could use a blank function name, however why not tell us the real reason you're wondering


Re: A tricky one (funcname[]) - Lookin - 13.03.2013

ok.
for example:
I wanted to make a timer include that made one timer work like
pawn Код:
ST(S(5), 1); // 5 seconds
rather than
pawn Код:
SetTimer(funcname[], interval, repeating)
im just using
pawn Код:
SetTimer(interval, repeating)
so that i can have multiple functions using just one timer
like this

pawn Код:
public DoSomeThingHere1()
{
    SendClientMessageToAll(LIGHT_BLUE,"MSG1");
    ST(S(5),1); //5 seconds
    return 1;
}

public DoSomeThingHere2()
{
    SendClientMessageToAll(LIGHT_BLUE,"MSG2");
    ST(S(5),1); //5 seconds
    return 1;
}
also was going to add in a question, may as well do it here. how would i make processing cmds and timers to read and write faster?


Re: A tricky one (funcname[]) - Vince - 13.03.2013

Isn't that exactly what y_timers does?


Re: A tricky one (funcname[]) - Lookin - 13.03.2013

I have no idea ive never looked at the inc

anyways im just wondering if it can be done or not ive never said im working on anything


Re: A tricky one (funcname[]) - Lookin - 13.03.2013

Quote:
Originally Posted by Lookin
Посмотреть сообщение
ok.
for example:
I wanted to make a timer include that made one timer work like
pawn Код:
ST(S(5), 1); // 5 seconds
rather than
pawn Код:
SetTimer(funcname[], interval, repeating)
im just using
pawn Код:
SetTimer(interval, repeating)
so that i can have multiple functions using just one timer
like this

pawn Код:
public DoSomeThingHere1()
{
    SendClientMessageToAll(LIGHT_BLUE,"MSG1");
    ST(S(5),1); //5 seconds
    return 1;
}

public DoSomeThingHere2()
{
    SendClientMessageToAll(LIGHT_BLUE,"MSG2");
    ST(S(5),1); //5 seconds
    return 1;
}
also was going to add in a question, may as well do it here. how would i make processing cmds and timers to read and write faster?
Quote:
Originally Posted by ******
Посмотреть сообщение
I'm still not clear how you want to specify which functions are called by your timer without that parameter...



There are multiple libraries for that - the most famous is probably ZCMD, but I'd say y_commands (and y_timers for timers).
Ok

public DoSomeThingHere2()
{
SendClientMessageToAll(LIGHT_BLUE,"MSG2");
ST(S(5),1); //only starts the timer in this function for the duration the function is called
return 1;
}

so that all it needs to do is count to the set amount of time (in this case S(5)) this function is used for rather than use a public and function name, all it knows is to use this function for the time set

And i didnt really plan it out or anything i was just curious if it was possible.