Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import host
- import bf2
- import realitytimer
- import realityadmin
- import realityconfig_admin
- g_fps_counter = 0
- g_fps_current = 0
- g_fps_time = 0
- g_timer = None
- def tick( data ):
- global g_fps_counter, g_fps_current, g_fps_time
- g_fps_counter += 1
- if g_fps_counter == 200:
- currentTime = time.time()
- g_fps_current = (200/(currentTime - g_fps_time))
- host.rcon_invoke('game.sayall "Server FPS: %s"' % g_fps_current)
- destroyTimer()
- def statusChanged(status):
- # Register the commands on map load
- if status == bf2.GameStatus.Loaded:
- realityadmin.g_adminCommands['fps'] = measureFPS
- realityconfig_admin.adm_adminPowerLevels['fps'] = 777
- # Just incase
- if status == bf2.GameStatus.EndGame:
- destroyTimer()
- def measureFPS( args, p ):
- global g_timer, g_fps_counter, g_fps_time
- if g_timer: # Don't try measuring if we're already measuring
- return
- host.rcon_invoke('game.sayall "Measuring FPS..."')
- g_timer = realitytimer.Timer(tick, -1, 1)
- g_timer.setRecurring(0.0001)
- g_fps_counter = 0
- g_fps_time = time.time()
- def destroyTimer():
- global g_timer
- if g_timer:
- g_timer.destroy()
- g_timer = None
- host.registerGameStatusHandler( statusChanged )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement