FeaturesQuote• Shows random messages after every 60 seconds without using a timer.
• Will show different message every minute.
• Message #1 will be repeated once it reaches last recorded message i.e Message #10. And so on.
• This snippet doesn't require Random(min,max) function.
OnScriptLoadMSGTick <- 0;
tCount <- 0;
OnTimeChange if(MSGTick < 61) { //check to increase
MSGTick++; // INCREASES EVERY SECOND
}
else if(MSGTick > 59) { // checks when 1min passes
MSGTick = 0;
tCount ++;
local m1 = "[#ffff00]Add the server to favourites", m2 = "please read /rules", m3 = "[#FFFFFF]Server made by : YOURNAME"; // You can edit these and add even more messages here make sure to tCount = 0; on last msg.
if(tCount == 1) {
Message(" "+m1+" ");
}
else if(tCount == 2) {
Message(" "+m2+" ");
}
else if(tCount == 3) { // 3rd and last msg
Message(" "+m3+" ");
tCount = 1; // to return to message #1
}
}
Wait, is there a function called onTimeChange in VC:MP? Damn me, I never knew.
Quote from: Athanatos on Nov 21, 2020, 10:31 AMWait, is there a function called onTimeChange in VC:MP? Damn me, I never knew.
Yeah. Its like OnTimeChange(newHr, oldHr, newMin, oldMin) .
Quote from: Inferno on Nov 21, 2020, 11:22 AMQuote from: Athanatos on Nov 21, 2020, 10:31 AMWait, is there a function called onTimeChange in VC:MP? Damn me, I never knew.
Yeah. Its like OnTimeChange(newHr, oldHr, newMin, oldMin) .
Never saw it in the VC:MP's documentation.
Same. Until a friend used it for playtime system.
In such cases, it's good to tell us so we can fix the wiki, if it is the case.
Official wiki was down and i was using Thijn's one until the adtec one came.
There are many event functions which i recently came across
This OnTimeChange
And OnPlayerModuleList.
but why OnTimeChange when we can use a timer? I guess doing same thing with a timer is same unless you hate "newtimer" word :P
Quote from: KX on Nov 23, 2020, 01:46 AMbut why OnTimeChange when we can use a timer? I guess doing same thing with a timer is same unless you hate "newtimer" word :P
Perhaps, he posted a example to let others know how the function can be useful like timer..
Quote from: KX on Nov 23, 2020, 01:46 AMbut why OnTimeChange when we can use a timer? I guess doing same thing with a timer is same unless you hate "newtimer" word :P
Having a tick function is more effecient in some cases over newTimer.
I had been using a bankcamp timer using NewTimer, and it used to kick me out of bank even when i left bank before 60s and enter at like 58 or 59s.
Since on Linus servers, its not preferred to kill timers.
Also as Shy mentioned above. Its just an example of How this can be as useful as NewTimer.
You can basically use this for any Continuous 1s interval timer. Or even others.
Having a tick function IS ALWAYS better than timers. Timers are responsible for crashes and memory leaks. And that's a known fact.
Quote from: Athanatos on Nov 23, 2020, 06:54 AMHaving a tick function IS ALWAYS better than timers. Timers are responsible for crashes and memory leaks. And that's a known fact.
Exactly, also it can be manually stopped/start using variables unlike timers which even can memory leaks upon starting/stopping.
Quote from: Inferno on Nov 21, 2020, 11:17 PMOfficial wiki was down and i was using Thijn's one until the adtec one came.
There are many event functions which i recently came across
This OnTimeChange
And OnPlayerModuleList.
Fixed.
Everyone gangsta until I tell you that onTimeChange is the same thing as Timers except that it may even be SLOWER in official squirrel plugin since the internals of the plugin uses onServerFrame (An unexposed event) which checks for game time change EVERY TICK and triggers onTimeChange when last value doesn't match new one.
Whereas Timer's are also processed at each FRAME but don't go through the checks of:-
1) Process TIMERS
2) Last game time (onTimeChange)
Whereas timer only checks for:
1) Process Timer
https://i.imgur.com/LUcrUoe.png
So would it cause more memory leaks than actual NewTimer?
Quote from: Inferno on Nov 23, 2020, 01:04 PMSo would it cause more memory leaks than actual NewTimer?
No
But atleast it would be a workaround for the generic Timer crashes in VC:MP, right?
Quote from: Athanatos on Nov 24, 2020, 09:14 AMBut atleast it would be a workaround for the generic Timer crashes in VC:MP, right?
Yes but it's one of the worst workarounds you can think of. As the onTimeChange is dependent on the server's time rate, if you change the time rate, your whole server will be messed up.