SA-MP Forums Archive
Problem with date timer - 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: Problem with date timer (/showthread.php?tid=207960)



Problem with date timer - ThomasTailor93 - 07.01.2011

Hello ladies and guys,

I wrote yesterday a timer for my server. This timer should write every 60 minutes the date of the day to every player only once. But in fact the server send this message 30+ times. I don't know what a failure I made. I hope anybody can help me with this:

pawn Код:
forward DatumTimer();
Under GameModeInit

pawn Код:
SetTimer("DatumTimer",36000000,true);
The whole code:

pawn Код:
public DatumTimer()
{
    new year, month, day;
    getdate (year, month, day);
    new coordsstring[256];
    format(coordsstring, sizeof(coordsstring),"SERVER: Datum: %d.%d.%d",day,month,year);
    SendClientMessageToAll(0xFF0000FF,coordsstring);
    return 1;
}
Regards, ThomasTailor93


Re: Problem with date timer - JaTochNietDan - 07.01.2011

I don't see anything that would cause the message to be sent more than once every 60 minutes to each player. Are you sure you're not using a timer to call "DatumTimer" function somewhere else?

Also additionally your string length is madness! 256 cells for that message? The message has a max length of around 24! That's a lot of wasted memory being allocated

Edit: You've also got an extra 0 in the timer length, which means it's called every 10 hours instead of 1 hour!


AW: Problem with date timer - ThomasTailor93 - 07.01.2011

Hi JaTochNietDan,
thanks for your help. I defined "DatumTimer" only once and I'm using it only in this function. Hm...strange

Edit: Language failure ^^
Edit 2: Well, I could be fixed after setting up string. And I put the timer to an other position. Anyway, thanks for help.