SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 08/11/2018, 08:13 PM   #1
Mobtiesgangsa
Big Clucker
 
Mobtiesgangsa's Avatar
 
Join Date: Oct 2016
Location: Skopje, Macedonia
Posts: 131
Reputation: 11
Default save\load server runtime hours

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
Code:
[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
also i want to save it with a standard file reader and writer

* file.inc *

Code:
/* File input/output functions
 *
 * (c) 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);
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?

Code:
#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;
}
EDIT: forgot to edit code
Mobtiesgangsa is online now   Reply With Quote
Old 08/11/2018, 08:24 PM   #2
cSharp
Little Clucker
 
Join Date: Oct 2018
Posts: 36
Reputation: 1
Default Re: save\load server runtime hours

There's no surprise in knowing that the SA:MP timers are inaccurate, has always been.

https://forum.sa-mp.com/showthread.php?t=650736
cSharp is offline   Reply With Quote
Old 08/11/2018, 08:43 PM   #3
Mobtiesgangsa
Big Clucker
 
Mobtiesgangsa's Avatar
 
Join Date: Oct 2016
Location: Skopje, Macedonia
Posts: 131
Reputation: 11
Default Re: save\load server runtime hours

Quote:
Originally Posted by cSharp View Post
There's no surprise in knowing that the SA:MP timers are inaccurate, has always been.

https://forum.sa-mp.com/showthread.php?t=650736
true, since i lost all my samp data becouse of hard drive failure and got some real life work to accomplish, didnt have time to do soo, thanks for heads up cSharp;4063909 , any idea to save load or suggest me an example?
Mobtiesgangsa is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Server Crashing after 13+ hours of runtime DaniceMcHarley Server Support 4 31/10/2018 11:23 AM
mysql table doesn't load/save, or load take very long time Inuro Scripting Help 5 22/08/2017 10:21 PM
How to save server variables in a file and load it on filterscirpt init? Adarsh007 Scripting Help 1 29/09/2016 04:21 PM
MySQL does not save, been searching for hours. milanosie Scripting Help 16 24/08/2012 12:40 PM
Script can't be load (Runtime Error 18) Awesome™ Scripting Help 3 06/09/2011 01:48 AM


All times are GMT. The time now is 12:29 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.