AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   checking latency between server frames (https://forums.alliedmods.net/showthread.php?t=141253)

Voi 10-21-2010 12:18

checking latency between server frames
 
1 Attachment(s)
I want to check the latency in miliseconds between each server frame. After i issue the "check_fps" command i want it to save each value from server_frame(), and when I issue the command again I want it to save all the values in a file, one value at a line.

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Server fps latency checker"
#define VERSION "0"
#define AUTHOR "twoj_stary"

new on_off
new Float:lastframetime

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_srvcmd("check_fps""switch_check")
}

server_frame()
{
    if(
on_off)
    {
    
// (halflife_time() - lastframetime)*1000.0  save the value
    
lastframetime == halflife_time()
    }
}

switch_check()
{
    if(!
on_off)
    {
        
server_print("starting to check latency of each server frame")
        
on_off 1
    
}
    else
    {
        
on_off 0
        server_print
("stopped checking, saving report file to %s"/*FILE+PATH*/)
    }



fysiks 10-21-2010 13:14

Re: checking latency between server frames
 
So . . . what's the question?

Voi 10-21-2010 13:43

Re: checking latency between server frames
 
Quote:

After i issue the "check_fps" command i want it to save each value from server_frame(), and when I issue the command again I want it to save all the values in a file, one value at a line.
I don't know how to save the milisecond value and later save them all in a file one value at line.

I hope its clear now :P

fysiks 10-21-2010 13:52

Re: checking latency between server frames
 
write_file()

Sylwester 10-21-2010 17:32

Re: checking latency between server frames
 
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Server fps latency checker"
#define VERSION "0"
#define AUTHOR "twoj_stary"

new bool:on_off
new g_fh

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_srvcmd("check_fps""switch_check")
}

public 
server_frame()
{
    static 
Float:last_frame
    
if(!on_off)
        return
    new 
Float:curr_frame get_gametime()
    new 
tmp[16]
    
formatex(tmp15"%f^n"curr_frame-last_frame)
    
fputs(g_fhtmp)
    
last_frame curr_frame
}

public 
switch_check()
{
    static 
filename[128]
    if(!(
on_off=!on_off))
    {
        
server_print("stopped checking, saving report file to %s"filename)
        
fclose(g_fh)
        return
    }

    
get_basedir(filename127)
    
format(filename127,  "%s/logs/frame_time_%d.log"filenameget_systime())
    
g_fh fopen(filename"wt")
    if(!
g_fh)
    {
        
on_off=false
        server_print
("failed to open log file %s"filename)
        return
    }
    
server_print("starting to check latency of each server frame")
}

public 
plugin_end()
{
    if(
g_fh)
        
fclose(g_fh)



Voi 10-21-2010 20:14

Re: checking latency between server frames
 
Thanks/Dziekuje :)


All times are GMT -4. The time now is 10:21.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.