GetConsoleVarAsString float Server Crash
#2

You can use this as non stable way to check stream_distance vaule at the moment until this bug gets fixed.

how it works?
Sending rcon command varlist by the script then by a help from FileManager plugin move server log to scriptfiles folder then read last lines and get stream_distance vaule.

FileManager Plugin:
http://www.jatochnietdan.com/project/sa-mp/filemanager

Script:

PHP Code:
#include a_samp
#include filemanager
#pragma dynamic 18000
Float:GetServerVarAsFloat(var[])
{
   new 
Handle[5500];
   if(!
strcmp(var,"stream_distance"true))
   {
      
strcat(HandleGetServerLog());
      new 
where strfind(Handle"stream_distance"true0);
      
strdel(Handle0where);
      
strdel(Handle0strfind(Handle,"="true0)+2);
      
where strfind(Handle,"(float)"true0);
      if(
where != -1)
      {
         
strdel(Handlewherestrlen(Handle));
      }
      
fremove("server_log.txt");
   }       
   else
   {
      
Handle "0.0";
   }
   return 
floatstr(Handle);
}
GetServerLog()
{
   
SendRconCommand("varlist");
   
file_copy("server_log.txt""scriptfiles/server_log.txt");
   new 
File:handle fopen("server_log.txt"io_read);
   new 
Handle[5500];
   if(
handle)
   {
       
fseek(handle, -5000seek_end);
       new 
buf[350];
       while(
fread(handlebuf))
       {
          
strcat(Handlebuf);
       }
       new 
where strfind(Handle,"Console Variables:"truewhere)+1;
       while(
strlen(Handle) && strfind(Handle,"Console Variables:"truewhere))
       {
          
where strfind(Handle,"Console Variables:"truewhere)+1;
          
strdel(Handle0where-1);
       }
       
fclose(handle);
   }
   else
   {
      
Handle "stream_distance       = 301.000000";
   }
   return 
Handle;

Usage example:

PHP Code:
public OnFilterScriptInit()
{
   new 
str[128];
   
format(strsizeof str,"stream_distance Vaule is: %f"GetServerVarAsFloat("stream_distance"));
   
SendClientMessageToAll(-1str);

Reply


Messages In This Thread
GetConsoleVarAsString float Server Crash - by Freaksken - 29.07.2016, 20:18
Re: GetConsoleVarAsString float Server Crash - by jlalt - 04.08.2016, 09:22
Re: GetConsoleVarAsString float Server Crash - by Freaksken - 06.08.2016, 20:49
Re: GetConsoleVarAsString float Server Crash - by LolerotehC - 14.08.2016, 03:36
Re: GetConsoleVarAsString float Server Crash - by Sew_Sumi - 17.08.2016, 04:10

Forum Jump:


Users browsing this thread: 1 Guest(s)