Create new state machines with different automaton in a public
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
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?
Ok Thank you ****** for answering.

I often ask for other solutions because i always remember for the statement of Einstein
"Problems can be never solved from the same level of thinking with which they were created."

I have an other solutions and it works




PHP код:
#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,timemaxid);
public 
SetTimerByTimes(functionsname[],timemin,timemaxid)
{
    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,timemaxid);
public 
TimerKonfig(functionsname[],timemin,timemaxid)
{
    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;

but the timer has an delay from around 1 Minute per hour.

But now to my first problem.
I wanted to use state for the called function.
but now when i call the functions i use an if statement
PHP код:
SetTimerByTimes("btest",17,20,0); 
PHP код:
pTime btest()
{
    if(
TimerVar{id}){
        
printf("btest1");
    }else{
        
printf("btest2");
    }
    return 
1;

But i wanted to use state and made it so

PHP код:
pTime btest()<btest:min>
{
    return 
1;

PHP код:
pTime btest()<btest:max>
{
    return 
1;

Where is the problem there?
I think that it is not possibel to create a new state maschine with the name of the function in
the example
PHP код:
public SetTimerByTimes(functionsname[],timemin,timemaxid)
{
....
state functionsname:min
that if i use my function SetTimerByTimes. it have to create the automaton with the name of this string

PHP код:
SetTimerByTimes("btest",17,20,0); 
PHP код:
public SetTimerByTimes(functionsname[],timemin,timemaxid)
{
....
state btest:min
I hope it was now evident and yes I know that my first explanation was very difficult to understand, because I didn't know exactly what I want.
Reply


Messages In This Thread
Create new state machines with different automaton in a public - by IPrototypeI - 26.01.2013, 21:39
AW: Re: Create new state machines with different automaton in a public - by IPrototypeI - 27.01.2013, 15:40

Forum Jump:


Users browsing this thread: 2 Guest(s)