Saving time/weather with dini
#1

Hello, how to use dini to save the weather I select with /settime everytime the server closes? I managed to do it with score and weapon but don't find anyway for data such as time or weather.

Thanks for your help.

(I already searched, and found nothing useful)
Reply
#2

You should save the time and weather when you use the command /settime instead of when the server closes. The saved time and weather will still be up to date as it is saved every time you use the command.
Reply
#3

Thanks, do you know how I can do this ?
Reply
#4

Quote:
Originally Posted by Adamsy
Посмотреть сообщение
Thanks, do you know how I can do this ?
I can try help you, can you show me the code of your /settime command?
Reply
#5

Here you go, sorry btw, I'm not using zcmd I have so much troubles with it idk why.

pawn Код:
//------------------------------Set time----------------------------------------


 if(strcmp(cmdtext, "/asettime") == 0)
  {
        tmp = strtok(cmdtext, idx);
        new time = strval(tmp);
        if(logged[playerid] == 0)
    {
    SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to use that command!");
    return 1;
    }
    if(PlayerInfo[playerid][pAdmin] < 1)
    {
    SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not admin.");
    return 1;
    }
     if(!strlen(tmp))
    {
     SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /asettime [hour]");
      return 1;
          }
      if(time < 0 || time > 23)
      {
        SendClientMessage(playerid, COLOR_BRIGHTRED, "Time must be between 0 and 23 hours!");
        return 1;
      }
      else if(logged[playerid] == 1)
      {
      SetWorldTime(time);
      format(string, sizeof(string), "Time has been changed for %d hour(s).", time);
      SendClientMessage(giveplayerid, COLOR_ORANGE, string);
      }
        return 1;
  }
Reply
#6

First, make a saving system with enum like you do for a player.

enum sInfo
{
weather,
time
};

Make a saving system with it and CMD.
And when server get online
use https://sampwiki.blast.hk/wiki/SetWeather
use https://sampwiki.blast.hk/wiki/SetWorldTime

Simple.
Reply
#7

Player infos are located in their own files but I don't know how to store informations in a new file I created called "server.ini"

( I want to save "weather" in "server.ini" and read it everytime the server opens. But I have no idea what to use at which callback. )
Reply
#8

I made it, it works. Thanks anyway!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)