Post: Need Help with code on of function anyone???
12-29-2015, 02:59 AM #1
UkHazeOG
Bounty hunter
(adsbygoogle = window.adsbygoogle || []).push({}); Hello My name is callum and i am new to gsc SCRIPTING i seem to have got the codes correct but i am missing somthing that enables the function to turn on and off for EG: i load up my game open menu press function (INFINATE GAME) it works then i turn it off and then try enable it again and it just keeps saying OFF in the bottom left hand side this is my code if you could give me any infomation atall on what i am doing wrong it would be really appreciated thank you for your time Smile



Inf_Game()
{
if(self.ingame==false)
{
self.ingame=true;
setDvar("scr_dom_scorelimit",0);
setDvar("scr_sd_numlives",0);
setDvar("scr_war_timelimit",0);
setDvar("scr_game_onlyheadshots",0);
setDvar("scr_war_scorelimit",0);
setDvar("scr_player_forcerespawn",1);
maps\mp\gametypes\_globallogic_utils::pausetimer();
self iPrintln("Infinity Game [^2ON^7]");
}
else
{
self maps\mp\gametypes\_globallogic_utils::resumetimer();
self iPrintln("Infinity Game [^1OFF^7]");
}
}
(adsbygoogle = window.adsbygoogle || []).push({});
12-29-2015, 10:07 PM #11
EternalHabit
Former Staff
Originally posted by BullyWiiPlaza View Post
Alright but the score limit set to 0 is for real infinity. Just saying :P


nahh because that will just end the game
12-29-2015, 10:29 PM #12
BullyWiiPlaza
Climbing up the ladder
Originally posted by xTurntUpLobbies View Post
nahh because that will just end the game

Nah, I'm using this and it works. Here is the "optimized" code version. You can try it for yourself Winky Winky

    toggleInfiniteTime()
{
level.unlimitedGame = invertAndPrint("Unlimited Game", level.unlimitedGame, true); // Use your own way to do the toggle

if(level.unlimitedGame)
{
registerScoreLimit(0, 0);
maps\mp\gametypes\_globallogic_utils::pauseTimer();
}
else
{
registerScoreLimit(0, 9999999);
maps\mp\gametypes\_globallogic_utils::resumeTimer();
}
}
12-30-2015, 11:59 PM #13
Originally posted by BullyWiiPlaza View Post
Nah, I'm using this and it works. Here is the "optimized" code version. You can try it for yourself Winky Winky

    toggleInfiniteTime()
{
level.unlimitedGame = invertAndPrint("Unlimited Game", level.unlimitedGame, true); // Use your own way to do the toggle

if(level.unlimitedGame)
{
registerScoreLimit(0, 0);
maps\mp\gametypes\_globallogic_utils::pauseTimer();
}
else
{
registerScoreLimit(0, 9999999);
maps\mp\gametypes\_globallogic_utils::resumeTimer();
}
}


You can further optimize this code like so, although I'm not 100% sure the compiler supports ternary method calling, but you can try:
    
toggleInfiniteTime()
{
level.unlimitedGame = invertAndPrint("Unlimited Game", level.unlimitedGame, true); // Use your own way to do the toggle

registerScoreLimit(0, level.unlimitedGame ? 0 : 9999999);
level.unlimitedGame ? maps\mp\gametypes\_globallogic_utils::pauseTimer() : maps\mp\gametypes\_globallogic_utils::resumeTimer();
}
12-31-2015, 01:29 AM #14
BullyWiiPlaza
Climbing up the ladder
Originally posted by Sabojohn View Post
You can further optimize this code like so, although I'm not 100% sure the compiler supports ternary method calling, but you can try:
    
toggleInfiniteTime()
{
level.unlimitedGame = invertAndPrint("Unlimited Game", level.unlimitedGame, true); // Use your own way to do the toggle

registerScoreLimit(0, level.unlimitedGame ? 0 : 9999999);
level.unlimitedGame ? maps\mp\gametypes\_globallogic_utils::pauseTimer() : maps\mp\gametypes\_globallogic_utils::resumeTimer();
}

Yeah, that would work but it's ugly with more than one line ternary. It's okay though Smile

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo