Post: Timer Code: Please Help
02-03-2011, 07:06 PM #1
Amanda
Can’t trickshot me!
(adsbygoogle = window.adsbygoogle || []).push({}); So here is a very simple code I made for my patch. All I want is to set this 5 minute timer in a gamemode I made to prevent a crash issue... The problem is that every second the new font string is placed over the previews one and covers it and after a while the game freezes... Any ideas how to make a normal timer?

    timer() {
self endon("disconnect");
limit = 300;
while(limit > 0)
{
limit --;
wait 1;

if (limit<300) {
min=4;
sec=limit-240;
}
else if (limit<240) {
min=3;
sec=limit-180;
}
else if (limit<180) {
min=2;
sec=limit-120;
}
else if (limit<120) {
min=1;
sec=limit-60;
}
else if (limit<60) {
min=0;
sec=limit;
}
else {
min=0;
sec=0;
} Anto = self createFontString("default", 1.5);
Anto setPoint("TOPRIGHT", "TOPRIGHT", -5, 0);
Anto setText( "^1Match Ends in: "+min+" : "+sec );
}
level thread maps\mp\gametypes\_gamelogic::forceEnd();
}
(adsbygoogle = window.adsbygoogle || []).push({});
02-03-2011, 10:29 PM #2
FrOoTLoOpZ
Got MILK?
Originally posted by Amanda View Post
So here is a very simple code I made for my patch. All I want is to set this 5 minute timer in a gamemode I made to prevent a crash issue... The problem is that every second the new font string is placed over the previews one and covers it and after a while the game freezes... Any ideas how to make a normal timer?

    timer() {
self endon("disconnect");
limit = 300;
while(limit > 0)
{
limit --;
wait 1;

if (limit<300) {
min=4;
sec=limit-240;
}
else if (limit<240) {
min=3;
sec=limit-180;
}
else if (limit<180) {
min=2;
sec=limit-120;
}
else if (limit<120) {
min=1;
sec=limit-60;
}
else if (limit<60) {
min=0;
sec=limit;
}
else {
min=0;
sec=0;
} Anto = self createFontString("default", 1.5);
Anto setPoint("TOPRIGHT", "TOPRIGHT", -5, 0);
Anto setText( "^1Match Ends in: "+min+" : "+sec );
}
level thread maps\mp\gametypes\_gamelogic::forceEnd();
}


just use this
    dotimer()
{
F = createServerFontString( "default", 1.5 );
F setPoint( "TOPRIGHT", "TOPRIGHT", -5, 0 );
F.sort = 1001;
F setTimer(300);
Self thread doFroot(F);
}

doFroot(Loopz)
{
wait 300;
Loopz destroy();
}

The following user thanked FrOoTLoOpZ for this useful post:

Amanda
02-03-2011, 11:26 PM #3
Amanda
Can’t trickshot me!
Thank you. I didn't know that there is a ready to use setTimer function! Anyway this is my fixed code Smile I replaced the fontstring with iprintln to prevent the overflows...
    timer() {
self endon("disconnect");
limit=300;
while(limit > 0)
{
limit --;

if(limit>=240){
min=4;
sec=limit-240;
}
else if(limit>=180){
min=3;
sec=limit-180;
}
else if(limit>=120){
min=2;
sec=limit-120;
}
else if(limit>=60){
min=1;
sec=limit-60;
}
else if(limit>0){
min=0;
sec=limit;
}
else
{
min=0;
sec=0;
}
if (sec>=10)
self iprintln("^1Match Ends in: 0"+min+" : "+sec);
else
self iprintln("^1Match Ends in: 0"+min+" : 0"+sec);
if (limit<=10 && limit>0) self thread maps\mp\gametypes\_gamelogic::playTickingSound();
wait 1;
}
level thread maps\mp\gametypes\_gamelogic::forceEnd();
}

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo