Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define ROUNDS 100
- forward TimerCallback();
- new timer_id = -1;
- new tick = 0;
- new tick_differential = 0;
- new last_tick = 0;
- new tick_counter = 0;
- new Float:tick_average = 0.0;
- new tick_goal = 1000;
- new caught_min = 10000;
- new caught_max = 0;
- new tick_catcher[ROUNDS];
- public OnGameModeInit() {
- last_tick = GetTickCount();
- timer_id = SetTimer("TimerCallback", tick_goal, 1);
- return 1;
- }
- public TimerCallback() {
- tick = GetTickCount();
- tick_differential = (tick - last_tick) - tick_goal;
- if(tick_differential < 0 || tick_differential > ROUNDS-2) {
- tick_catcher[ROUNDS-1]++;
- } else {
- tick_catcher[tick_differential]++;
- }
- if(tick_differential < caught_min)
- caught_min = tick_differential;
- if(tick_differential > caught_max)
- caught_max = tick_differential;
- tick_counter++;
- tick_average = tick_average + ((tick_differential - tick_average) / (tick_counter + 1.0));
- last_tick = tick;
- printf("Tick: %d", tick);
- printf("Tick diff: %d", tick_differential);
- printf("Tick avg: %f", tick_average);
- print("================");
- if(tick_counter > ROUNDS) {
- showResults();
- }
- return 1;
- }
- showResults() {
- KillTimer(timer_id);
- print("================");
- print("================");
- print("================");
- new string[256];
- for(new i = 0; i < ROUNDS; i++) {
- if(i < caught_min || i > caught_max)
- continue;
- if(i >= 10)
- format(string, sizeof(string), "%s%d,", string, i);
- else
- format(string, sizeof(string), "%s0%d,", string, i);
- }
- printf("%s", string);
- format(string, sizeof(string), "");
- for(new i = 0; i < ROUNDS; i++) {
- if(i < caught_min || i > caught_max)
- continue;
- new l = tick_catcher[i];
- if(l >= 10)
- format(string, sizeof(string), "%s%d,", string, l);
- else
- format(string, sizeof(string), "%s0%d,", string, l);
- }
- printf("%s", string);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement