Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Weird string issue that's just confusing me.

$
0
0
Say you've got this:

PHP Code:

#include <a_samp>

static serverUptime;

main() {
    
serverUptime gettime();

    for(new 
indexindex 10index++) {
        static 
output[255/* irrelevant cellsize*/];
        
strcat(outputreturnString());
        print(
output);
    }
}

returnString() {
    static 
output[64];

    static 
secondshoursdaysminutes;
    
seconds gettime()-serverUptime;

    while(
seconds >= 86400) {
        
seconds -= 86400;
        
days++;
    }

    while(
seconds >= 3600) {
        
seconds -= 3600;
        
hours++;
    }

    while(
seconds >= 60) {
        
seconds -= 60;
        
minutes++;
    }

    
format(outputsizeof output"%i day(s), %i hour(s), %i minute(s), %i second(s)"dayshoursminutesseconds);
    return 
output;


(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:
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



Why?

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>