forward SetTimerByTimes(functionsname[],timemin,timemax);
public SetTimerByTimes(functionsname[],timemin,timemax)
{
new Times[3];
gettime(Times[0], Times[1], Times[2]);
if((Times[0]- timemin) > (Times[0]- timemax)){
newtimer = SetTimerEx("Test",((Times[0] < timemin)?(((timemin-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)):(((24-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)+(timemin*60*60*1000))),false,"sii",functionsname,timemin,timemax);
state call:min;
}else{
newtimer = SetTimerEx("Test",((Times[0] < timemax)?(((timemax-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)):(((24-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)+(timemax*60*60*1000))),false,"sii",functionsname,timemin,timemax);
state call:max;
}
return 1;
}
error 086: unknown automaton "functionsname"
forward Test(functionsname[],timemin,timemax);
public Test(functionsname[],timemin,timemax)<call:min>
{
new Times[3];
gettime(Times[0], Times[1], Times[2]);
CallLocalFunction(functionsname,"");
state call:max;
newtimer = SetTimerEx("Test",((Times[0] < timemax)?(((timemax-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)):(((24-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)+(timemax*60*60*1000))),false,"ii",timemin,timemax);
return 1;
}
public Test(functionsname[],timemin,timemax)<call:max>
{
new Times[3];
gettime(Times[0], Times[1], Times[2]);
CallLocalFunction(functionsname,"");
state call:min;
newtimer = SetTimerEx("Test",((Times[0] < timemin)?(((timemin-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)):(((24-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)+(timemin*60*60*1000))),false,"ii",timemin,timemax);
return 1;
}
SetTimerByTimes("btest",12,22);
forward btest();
public btest()<call:min>
{
printf("Hallo");
return 1;
}
public btest()<call:max>
{
printf("By");
return 1;
}
|
A better question is WHY? What are you trying to achieve? This seems like an instance of the "X-Y" problem - you have some problem "X" and you think you have a solution "Y", but you don't know how to do "Y" so you ask how. It would be better if you told us what the problem you were trying to solve was as it is highly likely that there is a different, better solution.
If not, could you at least rephrase your question as I have no idea what you actually mean - there are no stock functions in that code, I don't know what line gives the error you quoted, and your two "SetTimerEx" lines look identical. Actually, looking at that, why not just name the two "Test" functions something different from each other? |
#define CalculateTime(%0,%1,%2,%3) (((%0-(%1+1))*60*60*1000) +((60-(%2+1))*60*1000)+((60-%3)*1000))
#define CalculateTimeToNextDay(%0,%1,%2,%3) (((24-(%1+1))*60*60*1000) +((60-(%2+1))*60*1000)+((60-%3)*1000)+(%0*60*60*1000))
#define pTime%0(%1) forward%0(id); public%0(id)
#if !defined MAX_TIMERS
#define MAX_TIMERS 10
#endif
new bool:TimerVar[MAX_TIMERS char];
new TimerName[MAX_TIMERS][20];
forward SetTimerByTimes(functionsname[],timemin,timemax, id);
public SetTimerByTimes(functionsname[],timemin,timemax, id)
{
new Times[3], var;
Times[0] = 16;
Times[1] = 59;
Times[2] = 0;
//gettime(Times[0], Times[1], Times[2]);
if((Times[0]- timemin) > (Times[0]- timemax) && (Times[0]- timemin) < 0){
SetTimerEx("TimerKonfig",((Times[0] < timemin)?CalculateTime(timemin,Times[0], Times[1], Times[2]):CalculateTimeToNextDay(timemin,Times[0], Times[1], Times[2])),false,"siii",functionsname,timemin,timemax,id);
TimerVar{id} = true;
var = (Times[0] < timemin)?CalculateTime(timemin,Times[0], Times[1], Times[2]):CalculateTimeToNextDay(timemin,Times[0], Times[1], Times[2]);
printf("Time %d time from start timer %d %d %d",var,Times[0], Times[1], Times[2]);
strins(TimerName[id],functionsname,0);
}else{
SetTimerEx("TimerKonfig",((Times[0] < timemax)?CalculateTime(timemax,Times[0], Times[1], Times[2]):CalculateTimeToNextDay(timemax,Times[0], Times[1], Times[2])),false,"siii",functionsname,timemin,timemax,id);
TimerVar{id} = false;
strins(TimerName[id],functionsname,0);
}
return id;
}
forward TimerKonfig(functionsname[],timemin,timemax, id);
public TimerKonfig(functionsname[],timemin,timemax, id)
{
new Times[3];
gettime(Times[0], Times[1], Times[2]);
if(TimerVar[id]){
CallRemoteFunction(TimerName[id],"d",id);
SetTimerEx("Test",((Times[0] < timemin)?(((timemin-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)):(((24-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)+(timemin*60*60*1000))),false,"ii",timemin,timemax);
TimerVar{id} = false;
}else{
CallLocalFunction(TimerName[id],"d",id);
SetTimerEx("Test",((Times[0] < timemin)?(((timemin-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)):(((24-(Times[0]+1))*60*60*1000) +((60-(Times[1]+1))*60*1000)+((60-Times[2])*1000)+(timemin*60*60*1000))),false,"ii",timemin,timemax);
TimerVar{id} = true;
}
return 1;
}
SetTimerByTimes("btest",17,20,0);
pTime btest()
{
if(TimerVar{id}){
printf("btest1");
}else{
printf("btest2");
}
return 1;
}
pTime btest()<btest:min>
{
return 1;
}
pTime btest()<btest:max>
{
return 1;
}
public SetTimerByTimes(functionsname[],timemin,timemax, id)
{
....
state functionsname:min;
SetTimerByTimes("btest",17,20,0);
public SetTimerByTimes(functionsname[],timemin,timemax, id)
{
....
state btest:min;