SetWorldTime - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetWorldTime (
/showthread.php?tid=264315)
SetWorldTime -
ludesert - 25.06.2011
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 =)
Re: SetWorldTime -
Willow - 25.06.2011
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;
}
Re : SetWorldTime -
ludesert - 25.06.2011
I have sscanf stock, and it works for other cmds, so I think it's ok =)
Re : SetWorldTime -
ludesert - 25.06.2011
I don't know how to use zcmds, how can I use it as a dcmd please ? Thanks =)
Re : SetWorldTime -
ludesert - 25.06.2011
Nobody ?
Re: SetWorldTime -
iPLEOMAX - 25.06.2011
I don't see any error with your command. Do you have any other function that modifies the game time?
Re : SetWorldTime -
ludesert - 25.06.2011
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).
Re: Re : SetWorldTime -
iPLEOMAX - 25.06.2011
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.
Re : SetWorldTime -
ludesert - 25.06.2011
I Will searched that tomorrow ! Tank you for tour informations
Re : SetWorldTime -
ludesert - 26.06.2011
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 =)