08.11.2018, 19:13
hello community i am making a server-based server time counter, but i have a question, a little dilema "doubts" about the system
Server logs printed, see red color
also i want to save it with a standard file reader and writer
* file.inc *
to use it for writting to an existing file on my scriptfiles folder, later on when gamemode\server reboots to load data from that dir\file no extra re-write's to see the server running time in-game.
any suggestion's you might like to give or help how to proceed to save and write file as an example?
EDIT: forgot to edit code
Server logs printed, see red color
Код:
[21:02:24] 00:00:50 [21:02:25] 00:00:51 [21:02:26] 00:00:52 [21:02:28] 00:00:53 [21:02:29] 00:00:54 [21:02:30] 00:00:55 [21:02:31] 00:00:56 [21:02:33] 00:00:57 [21:02:33] 00:00:58 /__ didn't print 00:00:59 later 00:01:00 [21:02:34] 00:01:00 \ [21:02:35] 00:01:01 [21:02:36] 00:01:02 [21:02:37] 00:01:03 [21:02:39] 00:01:04 [21:02:40] 00:01:05 [21:02:41] 00:01:06 [21:02:42] 00:01:07 [21:02:43] 00:01:08 [21:02:44] 00:01:09 [21:02:45] 00:01:10 [21:02:46] 00:01:11 [21:02:47] 00:01:12
* file.inc *
Код:
/* File input/output functions * * © Copyright 2004-2005, ITB CompuPhase * This file is provided as is (no warranties). */ #if defined _file_included #endinput #endif #define _file_included #pragma library File enum filemode { io_read, /* file must exist */ io_write, /* creates a new file */ io_readwrite, /* opens an existing file, or creates a new file */ io_append, /* appends to file (write-only) */ } enum seek_whence { seek_start, seek_current, seek_end, } const EOF = -1; native File:fopen(const name[], filemode: mode = io_readwrite); native bool:fclose(File: handle); native File:ftemp(); native bool:fremove(const name[]); native fwrite(File: handle, const string[]); native fread(File: handle, string[], size = sizeof string, bool: pack = false); native bool:fputchar(File: handle, value, bool: utf8 = true); native fgetchar(File: handle, value, bool: utf8 = true); native fblockwrite(File: handle, const buffer[], size = sizeof buffer); native fblockread(File: handle, buffer[], size = sizeof buffer); native fseek(File: handle, position = 0, seek_whence: whence = seek_start); native flength(File: handle); native fexist(const pattern[]); native bool:fmatch(name[], const pattern[], index = 0, size = sizeof name);
any suggestion's you might like to give or help how to proceed to save and write file as an example?
Код:
#include <a_samp> enum s_data { s_hours, s_minutes, s_seconds } new s_run_time[s_data]; new run_time_timer = 0; //new File: run_time; forward public ServerRunTimer(); main() { } public OnGameModeInit() { run_time_timer = SetTimer("ServerRunTimer", 1000, true); return 1; } public OnGameModeExit() { KillTimer(run_time_timer); return 1; } public ServerRunTimer() { s_run_time[s_seconds]++; if(s_run_time[s_seconds] == 59) { s_run_time[s_seconds] = 0; s_run_time[s_minutes]++; } else if(s_run_time[s_minutes] == 59) { s_run_time[s_minutes] = 0; s_run_time[s_hours]++; } printf("%02d:%02d:%02d", s_run_time[s_hours], s_run_time[s_minutes], s_run_time[s_seconds]); return 1; }