Please help with time - 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: Please help with time (
/showthread.php?tid=95136)
Please help with time -
honzk - 02.09.2009
I have a small FS that should show you how long are you on server, but it works only for id 0...
Please HELP
Pastebin:
http://pastebin.com/f69a1797d
Код:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
forward Time(playerid);
new StartHour[MAX_PLAYERS];
new StartMinute[MAX_PLAYERS];
new StartSecond[MAX_PLAYERS];
new StartTime[MAX_PLAYERS];
new TimeInSeconds[MAX_PLAYERS];
public OnFilterScriptInit()
{
print("FS 'helpbot' loaded...");
return 1;
}
#endif
public Time(playerid)
{
new Hour, Minute, Second, Aktualni;
gettime(Hour, Minute, Second);
Aktualni = Hour*3600 + Minute*60 + Second;
TimeInSeconds[playerid] = Aktualni - StartTime[playerid];
return 1;
}
public OnPlayerConnect(playerid)
{
SetTimer("Time", 1000, true);
gettime(StartHour[playerid], StartMinute[playerid], StartSecond[playerid]);
StartTime[playerid] = StartHour[playerid]*3600 + StartMinute[playerid]*60 + StartSecond[playerid];
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/time"))
{
new Hour, Minute, Second, string[256], string2[256];
gettime(Hour, Minute, Second);
format(string, sizeof(string), "Current time: %d:%d:%d CET / %d:%d:%d GMT", Hour, Minute, Second, Hour - 1, Minute, Second);
format(string2, sizeof(string), "You are here: 0 hours, 0 minutes and %d seconds", TimeInSeconds[playerid]);
SendClientMessage(playerid, 0xFFFF00FF, string);
SendClientMessage(playerid, 0xFFFF00FF, string2);
return 1;
}
return 0;
}
Re: Please help with time -
daals - 02.09.2009
Instead of using 'SetTimer', try using 'SetTimerEx', check the wiki for the syntax.
Re: Please help with time -
honzk - 02.09.2009
Thank you very much!
Re: Please help with time -
honzk - 02.09.2009
But it's still not working!
Re: Please help with time -
Correlli - 02.09.2009
Did you changed:
pawn Код:
SetTimer("Time", 1000, true);
to:
pawn Код:
SetTimerEx("Time", 1000, true, "i", playerid);
?