define outside of a repeating code part?
#1

hi,

lets take a look at this code:

pawn Код:
forward Timer1Sec();
public Timer1Sec()
{
        new rhour,rminute,rsecond;
        gettime(rhour,rminute,rsecond);
        new stringt[22],stringts[10];
        format(stringt,sizeof stringt,"~y~%d~w~:~y~%d",rhour,rminute);
        TextDrawSetString(RealTime,stringt);
        format(stringts,sizeof stringts,"~w~%d",rsecond);
        TextDrawSetString(RealTimeS,stringts);
        return 1;
}
This is a code to show and update a clock textdraw displaying the real time to all players.
It runs in a timer with an interval of 1 second so the textdraw (that is showing also seconds in the clock) runs smooth.
Now my question is, shall i better define the variables outside of this repeating code (outside this timer?) or doesntit matter at all?
Cause right now it is included in the timer with all the other code and that would mean it is redefined every second, right?

So should i better do it like this or doesnt it matter?

pawn Код:
//On top of script
new rhour,rminute,rsecond;
new stringt[22],stringts[10];

forward Timer1Sec();
public Timer1Sec()
{
        gettime(rhour,rminute,rsecond);
        format(stringt,sizeof stringt,"~y~%d~w~:~y~%d",rhour,rminute);
        TextDrawSetString(RealTime,stringt);
        format(stringts,sizeof stringts,"~w~%d",rsecond);
        TextDrawSetString(RealTimeS,stringts);
        return 1;
}

Would be happy about help and also rep+
Reply


Messages In This Thread
define outside of a repeating code part? - by PawnoQ - 03.01.2012, 03:29
Re: define outside of a repeating code part? - by coole210 - 03.01.2012, 05:56
Respuesta: define outside of a repeating code part? - by [Nikk] - 03.01.2012, 05:56

Forum Jump:


Users browsing this thread: 2 Guest(s)