09.01.2012, 06:27
pawn Code:
stock secs2hms(secs,&hours,&minutes,&seconds) {if (secs<0) return false;minutes = secs / 60; seconds = secs % 60;hours = minutes / 60; minutes = minutes % 60;return 1;}
now notice the &hours, & ... , the & sign means you pass a variable by reference, so the function will actually SET that variable, it's like you provide more than 1 output variable, if no & (however eg arrays are exceptions, eg strcopy) it means it's input [again, arrays are exceptions, I won't go deeper into it],
Now we want to know how many hours, mins, seconds , 3661 seconds is,
we start making our variables:
pawn Code:
new MyKnownSeconds = 3661;
new Seconds;
new Minutes;
new Hours;
pawn Code:
public OnFilterScriptInit()
{
new MyKnownSeconds = 3661;
new Seconds;
new Minutes;
new Hours;
secs2hms(/*input*/ MyKnownSeconds, /*output*/Hours,Minutes,Seconds);//Assign Hours,Minutes,Seconds the correct values, you can replace MyKnownSeconds by an number also, eg 3661
printf("H: %d M: %d S: %d",Hours,Minutes,Seconds);
return 1;
}
Code:
H: 1 M: 1 S: 1