SetWorldTime
#1

Hello, I'm scripting a GM and I want to create a command to set the time. So, I searched on the net and I maked this :

pawn Код:
dcmd_heure(playerid,params[])
{
  if (!IsPlayerAdmin(playerid))
  return SendClientMessage(playerid, 0xFF0000AA, "Vous n'кtes pas administrateur !");
  if (!params[0])
  return SendClientMessage( playerid, 0xFF9900, "Utilisation : /Heure [heure] -- L'heure rentrйe doit кtre numйrique.");

  new
    string[ 70 ],
    h = strval( params );

  if (h < 0 || h > 24) return SendClientMessage( playerid, 0xFF0000AA, "Erreur ! Veuillez rentrer un nombre compris entre 1 et 24 inclus.");
  SetWorldTime(h);
  format(string, sizeof(string), "%s a changй l'heure ! Il est maintenant %d h !", GetName(playerid), h);
  SendClientMessageToAll(0xCC0099, string );
  return 1;
}
with this stock :

pawn Код:
stock GetName(playerid)
{
    new Name[MAX_PLAYER_NAME];

    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, Name, sizeof(Name));
    }
    else
    {
        Name = "Disconnected/Nothing";
    }

    return Name;
}
It works, but after I change the time, the server returns to my computer's time (GMT+1, France time).

So, how can I change the time definitly ?

Thanks a lot =)
Reply
#2

Just made it quick with zcmd, you just have to edit it for your needs and it should work... I haven't tested it!
You will need a sscanf plugin or include!
Код:
CMD:settime(playerid,params[])
{
	new time,string[128];
	if(!IsPlayerAdmin(playerid)) {
	    return /* not admin, put message here*/
	}
	if(sscanf(params,"d",time); {
	    return /* invalid syntax, putt message here */
	}
	if(time >= 0 && time < 24)
	{
	    SetWorldTime(playerid,time);
	    format(string,sizeof(string),"%s changed time, time is now %d hours!", PlayerName(playerid),time);
	    SendClientMessageToAll(COLOR_WHITE,string);
	    return 1;
	}
	else {
		/* invalid time, put message here */
	}
}


stock PlayerName(playerid)
{
	new name[24];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}
Reply
#3

I have sscanf stock, and it works for other cmds, so I think it's ok =)
Reply
#4

I don't know how to use zcmds, how can I use it as a dcmd please ? Thanks =)
Reply
#5

Nobody ?
Reply
#6

I don't see any error with your command. Do you have any other function that modifies the game time?
Reply
#7

No. I searched (CTLR + F) in m'y GM, ans there is no SetWorldTime in the GM (only in the command).

Can it ve in the filterscript ? I use the basics filterscripts, they are with the server pack (in the zip that i downloaded).
Reply
#8

Quote:
Originally Posted by ludesert
Посмотреть сообщение
I use the basics filterscripts, they are with the server pack (in the zip that i downloaded).
Yes, search in the other FS, it should be there somewhere which is changing/syncing your game time with pc.
Reply
#9

I Will searched that tomorrow ! Tank you for tour informations
Reply
#10

I found the error. In the default server.cfg file, the filterscript gl_realtime is loaded. It was the source fo the problem ! Now, my command works perfectly and the time doesn't change ! Thanks =)
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)