Auto Updater.. - 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: Auto Updater.. (
/showthread.php?tid=270182)
Auto Updater.. -
Luis- - 19.07.2011
Hello, I have attempted to make an auto updater for the players scores and to set the world time, my code just doesn't seem to work, it prints out the time like I have scripted it to:
pawn Код:
forward secondupdater(playerid);
public secondupdater(playerid)
{
new hour, minute, second;
gettime(hour, minute, second);
if(minute == 60 && second == 0)
{
hour++;
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
SetWorldTime(hour);
if(hour == 24)
{
hour = 0;
}
}
printf("Hour: %d, Minutes: %d, Seconds: %d.", hour, minute, second);
if(minute == 60 && second == 0)
{
printf("New Hour: %d.", hour);
}
return 1;
}
I just don't understand it, should it be a SetTimer or SetTimerEx also?
Re: Auto Updater.. -
Famalamalam - 19.07.2011
Maybe you should run a loop in there and just have it as a standalone function which you should then run on SetTimerEx..? Give it a whirl.
Re: Auto Updater.. -
Luis- - 19.07.2011
Doesn't seem to work.
Re: Auto Updater.. -
Famalamalam - 19.07.2011
Hm. Show me all the code ... like how are you implementing the function..?
Re: Auto Updater.. -
Luis- - 19.07.2011
pawn Код:
forward secondupdater();
public secondupdater()
{
new hour, minute, second;
gettime(hour, minute, second);
for(new i; i < MAX_PLAYERS; i ++)
{
if(minute == 60 && second == 0)
{
hour++;
SetPlayerScore(i, GetPlayerScore(i) + 1);
SetWorldTime(hour);
if(hour == 24)
{
hour = 0;
}
}
}
printf("Hour: %d, Minutes: %d, Seconds: %d.", hour, minute, second);
if(minute == 60 && second == 0)
{
printf("New Hour: %d.", hour);
}
return 1;
}
Re: Auto Updater.. -
Famalamalam - 19.07.2011
I have no idea.. If that doesn't work then I don't know what's going on... try running it on SetTimer now you have a loop.
Re: Auto Updater.. -
wups - 19.07.2011
I'm 99% sure, that there is no 60'th minute.
Do it my way:
pawn Код:
new CurrentHour;
// on top
forward secondtimer();
public secondtimer()
{
new hour,minute,second;
gettime(hour,minute,second);
if(hour != CurrentHour)
{
CurrentHour=hour;
for(new playerid;playerid<MAX_PLAYERS;playerid++) if(IsPlayerConnected(playerid) SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
SetWorldTime(hour);
}
}
// And it should be done like this OnGameModeInit.
SetTimer("secondtimer",1000,false);
Re: Auto Updater.. -
Famalamalam - 19.07.2011
Shit... the fuck. This is true..........