Say you've got this:
(a random example)
Now, you'd expect this to output the uptime once, 10 times. however, it repeats it over and over. (note that i've used strcat in this example.)
output of the code:
Why?
PHP Code:
#include <a_samp>
static serverUptime;
main() {
serverUptime = gettime();
for(new index; index < 10; index++) {
static output[255/* irrelevant cellsize*/];
strcat(output, returnString());
print(output);
}
}
returnString() {
static output[64];
static seconds, hours, days, minutes;
seconds = gettime()-serverUptime;
while(seconds >= 86400) {
seconds -= 86400;
days++;
}
while(seconds >= 3600) {
seconds -= 3600;
hours++;
}
while(seconds >= 60) {
seconds -= 60;
minutes++;
}
format(output, sizeof output, "%i day(s), %i hour(s), %i minute(s), %i second(s)", days, hours, minutes, seconds);
return output;
}
Now, you'd expect this to output the uptime once, 10 times. however, it repeats it over and over. (note that i've used strcat in this example.)
output of the code:
PHP Code:
Filterscripts
---------------
Loaded 0 filterscripts.
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute
0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute(s), 0 second(s)0 day(s), 0 hour(s), 0 minute
Number of vehicle models: 0
Why?