Post: Overflow Fix By CoolJay [Black Ops II][Utility]
07-07-2016, 10:13 AM #1
(adsbygoogle = window.adsbygoogle || []).push({});
You must login or register to view this content.

`🍓
Overview:

- Hello people of NGU, i know there are already multiple other posts and tutorials on Overflow fix's, and this is just a additional version to them,to put it simple, what i have brought new for all of you is that this automatically resets the string to text elements when the Overflow Fix happens without you needing to define what text you want to reset in a function like RecreateText(), its very simple but i've never seen people do it this way so i thought i would make a post about it. This makes it really convenient because it works with any kind of gamemode or mod menu you wish to create. This post will also explain in depth how a Overflow Fix works since i see alot of confusion around it, hopefully clearing up that

Why You Would Want A Overflow Fix:

- Black Ops 2 is limited in terms of the amount of unique strings you can use with SetText()
and basically when using text huds on your screen in game you will eventually find yourself running into this
"Overflow" error that will backyou out of the game. Why does this happen? well when every you create
a text element using such as a CreateText() function, it sets all the individual components for it for example
font, fontscale, alignment, color, glowcolor, alpha etc, along side with your "text" which is set by doing SetText(yourtexthere) and thats what you will find inside all CreateText() functions of any kind.
This function adds unique strings to the game and the game is limited to how many unique strings you can use for text elements.

- The issue is not when you have so many text elements all over your screen at once, but the amount of times you use SetText(yourtexthere) with a string you haven't used before for any text elements as a whole in total, and all players contribute to hitting this limit. So if you use SetText(yourtexthere) for a text element and the string you use has already been used before on the same text element or any other text element it would of been added to a string table and won't contribute to the overflow anymore until its cleared from the stringtable. The limit varies for each game mode in the game, but for an example, team deathmatch's string limit is 64 strings before the game Overflows so if you have under "64" text elements using the same or individual different strings created in total without ever changing text the game won't ever Overflow, however with gamemodes and menus, people will want to update the text for a textelement consistently using the SetText(yourtexthere) function, and add new text elements into the game in general. This becomes a problem so a Overflow Fix is needed.
What The Overflow Fix Does:

- The Overflow Fix counts every time a new unique string is added to the string table and once you reach a certain limit it then uses ClearAllTextAfterHudElem(). This clears all the strings for every text element (up to 118 text elements made after the anchor) and removes them from the stringtable and then afterwards the Overflow Fix resets the text for them by getting the text for ever text element via a text element table to reset themselves to the last text they had previously, if the text element was destroyed before hand it won't reset. All of this is what stops the game Overflowing.

- If you have more text elements then the string limit is regardless of whether or not its been reset consistently then the Overflow Fix will not work for you. This issue can be resolved though by using SyGnUs's String Fix which gives you a additional 172 strings to use. This can allow you to have a maximum of 12 unique string text elements per player in a 18 player game on team deathmatch all on screen at the same time, although in most gsc gamemodes/menus players are using the same strings so you could probably get away with alot more without noticing this. Another thing is that ClearAllTextAfterHudElem() can only clear 118 strings at a time so it is used multiple times for when SyGnUs's String Fix is used.
How To Add This Overflow Fix To Your GSC Project:

Step 1:

- Add a new .gsc file to your project, it can be named what ever you like but ill call it "Overflowfix.gsc"
then add the following code within that .gsc file:

    OverflowFix()
{
level Waittill("connected", player);
level.stringtable = [];
level.textelementtable = [];
textanchor = CreateServerFontString("default", 1);
textanchor SetElementText("Anchor");
textanchor.alpha = 0;

if (GetDvar("g_gametype") == "tdm" || GetDvar("g_gametype") == "hctdm")
limit = 54;
if (GetDvar("g_gametype") == "dm" || GetDvar("g_gametype") == "hcdm")
limit = 54;
if (GetDvar("g_gametype") == "dom" || GetDvar("g_gametype") == "hcdom")
limit = 38;
if (GetDvar("g_gametype") == "dem" || GetDvar("g_gametype") == "hcdem")
limit = 41;
if (GetDvar("g_gametype") == "conf" || GetDvar("g_gametype") == "hcconf")
limit = 53;
if (GetDvar("g_gametype") == "koth" || GetDvar("g_gametype") == "hckoth")
limit = 41;
if (GetDvar("g_gametype") == "hq" || GetDvar("g_gametype") == "hchq")
limit = 43;
if (GetDvar("g_gametype") == "ctf" || GetDvar("g_gametype") == "hcctf")
limit = 32;
if (GetDvar("g_gametype") == "sd" || GetDvar("g_gametype") == "hcsd")
limit = 38;
if (GetDvar("g_gametype") == "oneflag" || GetDvar("g_gametype") == "hconeflag")
limit = 25;
if (GetDvar("g_gametype") == "gun")
limit = 48;
if (GetDvar("g_gametype") == "oic")
limit = 51;
if (GetDvar("g_gametype") == "shrp")
limit = 48;
if (GetDvar("g_gametype") == "sas")
limit = 50;
if (IsDefined(level.stringoptimization))
limit += 172;

while (!level.gameended)
{
if (IsDefined(level.stringoptimization) && level.stringtable.size >= 100 && !IsDefined(textanchor2))
{
textanchor2 = CreateServerFontString("default", 1);
textanchor2 SetElementText("Anchor2");
textanchor2.alpha = 0;
}
if (level.stringtable.size >= limit)
{
if (IsDefined(textanchor2))
{
textanchor2 ClearAllTextAfterHudElem();
textanchor2 DestroyElement();
}

textanchor ClearAllTextAfterHudElem();
level.stringtable = [];

foreach (textelement in level.textelementtable)
{
if (!IsDefined(self.label))
textelement SetElementText(textelement.text);
else
textelement SetElementValueText(textelement.text);
}
}

wait 0.01;
}
}

SetElementText(text)
{
self SetText(text);

if (self.text != text)
self.text = text;
if (!IsInArray(level.stringtable, text))
level.stringtable[level.stringtable.size] = text;
if (!IsInArray(level.textelementtable, self))
level.textelementtable[level.textelementtable.size] = self;
}

SetElementValueText(text)
{
self.label = &"" + text;

if (self.text != text)
self.text = text;
if (!IsInArray(level.stringtable, text))
level.stringtable[level.stringtable.size] = text;
if (!IsInArray(level.textelementtable, self))
level.textelementtable[level.textelementtable.size] = self;
}

DestroyElement()
{
if (IsInArray(level.textelementtable, self))
ArrayRemoveValue(level.textelementtable, self);
if (IsDefined(self.elemtype))
{
self.frame Destroy();
self.bar Destroy();
self.barframe Destroy();
}

self Destroy();
}
Step 2:

- In your main.gsc file you will want to add:

    level thread OverflowFix();

- You need to put this in a point in the code where its called
before any other text is created in your gsc.
Calling it inside Init() is the best place.

Here's an example:

    //Inside of [B]Init()[/B]
level thread OverflowFix();

Step 3:

- You will need to replace any instance in your code that contained
    SetText(text);
and replace it with
    SetElementText(text);
and
    Destroy();
and replace it with
    DestroyElement();

- That's It Completed Smile
How To Add String Optimization To Your GSC Project:

- All though this is not necessary you may want it if you use alot of text elements in your GSC.
This is version is unique to my Overflow fix that determines whether you are using string optimization or not

Step 1:

- Add a new gsc project, and name it _rank.gsc
then add the following code within that .gsc file:

    #include maps/mp/gametypes/_globallogic;
#include maps/mp/gametypes/_hud;
#include maps/mp/gametypes/_hud_util;
#include maps/mp/_scoreevents;
#include maps/mp/_utility;
#include common_scripts/utility;

ClearStrings()
{
level.stringoptimization = true;
level.scoreinfo = [];
level.xpscale = GetDvarFloat("scr_xpscale");
level.codpointsxpscale = GetDvarFloat("scr_codpointsxpscale");
level.codpointsmatchscale = GetDvarFloat("scr_codpointsmatchscale");
level.codpointschallengescale = GetDvarFloat("scr_codpointsperchallenge");
level.clearstrings = GetDvarInt("scr_rankXpCap");
level.codpointscap = GetDvarInt("scr_codPointsCap");
level.usingmomentum = 1;
level.usingscorestreaks = GetDvarInt("scr_scorestreaks");
level.scorestreaksmaxstacking = GetDvarInt("scr_scorestreaks_maxstacking");
level.maxinventoryscorestreaks = GetDvarIntDefault("scr_maxinventory_scorestreaks", 3);

if (IsDefined(level.usingscorestreaks))
level.usingrampage = !level.usingscorestreaks;

level.rampagebonusscale = GetDvarFloat("scr_rampagebonusscale");
level.ranktable = [];
PrecacheShader("white");

if (!SessionModeIsZombiesGame())
InitScoreInfo();

level.maxrank = Int(TableLookUp("mp/rankTable.csv", 0, "maxrank", 1));
level.maxprestige = Int(TableLookUp("mp/rankIconTable.csv", 0, "maxprestige", 1));

pid = 0;
rid = 0;
pid = 0;

while (pid <= level.maxprestige)
{
rid = 0;

while (rid <= level.maxrank)
{
PrecacheShader(TableLookUp("mp/rankIconTable.csv", 0, rid, pid + 1));
rid++;
}

pid++;
}

rankid = 0;
rankname = TableLookUp("mp/ranktable.csv", 0, rankid, 1);

while (IsDefined(rankname) && rankname != "")
{
level.ranktable[rankid][1] = TableLookUp("mp/ranktable.csv", 0, rankid, 1);
level.ranktable[rankid][2] = TableLookUp("mp/ranktable.csv", 0, rankid, 2);
level.ranktable[rankid][3] = TableLookUp("mp/ranktable.csv", 0, rankid, 3);
level.ranktable[rankid][7] = TableLookUp("mp/ranktable.csv", 0, rankid, 7);
level.ranktable[rankid][14] = TableLookUp("mp/ranktable.csv", 0, rankid, 14);
rankid++;
rankname = TableLookUp("mp/ranktable.csv", 0, rankid, 1);
}

level thread OptimizationPlayerConnect();
}

InitScoreInfo()
{
scoreinfotableid = GetScoreEventTableID();

if (!IsDefined(scoreinfotableid))
return;

scorecolumn = GetScoreEventColumn(level.gametype);
xpcolumn = GetXPEventColumn(level.gametype);

if (scorecolumn < 0)
return;

if (xpcolumn < 0)
return;

row = 1;

while (row < 512)
{
type = TableLookUpColumnForRow(scoreinfotableid, row, 0);

if (type != "")
{
labelstring = TableLookUpColumnForRow(scoreinfotableid, row, 1);
label = undefined;

if (labelstring != "")
label = TableLookUpiString(scoreinfotableid, 0, type, 1);

scorevalue = Int(TableLookUpColumnForRow(scoreinfotableid, row, scorecolumn));
RegisterScoreInfo(type, scorevalue, label);

if (maps/mp/_utility::GetRoundsPlayed() == 0)
{
xpvalue = Float(TableLookUpColumnForRow(scoreinfotableid, row, xpcolumn));
setddlstat = TableLookUpColumnForRow(scoreinfotableid, row, 5);
addplayerstat = 0;

if (setddlstat == "TRUE")
addplayerstat = 1;

ismedal = 0;
istring = TableLookUpiString(scoreinfotableid, 0, type, 2);

if (IsDefined(istring) && istring != &"")
ismedal = 1;

demobookmarkpriority = Int(TableLookUpColumnForRow(scoreinfotableid, row, 6));

if (!IsDefined(demobookmarkpriority))
demobookmarkpriority = 0;

RegisterXP(type, xpvalue, addplayerstat, ismedal, demobookmarkpriority, row);
}

allowkillstreakweapons = TableLookUpColumnForRow(scoreinfotableid, row, 4);

if (allowkillstreakweapons == "TRUE")
level.scoreinfo[type]["allowKillstreakWeapons"] = 1;
}

row++;
}
}

GetRankXPCapped(inrankxp)
{
if (IsDefined(level.clearstrings) && level.clearstrings && level.clearstrings <= inrankxp)
return level.clearstrings;

return inrankxp;
}

GetCodPointsCapped(incodpoints)
{
if (IsDefined(level.codpointscap) && level.codpointscap && level.codpointscap <= incodpoints)
return level.codpointscap;

return incodpoints;
}

RegisterScoreInfo(type, value, label)
{
overridedvar = "scr_" + level.gametype + "_score_" + type;

if (GetDvar(overridedvar) != "")
value = GetDvarInt(overridedvar);

if (type == "kill")
{
multiplier = GetGameTypeSetting("killEventScoreMultiplier");
level.scoreinfo[type]["value"] = Int((multiplier + 1) * value);
}
else
level.scoreinfo[type]["value"] = value;

if (IsDefined(label))
{
PrecacheString(&"MP_PLUS");
level.scoreinfo[type]["label"] = &"MP_PLUS";
level.scoreinfo[type]["label"] = &"";
}
}

GetScoreInfoValue(type)
{
if (IsDefined(level.scoreinfo[type]))
return level.scoreinfo[type]["value"];
}

GetScoreInfoLabel(type)
{
return level.scoreinfo[type]["label"];
}

KillstreakWeaponsAllowedScore(type)
{
if (IsDefined(level.scoreinfo[type]["allowKillstreakWeapons"]) && level.scoreinfo[type]["allowKillstreakWeapons"] == 1)
return 1;
else
return 0;
}

DoesScoreInfoCountTowardRampage(type)
{
if (IsDefined(level.scoreinfo[type]["rampage"]))
return level.scoreinfo[type]["rampage"];
}

GetRankInfominXP(rankid)
{
return Int(level.ranktable[rankid][2]);
}

GetRankInfoXPAMT(rankid)
{
return Int(level.ranktable[rankid][3]);
}

GetRankInfoAXXP(rankid)
{
return Int(level.ranktable[rankid][7]);
}

GetRankInfoFull(rankid)
{
return TableLookUpiString("mp/ranktable.csv", 0, rankid, 16);
}

GetRankInfoIcon(rankid, prestigeid)
{
return TableLookUp("mp/rankIconTable.csv", 0, rankid, prestigeid + 1);
}

GetRankInfoLevel(rankid)
{
return Int(TableLookUp("mp/ranktable.csv", 0, rankid, 13));
}

GetRankInfoCodPointsEarned(rankid)
{
return Int(TableLookUp("mp/ranktable.csv", 0, rankid, 17));
}

ShouldKickByRank()
{
if (self IsHost())
return 0;
if (level.rankcap > 0 && self.pers["rank"] > level.rankcap)
return 1;
if (level.rankcap > 0 && level.minprestige == 0 && self.pers["plevel"] > 0)
return 1;
if (level.minprestige > self.pers["plevel"])
return 1;

return 0;
}

GetCodPointsStat()
{
codpoints = self GetDStat("playerstatslist", "CODPOINTS", "StatValue");
codpointscapped = GetCodPointsCapped(codpoints);

if (codpoints > codpointscapped)
self SetCodPointsStat(codpointscapped);

return codpointscapped;
}

SetCodPointsStat(codpoints)
{
self SetDStat("PlayerStatsList", "CODPOINTS", "StatValue", GetCodPointsCapped(codpoints));
}

GetRankXPStat()
{
rankxp = self GetDStat("playerstatslist", "RANKXP", "StatValue");
rankxpcapped = GetRankXPCapped(rankxp);

if (rankxp > rankxpcapped)
self SetDStat("playerstatslist", "RANKXP", "StatValue", rankxpcapped);

return rankxpcapped;
}

OptimizationPlayerConnect()
{
for (;Winky Winky
{
level Waittill("connected", player);
player.pers["rankxp"] = player GetRankXPStat();
player.pers["codpoints"] = player GetCodPointsStat();
player.pers["currencyspent"] = player GetDStat("playerstatslist", "currencyspent", "StatValue");
rankid = player GetRankForXP(player GetRankXP());
player.pers["rank"] = rankid;
player.pers["plevel"] = player GetDStat("playerstatslist", "PLEVEL", "StatValue");

if (player ShouldKickByRank())
{
kick(player GetEntityNumber());
continue;
}
else
{
if (!IsDefined(player.pers["participation"]) || level.gametype == "twar" && game["roundsplayed"] >= 0 && player.pers["participation"] >= 0)
player.pers["participation"] = 0;

player.rankupdatetotal = 0;
player.cur_ranknum = rankid;
prestige = player GetDStat("playerstatslist", "plevel", "StatValue");
player SetRank(rankid, prestige);
player.pers["prestige"] = prestige;

if (!IsDefined(player.pers["summary"]))
{
player.pers["summary"] = [];
player.pers["summary"]["xp"] = 0;
player.pers["summary"]["score"] = 0;
player.pers["summary"]["challenge"] = 0;
player.pers["summary"]["match"] = 0;
player.pers["summary"]["misc"] = 0;
player.pers["summary"]["codpoints"] = 0;
}
if (!level.rankedmatch || level.wagermatch && level.leaguematch)
player SetDStat("AfterActionReportStats", "lobbyPopup", "none");
if (level.rankedmatch)
{
player SetDStat("playerstatslist", "rank", "StatValue", rankid);
player SetDStat("playerstatslist", "minxp", "StatValue", GetRankInfominXP(rankid));
player SetDStat("playerstatslist", "maxxp", "StatValue", GetRankInfoAXXP(rankid));
player SetDStat("playerstatslist", "lastxp", "StatValue", GetRankXPCapped(player.pers["rankxp"]));
}

player.explosivekills[0] = 0;
player thread OptimizationPlayerSpawn();
player thread OptimizationJoinedTeam();
player thread OptimizationJoinedSpectators();
}
}
}

OptimizationJoinedTeam()
{
self Endon("disconnect");

for (;Winky Winky
{
self Waittill("joined_team");
self thread RemoveRankHud();
}
}

OptimizationJoinedSpectators()
{
self Endon("disconnect");

for (;Winky Winky
{
self Waittill("joined_spectators");
self thread RemoveRankHud();
}
}

OptimizationPlayerSpawn()
{
self Endon("disconnect");

for (;Winky Winky
{
self Waittill("spawned_player");

if (!IsDefined(self.hud_rankscroreupdate))
{
self.hud_rankscroreupdate = NewScoreHudElem(self);
self.hud_rankscroreupdate.horzalign = "center";
self.hud_rankscroreupdate.vertalign = "middle";
self.hud_rankscroreupdate.alignx = "center";
self.hud_rankscroreupdate.aligny = "middle";
self.hud_rankscroreupdate.x = 0;

if (self IsSplitScreen())
self.hud_rankscroreupdate.y = -15;
else
self.hud_rankscroreupdate.y = -60;

self.hud_rankscroreupdate.font = "default";
self.hud_rankscroreupdate.fontscale = 2;
self.hud_rankscroreupdate.archived = 0;
self.hud_rankscroreupdate.label = &"MP_PLUS";
self.hud_rankscroreupdate.color = (1, 0, 0);
self.hud_rankscroreupdate.alpha = 0;
self.hud_rankscroreupdate.glowcolor = (1, 0, 0);
self.hud_rankscroreupdate.glowalpha = 0.5;
self.hud_rankscroreupdate.sort = 50;
self.hud_rankscroreupdate maps/mp/gametypes/_hud::FontPulseInit();
}
}
}

IncCodPoints(amount)
{
if (!IsRankEnabled())
return;
if (!level.rankedmatch)
return;

newcodpoints = GetCodPointsCapped(self.pers["codpoints"] + amount);

if (newcodpoints > self.pers["codpoints"])
self.pers["summary"]["codpoints"] += newcodpoints - self.pers["codpoints"];

self.pers["codpoints"] = newcodpoints;
SetCodPointsStat(Int(newcodpoints));
}

AtleastOnePlayerOnEachTeam()
{
foreach(team in level.teams)
{
if (!level.playercount[team])
return false;
}
return true;
}

GiveRankXP(type, value, devadd)
{
self Endon("disconnect");

if (SessionModeIsZombiesGame())
return;

if (level.teambased && !AtleastOnePlayerOnEachTeam() && !IsDefined(devadd))
return;
else
{
if (!level.teambased && maps/mp/gametypes/_globallogic::TotalPlayerCount() < 2 && !IsDefined(devadd))
return;
}
if (!IsRankEnabled())
return;

PixBeginEvent("GiveRankXP");

if (!IsDefined(value))
value = GetScoreInfoValue(type);
if (level.rankedmatch)
BBPrint("mpplayerxp", "gametime %d, player %s, type %s, delta %d", getTime(), self.name, type, value);

switch (type)
{
case "assault": case "assault_assist": case "assist": case "assist_25": case "assist_50": case "assist_75": case "capture": case "defend": case "defuse": case "destroyer": case "dogassist": case "dogkill": case "headshot": case "helicopterassist": case "helicopterassist_25": case "helicopterassist_50": case "helicopterassist_75": case "helicopterkill": case "kill": case "medal": case "pickup": case "plant": case "rcbombdestroy": case "return": case "revive": case "spyplaneassist": case "spyplanekill": value = Int(value * level.xpscale);
break;

default: if (level.xpscale == 0)
value = 0;

break;
}

xpincrease = self IncRankXP(value);

if (level.rankedmatch)
self UpdateRank();
if (value != 0)
self SyncXPStat();
if (IsDefined(self.enabletext) && self.enabletext && !level.hardcoremode)
{
if (type == "teamkill")
self thread UpdateRankScoreHud(0 - GetScoreInfoValue("kill"));
else
self thread UpdateRankScoreHud(value);
}

switch(type)
{
case "assault": case "assist": case "assist_25": case "assist_50": case "assist_75": case "capture": case "defend": case "headshot": case "helicopterassist": case "helicopterassist_25": case "helicopterassist_50": case "helicopterassist_75": case "kill": case "medal": case "pickup": case "return": case "revive": case "suicide": case "teamkill": self.pers["summary"]["score"] += value;
IncCodPoints(Round_This_Number(value * level.codpointsxpscale));

break;

case "loss": case "tie": case "win": self.pers["summary"]["match"] += value;
IncCodPoints(Round_This_Number(value * level.codpointsmatchscale));

break;

case "challenge": self.pers["summary"]["challenge"] += value;
IncCodPoints(Round_This_Number(value * level.codpointschallengescale));

break;

default: self.pers["summary"]["misc"] += value;
self.pers["summary"]["match"] += value;

IncCodPoints(Round_This_Number(value * level.codpointsmatchscale));

break;
}

self.pers["summary"]["xp"] += xpincrease;
PixEndEvent();
}

Round_This_Number(value)
{
value = Int(value + 0.5);
return value;
}

UpdateRank()
{
newrankid = self GetRank();

if (newrankid == self.pers["rank"])
return 0;

oldrank = self.pers["rank"];
rankid = self.pers["rank"];
self.pers["rank"] = newrankid;

while (rankid <= newrankid)
{
self SetDStat("playerstatslist", "rank", "StatValue", rankid);
self SetDStat("playerstatslist", "minxp", "StatValue", Int(level.ranktable[rankid][2]));
self SetDStat("playerstatslist", "maxxp", "StatValue", Int(level.ranktable[rankid][7]));
self.setpromotion = 1;

if (level.rankedmatch && level.gameended && !self IsSplitScreen())
self SetDStat("AfterActionReportStats", "lobbyPopup", "promotion");

if (rankid != oldrank)
{
codpointsearnedforrank = GetRankInfoCodPointsEarned(rankid);
IncCodPoints(codpointsearnedforrank);

if (!IsDefined(self.pers["rankcp"]))
self.pers["rankcp"] = 0;

self.pers["rankcp"] += codpointsearnedforrank;
}

rankid++;
}

self LogString("promoted from " + oldrank + " to " + newrankid + " timeplayed: " + self GetDStat("playerstatslist", "time_played_total", "StatValue"));
self SetRank(newrankid);

return 1;
}

CodeCallback_RankUp(rank, prestige, unlocktokensadded)
{
if (rank > Cool Man (aka Tustin)
self GiveAchievement("MP_MISC_1");

self LuiNotifyEvent(&"rank_up", 3, rank, prestige, unlocktokensadded);
self LuiNotifyEventToSpectators(&"rank_up", 3, rank, prestige, unlocktokensadded);
}

GetItemIndex(refstring)
{
itemindex = Int(TableLookUp("mp/statstable.csv", 4, refstring, 0));
return itemindex;
}

EndGameUpdate()
{
player = self;
}

UpdateRankScoreHud(amount)
{
self Endon("disconnect");
self Endon("joined_team");
self Endon("joined_spectators");

if (amount < 1)
return;

self Notify("update_score");
self Endon("update_score");

wait 0.05;
self.rankupdatetotal += self.killpoints;

if (IsDefined(self.hud_rankscroreupdate) && self.rankupdatetotal > 1)
{
self.hud_rankscroreupdate SetValue(self.rankupdatetotal);
self.hud_rankscroreupdate.alpha = 0.85;
self.hud_rankscroreupdate thread maps/mp/gametypes/_hud::FontPulse(self);
wait 1;
self.hud_rankscroreupdate FadeOverTime(0.75);
self.hud_rankscroreupdate.alpha = 0;
self.rankupdatetotal = 0;
}
}

UpdateMomentumHud(amount, reason, reasonvalue)
{
self Endon("disconnect");
self Endon("joined_team");
self Endon("joined_spectators");

if (amount < 1)
return;

self Notify("update_score");
self Endon("update_score");

wait 0.05;
self.rankupdatetotal += self.killpoints;

if (IsDefined(self.hud_rankscroreupdate) && self.rankupdatetotal > 1)
{
self.hud_rankscroreupdate SetValue(self.rankupdatetotal);
self.hud_rankscroreupdate.alpha = 0.85;
self.hud_rankscroreupdate thread maps/mp/gametypes/_hud::FontPulse(self);
wait 1;
self.hud_rankscroreupdate FadeOverTime(0.75);
self.hud_rankscroreupdate.alpha = 0;
self.rankupdatetotal = 0;
}
}

RemoveRankHud()
{
if (IsDefined(self.hud_rankscroreupdate))
self.hud_rankscroreupdate.alpha = 0;
if (IsDefined(self.hud_momentumreason))
self.hud_momentumreason.alpha = 0;
}

GetRank()
{
rankxp = GetRankXPCapped(self.pers["rankxp"]);
rankid = self.pers["rank"];

if (rankxp < (GetRankInfominXP(rankid) + GetRankInfoXPAMT(rankid)))
return rankid;
else
return self GetRankForXP(rankxp);
}

GetRankForXP(xpval)
{
rankid = 0;
rankname = level.ranktable[rankid][1];

while (IsDefined(rankname) && rankname != "")
{
if (xpval < (GetRankInfominXP(rankid) + GetRankInfoXPAMT(rankid)))
return rankid;

rankid++;

if (IsDefined(level.ranktable[rankid]))
{
rankname = level.ranktable[rankid][1];
continue;
}
else
rankname = undefined;
}

rankid--;
return rankid;
}

GetSPM()
{
ranklevel = self GetRank() + 1;
return (3 + (ranklevel * 0.5)) * 10;
}

GetRankXP()
{
return GetRankXPCapped(self.pers["rankxp"]);
}

IncRankXP(amount)
{
if (!level.rankedmatch)
return 0;

xp = self GetRankXP();
newxp = GetRankXPCapped(xp + amount);

if (self.pers["rank"] == level.maxrank && newxp >= GetRankInfoAXXP(level.maxrank))
newxp = GetRankInfoAXXP(level.maxrank);

xpincrease = GetRankXPCapped(newxp) - self.pers["rankxp"];

if (xpincrease < 0)
xpincrease = 0;

self.pers["rankxp"] = GetRankXPCapped(newxp);
return xpincrease;
}

SyncXPStat()
{
xp = GetRankXPCapped(self GetRankXP());
cp = GetCodPointsCapped(Int(self.pers["codpoints"]));
self SetDStat("playerstatslist", "rankxp", "StatValue", xp);
self SetDStat("playerstatslist", "codpoints", "StatValue", cp);
}


Step 2:

- In your main.gsc file you will want to add:

    //At the top of [B]Init()[/B] just bellow the included gsc list
ClearStrings();

Step 3:

- In order for this to be utilized you must
export your project as a compiled script file and name it "_rank.gsc"
Then you will need to create folders in this format: "maps/mp/gametypes/_rank.gsc"

- then you put "_rank.gsc" in "gametypes".
You will need to inject it as a compiled script file everytime in order
for this to be used in game, if not the game simply won't have
as many strings available when you inject directly.
Updates Log:
Release (07/07/2016): Additional Info:

- You can get the text string for a certain text element using this variable "textelementnamehere.text".
- If you get the error: "MAX_GAMESTATE_CHARS"
its because you've hit the maximum amount of strings you can use, reason being this stores the text elements strings in variables, and your gsc project was very close to the string limit before adding this.
- If you get the error: "EXE_ERR_RELIABLE_CYCLED_OUT"
its because you have called the Overflow Fix thread before players have even spawned in, or because there is too many text elements created/too many text elements being looped to change text and the -Overflow Fix cannot keep up.
Credits: - dtx12
- TheFallen
- jwm614
- xTurntUpLobbies
- Im_YouViolateMe
- Amanda
- SyGnUs
- Loz
- anthonything
Last edited by OfficialCoolJay ; 08-04-2019 at 10:17 AM.

The following 16 users say thank you to OfficialCoolJay for this useful post:

blazethewolf_, BlueeHasSwag, BullyWiiPlaza, DF_AUS, DoraTheKiller97, HiddenHour, Im_YouViolateMe, marmar19, Nothingbutbread, ODLeslie, Patrick, Pink Guy, Reezh, That1Modder, Ways, xexDELL
07-07-2016, 10:58 AM #2
ODLeslie
Do a barrel roll!
Great work mate, this thread was needed, hopefully people take the time to give it a read and take note, considering you've put in the time to make the thread, thanks for posting Enzo
07-07-2016, 11:06 AM #3
DF_AUS
NextGenUpdate Elite
YVM's tut should have been stickied looooooong ago,cant understand why no mods never done it,anyways,good going m8,this should help people.
07-07-2016, 11:57 AM #4
EternalHabit
Former Staff
Credits go to:
dtx12
jwm614
xTurntUpLobbies
Im_YouViolateMe

Anyways strings are cached by the game not by the player (yvm pointed this out to me). Therefore, you can setText using the same exact string as many times as you want and never overflow. Its only when you setText and its a different word the game will count up. If anyone feels like testing this themselves, remove your overflow fix and loop a string count using setText. Reset it to 0 everytime it hits 50 and you won't overflow (as long as it doesnt hit 67 obviously). You could even do it for all players too. Also I've updated my overflow fix quite a bit I may post it sometime soon
Last edited by EternalHabit ; 07-07-2016 at 12:08 PM.

The following 2 users say thank you to EternalHabit for this useful post:

BullyWiiPlaza, OfficialCoolJay
07-07-2016, 12:18 PM #5
Originally posted by xTurntUpLobbies View Post
Credits go to:
dtx12
jwm614
xTurntUpLobbies
Im_YouViolateMe

Anyways strings are cached by the game not by the player (yvm pointed this out to me). Therefore, you can setText using the same exact string as many times as you want and never overflow. Its only when you setText and its a different word the game will count up. If anyone feels like testing this themselves, remove your overflow fix and loop a string count using setText. Reset it to 0 everytime it hits 50 and you won't overflow (as long as it doesnt hit 67 obviously). You could even do it for all players too. Also I've updated my overflow fix quite a bit I may post it sometime soon


oh really, thats good to know, ty for the info ill add to the post
07-07-2016, 04:34 PM #6
anthonything
Space Ninja
Originally posted by OfficialCoolJay View Post
oh really, thats good to know, ty for the info ill add to the post


Heres the one i personally use as it is more effective:
    

overflowfix()
{
level endon("host_migration_begin");
level.uniquestrings = [];
level.test = createServerFontString("default", 1);
level.test setText("NewOverflow");
level.test.alpha = 0;
if(getDvar("g_gametype") == "sd")
max = 45;
else
max = 45;

for(;Winky Winky
{
level waittill("textset");

if(level.uniquestrings.size >= max)
{
level.test ClearAllTextAfterHudElem();
level.uniquestrings = [];

foreach(player in level.players)
{
player UpdateMenu(false, true);
}
}
wait 0.01;
}
}

setSafeText(text)
{
if( !isinarray(level.uniquestrings, text ) )
{
level.uniquestrings = add_to_array(level.uniquestrings, text, 0 );
level notify("textset");
}
self setText(text);
}



Putting a loop on each elem is quite messy and allows more chances for freezing.
And your explanation is technically incorrect, but no reason to correct because it doesn't really affect the outcome.
Last edited by anthonything ; 07-07-2016 at 04:38 PM.
07-08-2016, 02:01 AM #7
Originally posted by anthonything View Post
Heres the one i personally use as it is more effective:
    

overflowfix()
{
level endon("host_migration_begin");
level.uniquestrings = [];
level.test = createServerFontString("default", 1);
level.test setText("NewOverflow");
level.test.alpha = 0;
if(getDvar("g_gametype") == "sd")
max = 45;
else
max = 45;

for(;Winky Winky
{
level waittill("textset");

if(level.uniquestrings.size >= max)
{
level.test ClearAllTextAfterHudElem();
level.uniquestrings = [];

foreach(player in level.players)
{
player UpdateMenu(false, true);
}
}
wait 0.01;
}
}

setSafeText(text)
{
if( !isinarray(level.uniquestrings, text ) )
{
level.uniquestrings = add_to_array(level.uniquestrings, text, 0 );
level notify("textset");
}
self setText(text);
}



Putting a loop on each elem is quite messy and allows more chances for freezing.
And your explanation is technically incorrect, but no reason to correct because it doesn't really affect the outcome.


1. Each loop for each text element isnt on a 0.05; constant loop they all just wait until notified so shouldnt be an issue.
2. I tested on very messy large coded gsc menus/gamemodes and no freezing issues after an hour of testing.
3. Things i would debate is the loop for where ClearAllTextAfterHudElem() is, other people use a level waittill("textset"); which stops the loop for looping over and over, but its no big deal really, and using a array for all the strings is probably better tbh, you would need to get the text element name as well and set the correct string to the correct text element,
4. I always had the intention of updating this thread when i learn more or find better ways to do stuff, the explanation probably lacks alot of technical reasoning but none the less it wouldnt steer anyone in the wrong direction.
Last edited by OfficialCoolJay ; 07-08-2016 at 02:17 AM.
07-10-2016, 05:16 AM #8
Originally posted by xTurntUpLobbies View Post
Credits go to:
dtx12
jwm614
xTurntUpLobbies
Im_YouViolateMe

Anyways strings are cached by the game not by the player (yvm pointed this out to me). Therefore, you can setText using the same exact string as many times as you want and never overflow. Its only when you setText and its a different word the game will count up. If anyone feels like testing this themselves, remove your overflow fix and loop a string count using setText. Reset it to 0 everytime it hits 50 and you won't overflow (as long as it doesnt hit 67 obviously). You could even do it for all players too. Also I've updated my overflow fix quite a bit I may post it sometime soon


could you help me with something? my skype thechiraqsavage
07-10-2016, 06:49 AM #9
Originally posted by OfficialCoolJay View Post
Hello people of ngu, i know there are already multiple other posts and tutorials on Overflow fix's, and this is just a additional version to them,to put it simple, what i have brought new for all of you is that this automatically resets the string to text elements when the Overflow Fix happens without you needing to define what text you want to reset in a function like RecreateText(), its very simple but ive never seen people do it this way so i thought i would make a post about it. This makes it really convenient because it works with any kind of gamemode or mod menu you wish to create. This post is also to explain in depth how Overflows/Overflow fixs work since i see alot of confusion on this topic hopefully this clears up any confussion and helps all people new to GSC and also may be of use to those whom are GSC veterans


This Post Will Cover:

- Why You Would Want A Overflow Fix

- What The Overflow Fix Does

- How To Add This Overflow Fix To Your GSC

- How To Add Strings Fix To Your GSC

- Additional Info

Why You Would Want A Overflow Fix:

Black Ops 2 is very limited in terms of the amount of custom content you can run in game at a time
and basically when using text huds on your screen in game you will eventually find yourself running into this
"Overflow" error that will backyou out of the game. Why does this happen? well when every you create
a text element using such as a CreateText() function, it sets all the individual components for it for example
font, fontscale, alignment, color, glowcolor, alpha etc, along side with your "text" which is set by doing SetText(yourtexthere) and thats what you will find inside all CreateText() functions of any kind.

The issue is not when you have so many text elements all over your screen at once, but the amount of times you use SetText(yourtexthere) with a string you haven't used before for any text elements as a whole in total, and all players contribute to hitting this limit. So if you use SetText(yourtexthere) for text element and the string you use has already been used before on the same text element or any other text element it would of been added to a string table and won't contribute to the overflow from now on. The limit is "67" before the game Overflows so if you have under "67" text elements created in total including every other players, you won't ever Overflow. A example would be that you have a lobby with 18 players
each player would only be able to have "3" text elements on there screen, anything over and the game will Overflow.
However, with gamemodes and menus, people will want to update the text for a textelement consistently, using the SetText(yourtexthere) function, for example the text in a menu when you change submenus will use SetText(yourtexthere).

What The Overflow Fix Does:

The Overflow Fix counts everytime you use SetText(yourtexthere) and once you reach a certain limit it then uses ClearAllTextAfterHudElem(). This clears all the strings for every text element on screen and then afterwards the Overflow Fix resets the text for them by notifing every text element to reset themselves to the last text they had previously, if the text element was destroyed before hand it won't reset. All of this is what stops the game Overflowing.

If you have over "67" text elements regardless of whether or not its been reset consistently then the Overflow Fix will not work for you. This issue can be resolved though by using SyGnUs's String Fix (original idea by Amanda) which increase the limit from "67" to "240" making the Overflow Fix useful to you still if you have over "67" text elements.

How To Add This Overflow Fix To Your GSC:

Step 1:

Add a new .gsc file to your project, it can be named what ever you like but ill call it "Overflowfix.gsc"
then add the following code within that .gsc file:

    OverflowFix()
{
level.amountoftextset = 0;
firsttext = CreateServerFontString("default", 1.5);
firsttext SetText("CoolJay");
firsttext.alpha = 0;

//Text Limit
if(GetDvar("g_gametype") == "sd")
limit = 40;
else
limit = 50;

//String Fix
if(IsDefined(level.stringsfix))
limit += 180;

for(;Winky Winky
{
if(level.amountoftextset >= limit)
{
firsttext ClearAllTextAfterHudElem();
level.amountoftextset = 0;
level notify("overflow_fixed");
}
wait 0.05;
}
}


Step 2:

In your main.gsc file you will want to add:

    level thread OverflowFix();


You need to put this in a point in the code where its called
before any text is created.

Here's an example:

    //At the bottom of [B]Init()[/B]
level waittill("prematch_over");
level thread OverflowFix();


Step 3:

Find the function you use to create text with for example "CreateText()"
you may have multiple different create text function so apply this step to all of them.

Remove
    SetText(text);
from the function and replace it with
    SetSafeText(text);


Step 4:

Add the following code anywhere in your gsc project you wish

    SetSafeText(text)
{
self SetText(text);
if(!IsDefined(self.text))
self thread SetTextMonitor();
if(self.text != text)
self.text = text;
level.amountoftextset ++;
}

SetTextMonitor()
{
self endon("stop_settextmonitor");

while(IsDefined(self))
{
level waittill("overflow_fixed");
self SetSafeText(self.text);
}
}


That's It Completed Smile

How To Add Strings Fix To Your GSC

All though this is not necessary you may want it if you use alot of text elements in your GSC

Step 1:

Add a new .gsc file to your project, it can be named what ever you like but ill call it "stringfix.gsc"
then add the following code within that .gsc file:

    StringsFix()
{
level.stringsfix = true;
level.scoreinfo = [];
level.xpscale = getDvarFloat( "scr_xpscale" );
level.codpointsxpscale = getDvarFloat( "scr_codpointsxpscale" );
level.codpointsmatchscale = getDvarFloat( "scr_codpointsmatchscale" );
level.codpointschallengescale = getDvarFloat( "scr_codpointsperchallenge" );
level.rankxpcap = getDvarInt( "scr_rankXpCap" );
level.codpointscap = getDvarInt( "scr_codPointsCap" );
level.usingmomentum = 1;
level.usingscorestreaks = getDvarInt( "scr_scorestreaks" ) != 0;
level.scorestreaksmaxstacking = getDvarInt( "scr_scorestreaks_maxstacking" );
level.maxinventoryscorestreaks = getdvarintdefault( "scr_maxinventory_scorestreaks", 3 );
if ( isDefined( level.usingscorestreaks ) )
{
level.usingrampage = !level.usingscorestreaks;
}
level.rampagebonusscale = getDvarFloat( "scr_rampagebonusscale" );
level.ranktable = [];
precacheshader( "white" );
if ( !sessionmodeiszombiesgame() )
{
initscoreinfo();
}
level.maxrank = int( tablelookup( "mp/rankTable.csv", 0, "maxrank", 1 ) );
level.maxprestige = int( tablelookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ) );
pid = 0;
rid = 0;
pid = 0;
while ( pid <= level.maxprestige )
{
rid = 0;
while ( rid <= level.maxrank )
{
precacheshader( tablelookup( "mp/rankIconTable.csv", 0, rid, pid + 1 ) );
rid++;
}
pid++;
}
rankid = 0;
rankname = tablelookup( "mp/ranktable.csv", 0, rankid, 1 );
while ( isDefined( rankname ) && rankname != "" )
{
level.ranktable[ rankid ][ 1 ] = tablelookup( "mp/ranktable.csv", 0, rankid, 1 );
level.ranktable[ rankid ][ 2 ] = tablelookup( "mp/ranktable.csv", 0, rankid, 2 );
level.ranktable[ rankid ][ 3 ] = tablelookup( "mp/ranktable.csv", 0, rankid, 3 );
level.ranktable[ rankid ][ 7 ] = tablelookup( "mp/ranktable.csv", 0, rankid, 7 );
level.ranktable[ rankid ][ 14 ] = tablelookup( "mp/ranktable.csv", 0, rankid, 14 );
rankid++;
rankname = tablelookup( "mp/ranktable.csv", 0, rankid, 1 );
}
level thread stringsfixonplayerconnect();
}
initscoreinfo()
{
scoreinfotableid = getscoreeventtableid();
if ( !isDefined( scoreinfotableid ) )
{
return;
}
scorecolumn = getscoreeventcolumn( level.gametype );
xpcolumn = getxpeventcolumn( level.gametype );
if ( scorecolumn < 0 )
{
return;
}
if ( xpcolumn < 0 )
{
return;
}
row = 1;
while ( row < 512 )
{
type = tablelookupcolumnforrow( scoreinfotableid, row, 0 );
if ( type != "" )
{
labelstring = tablelookupcolumnforrow( scoreinfotableid, row, 1 );
label = undefined;
if ( labelstring != "" )
{
label = tablelookupistring( scoreinfotableid, 0, type, 1 );
}
scorevalue = int( tablelookupcolumnforrow( scoreinfotableid, row, scorecolumn ) );
registerscoreinfo( type, scorevalue, label );
if ( maps/mp/_utility::getroundsplayed() == 0 )
{
xpvalue = float( tablelookupcolumnforrow( scoreinfotableid, row, xpcolumn ) );
setddlstat = tablelookupcolumnforrow( scoreinfotableid, row, 5 );
addplayerstat = 0;
if ( setddlstat == "TRUE" )
{
addplayerstat = 1;
}
ismedal = 0;
istring = tablelookupistring( scoreinfotableid, 0, type, 2 );
if ( isDefined( istring ) && istring != &"" )
{
ismedal = 1;
}
demobookmarkpriority = int( tablelookupcolumnforrow( scoreinfotableid, row, 6 ) );
if ( !isDefined( demobookmarkpriority ) )
{
demobookmarkpriority = 0;
}
registerxp( type, xpvalue, addplayerstat, ismedal, demobookmarkpriority, row );
}
allowkillstreakweapons = tablelookupcolumnforrow( scoreinfotableid, row, 4 );
if ( allowkillstreakweapons == "TRUE" )
{
level.scoreinfo[ type ][ "allowKillstreakWeapons" ] = 1;
}
}
row++;
}
}
getrankxpcapped( inrankxp )
{
if ( isDefined( level.rankxpcap ) && level.rankxpcap && level.rankxpcap <= inrankxp )
{
return level.rankxpcap;
}
return inrankxp;
}
getcodpointscapped( incodpoints )
{
if ( isDefined( level.codpointscap ) && level.codpointscap && level.codpointscap <= incodpoints )
{
return level.codpointscap;
}
return incodpoints;
}
registerscoreinfo( type, value, label )
{
overridedvar = "scr_" + level.gametype + "_score_" + type;
if ( getDvar( overridedvar ) != "" )
{
value = getDvarInt( overridedvar );
}
if ( type == "kill" )
{
multiplier = getgametypesetting( "killEventScoreMultiplier" );
level.scoreinfo[ type ][ "value" ] = int( ( multiplier + 1 ) * value );
}
else
{
level.scoreinfo[ type ][ "value" ] = value;
}
if ( isDefined( label ) )
{
precachestring( &"MP_PLUS" );
level.scoreinfo[ type ][ "label" ] = &"MP_PLUS";
level.scoreinfo[ type ][ "label" ] = &"";
}
}
getscoreinfovalue( type )
{
if ( isDefined( level.scoreinfo[ type ] ) )
{
return level.scoreinfo[ type ][ "value" ];
}
}
getscoreinfolabel( type )
{
return level.scoreinfo[ type ][ "label" ];
}
killstreakweaponsallowedscore( type )
{
if ( isDefined( level.scoreinfo[ type ][ "allowKillstreakWeapons" ] ) && level.scoreinfo[ type ][ "allowKillstreakWeapons" ] == 1 )
{
return 1;
}
else
{
return 0;
}
}
doesscoreinfocounttowardrampage( type )
{
if ( isDefined( level.scoreinfo[ type ][ "rampage" ] ) )
{
return level.scoreinfo[ type ][ "rampage" ];
}
}
getrankinfominxp( rankid )
{
return int( level.ranktable[ rankid ][ 2 ] );
}
getrankinfoxpamt( rankid )
{
return int( level.ranktable[ rankid ][ 3 ] );
}
getrankinfomaxxp( rankid )
{
return int( level.ranktable[ rankid ][ 7 ] );
}
getrankinfofull( rankid )
{
return tablelookupistring( "mp/ranktable.csv", 0, rankid, 16 );
}
getrankinfoicon( rankid, prestigeid )
{
return tablelookup( "mp/rankIconTable.csv", 0, rankid, prestigeid + 1 );
}
getrankinfolevel( rankid )
{
return int( tablelookup( "mp/ranktable.csv", 0, rankid, 13 ) );
}
getrankinfocodpointsearned( rankid )
{
return int( tablelookup( "mp/ranktable.csv", 0, rankid, 17 ) );
}
shouldkickbyrank()
{
if ( self ishost() )
{
return 0;
}
if ( level.rankcap > 0 && self.pers[ "rank" ] > level.rankcap )
{
return 1;
}
if ( level.rankcap > 0 && level.minprestige == 0 && self.pers[ "plevel" ] > 0 )
{
return 1;
}
if ( level.minprestige > self.pers[ "plevel" ] )
{
return 1;
}
return 0;
}
getcodpointsstat()
{
codpoints = self getdstat( "playerstatslist", "CODPOINTS", "StatValue" );
codpointscapped = getcodpointscapped( codpoints );
if ( codpoints > codpointscapped )
{
self setcodpointsstat( codpointscapped );
}
return codpointscapped;
}
setcodpointsstat( codpoints )
{
self setdstat( "PlayerStatsList", "CODPOINTS", "StatValue", getcodpointscapped( codpoints ) );
}
getrankxpstat()
{
rankxp = self getdstat( "playerstatslist", "RANKXP", "StatValue" );
rankxpcapped = getrankxpcapped( rankxp );
if ( rankxp > rankxpcapped )
{
self setdstat( "playerstatslist", "RANKXP", "StatValue", rankxpcapped );
}
return rankxpcapped;
}
stringsfixonplayerconnect()
{
for (;Winky Winky
{
level waittill( "connected", player );
player.pers[ "rankxp" ] = player getrankxpstat();
player.pers[ "codpoints" ] = player getcodpointsstat();
player.pers[ "currencyspent" ] = player getdstat( "playerstatslist", "currencyspent", "StatValue" );
rankid = player getrankforxp( player getrankxp() );
player.pers[ "rank" ] = rankid;
player.pers[ "plevel" ] = player getdstat( "playerstatslist", "PLEVEL", "StatValue" );
if ( player shouldkickbyrank() )
{
kick( player getentitynumber() );
continue;
}
else
{
if ( !isDefined( player.pers[ "participation" ] ) || level.gametype == "twar" && game[ "roundsplayed" ] >= 0 && player.pers[ "participation" ] >= 0 )
{
player.pers[ "participation" ] = 0;
}
player.rankupdatetotal = 0;
player.cur_ranknum = rankid;
prestige = player getdstat( "playerstatslist", "plevel", "StatValue" );
player setrank( rankid, prestige );
player.pers[ "prestige" ] = prestige;
if ( !isDefined( player.pers[ "summary" ] ) )
{
player.pers[ "summary" ] = [];
player.pers[ "summary" ][ "xp" ] = 0;
player.pers[ "summary" ][ "score" ] = 0;
player.pers[ "summary" ][ "challenge" ] = 0;
player.pers[ "summary" ][ "match" ] = 0;
player.pers[ "summary" ][ "misc" ] = 0;
player.pers[ "summary" ][ "codpoints" ] = 0;
}
if ( !level.rankedmatch || level.wagermatch && level.leaguematch )
{
player setdstat( "AfterActionReportStats", "lobbyPopup", "none" );
}
if ( level.rankedmatch )
{
player setdstat( "playerstatslist", "rank", "StatValue", rankid );
player setdstat( "playerstatslist", "minxp", "StatValue", getrankinfominxp( rankid ) );
player setdstat( "playerstatslist", "maxxp", "StatValue", getrankinfomaxxp( rankid ) );
player setdstat( "playerstatslist", "lastxp", "StatValue", getrankxpcapped( player.pers[ "rankxp" ] ) );
}
player.explosivekills[ 0 ] = 0;
player thread stringsfixonplayerspawned();
player thread stringsfixonjoinedteam();
player thread stringsfixonjoinedspectators();
}
}
}
stringsfixonjoinedteam()
{
self endon( "disconnect" );
for (;Winky Winky
{
self waittill( "joined_team" );
self thread removerankhud();
}
}
stringsfixonjoinedspectators()
{
self endon( "disconnect" );
for (;Winky Winky
{
self waittill( "joined_spectators" );
self thread removerankhud();
}
}
stringsfixonplayerspawned()
{
self endon( "disconnect" );
for (;Winky Winky
{
self waittill( "spawned_player" );
if ( !isDefined( self.hud_rankscroreupdate ) )
{
self.hud_rankscroreupdate = newscorehudelem( self );
self.hud_rankscroreupdate.horzalign = "center";
self.hud_rankscroreupdate.vertalign = "middle";
self.hud_rankscroreupdate.alignx = "center";
self.hud_rankscroreupdate.aligny = "middle";
self.hud_rankscroreupdate.x = 0;
if ( self issplitscreen() )
{
self.hud_rankscroreupdate.y = -15;
}
else
{
self.hud_rankscroreupdate.y = -60;
}
self.hud_rankscroreupdate.font = "default";
self.hud_rankscroreupdate.fontscale = 2;
self.hud_rankscroreupdate.archived = 0;
self.hud_rankscroreupdate.color = ( 1, 1, 0.5 );
self.hud_rankscroreupdate.alpha = 0;
self.hud_rankscroreupdate.sort = 50;
self.hud_rankscroreupdate maps/mp/gametypes/_hud::fontpulseinit();
}
}
}
inccodpoints( amount )
{
if ( !isrankenabled() )
{
return;
}
if ( !level.rankedmatch )
{
return;
}
newcodpoints = getcodpointscapped( self.pers[ "codpoints" ] + amount );
if ( newcodpoints > self.pers[ "codpoints" ] )
{
self.pers[ "summary" ][ "codpoints" ] += newcodpoints - self.pers[ "codpoints" ];
}
self.pers[ "codpoints" ] = newcodpoints;
setcodpointsstat( int( newcodpoints ) );
}
atleastoneplayeroneachteam()
{
foreach( team in level.teams )
{
if ( !level.playerCount[team] )
return false;
}
return true;
}
giverankxp( type, value, devadd )
{
self endon( "disconnect" );
if ( sessionmodeiszombiesgame() )
{
return;
}
if ( level.teambased && !atleastoneplayeroneachteam() && !isDefined( devadd ) )
{
return;
}
else
{
if ( !level.teambased && maps/mp/gametypes/_globallogic::totalplayercount() < 2 && !isDefined( devadd ) )
{
return;
}
}
if ( !isrankenabled() )
{
return;
}
pixbeginevent( "giveRankXP" );
if ( !isDefined( value ) )
{
value = getscoreinfovalue( type );
}
if ( level.rankedmatch )
{
bbprint( "mpplayerxp", "gametime %d, player %s, type %s, delta %d", getTime(), self.name, type, value );
}
switch( type )
{
case "assault": case "assault_assist": case "assist": case "assist_25": case "assist_50": case "assist_75": case "capture": case "defend": case "defuse": case "destroyer": case "dogassist": case "dogkill": case "headshot": case "helicopterassist": case "helicopterassist_25": case "helicopterassist_50": case "helicopterassist_75": case "helicopterkill": case "kill": case "medal": case "pickup": case "plant": case "rcbombdestroy": case "return": case "revive": case "spyplaneassist": case "spyplanekill": value = int( value * level.xpscale );
break;
default: if ( level.xpscale == 0 )
{
value = 0;
}
break;
}
xpincrease = self incrankxp( value );
if ( level.rankedmatch )
{
self updaterank();
}
if ( value != 0 )
{
self syncxpstat();
}
if ( isDefined( self.enabletext ) && self.enabletext && !level.hardcoremode )
{
if ( type == "teamkill" )
{
self thread updaterankscorehud( 0 - getscoreinfovalue( "kill" ) );
}
else
{
self thread updaterankscorehud( value );
}
}
switch( type )
{
case "assault": case "assist": case "assist_25": case "assist_50": case "assist_75": case "capture": case "defend": case "headshot": case "helicopterassist": case "helicopterassist_25": case "helicopterassist_50": case "helicopterassist_75": case "kill": case "medal": case "pickup": case "return": case "revive": case "suicide": case "teamkill": self.pers[ "summary" ][ "score" ] += value;
inccodpoints( round_this_number( value * level.codpointsxpscale ) );
break;
case "loss": case "tie": case "win": self.pers[ "summary" ][ "match" ] += value;
inccodpoints( round_this_number( value * level.codpointsmatchscale ) );
break;
case "challenge": self.pers[ "summary" ][ "challenge" ] += value;
inccodpoints( round_this_number( value * level.codpointschallengescale ) );
break;
default: self.pers[ "summary" ][ "misc" ] += value;
self.pers[ "summary" ][ "match" ] += value;
inccodpoints( round_this_number( value * level.codpointsmatchscale ) );
break;
}
self.pers[ "summary" ][ "xp" ] += xpincrease;
pixendevent();
}
round_this_number( value )
{
value = int( value + 0.5 );
return value;
}
updaterank()
{
newrankid = self getrank();
if ( newrankid == self.pers[ "rank" ] )
{
return 0;
}
oldrank = self.pers[ "rank" ];
rankid = self.pers[ "rank" ];
self.pers[ "rank" ] = newrankid;
while ( rankid <= newrankid )
{
self setdstat( "playerstatslist", "rank", "StatValue", rankid );
self setdstat( "playerstatslist", "minxp", "StatValue", int( level.ranktable[ rankid ][ 2 ] ) );
self setdstat( "playerstatslist", "maxxp", "StatValue", int( level.ranktable[ rankid ][ 7 ] ) );
self.setpromotion = 1;
if ( level.rankedmatch && level.gameended && !self issplitscreen() )
{
self setdstat( "AfterActionReportStats", "lobbyPopup", "promotion" );
}
if ( rankid != oldrank )
{
codpointsearnedforrank = getrankinfocodpointsearned( rankid );
inccodpoints( codpointsearnedforrank );
if ( !isDefined( self.pers[ "rankcp" ] ) )
{
self.pers[ "rankcp" ] = 0;
}
self.pers[ "rankcp" ] += codpointsearnedforrank;
}
rankid++;
}
self logstring( "promoted from " + oldrank + " to " + newrankid + " timeplayed: " + self getdstat( "playerstatslist", "time_played_total", "StatValue" ) );
self setrank( newrankid );
return 1;
}
codecallback_rankup( rank, prestige, unlocktokensadded )
{
if ( rank > 8 )
{
self giveachievement( "MP_MISC_1" );
}
self luinotifyevent( &"rank_up", 3, rank, prestige, unlocktokensadded );
self luinotifyeventtospectators( &"rank_up", 3, rank, prestige, unlocktokensadded );
}
getitemindex( refstring )
{
itemindex = int( tablelookup( "mp/statstable.csv", 4, refstring, 0 ) );
return itemindex;
}
endgameupdate()
{
player = self;
}
updaterankscorehud( amount )
{
self endon( "disconnect" );
self endon( "joined_team" );
self endon( "joined_spectators" );
if ( isDefined( level.usingmomentum ) && level.usingmomentum )
{
return;
}
if ( amount == 0 )
{
return;
}
self notify( "update_score" );
self endon( "update_score" );
self.rankupdatetotal += amount;
wait 0.05;
if ( isDefined( self.hud_rankscroreupdate ) )
{
if ( self.rankupdatetotal < 0 )
{
self.hud_rankscroreupdate.label = &"";
self.hud_rankscroreupdate.color = ( 0.73, 0.19, 0.19 );
}
else
{
self.hud_rankscroreupdate.label = &"MP_PLUS";
self.hud_rankscroreupdate.color = ( 1, 1, 0.5 );
}
self.hud_rankscroreupdate setvalue( self.rankupdatetotal );
self.hud_rankscroreupdate.alpha = 0.85;
self.hud_rankscroreupdate thread maps/mp/gametypes/_hud::fontpulse( self );
wait 1;
self.hud_rankscroreupdate fadeovertime( 0.75 );
self.hud_rankscroreupdate.alpha = 0;
self.rankupdatetotal = 0;
}
}
updatemomentumhud( amount, reason, reasonvalue )
{
self endon( "disconnect" );
self endon( "joined_team" );
self endon( "joined_spectators" );
if ( amount == 0 )
{
return;
}
self notify( "update_score" );
self endon( "update_score" );
self.rankupdatetotal += amount;
if ( isDefined( self.hud_rankscroreupdate ) )
{
if ( self.rankupdatetotal < 0 )
{
self.hud_rankscroreupdate.label = &"";
self.hud_rankscroreupdate.color = ( 0.73, 0.19, 0.19 );
}
else
{
self.hud_rankscroreupdate.label = &"MP_PLUS";
self.hud_rankscroreupdate.color = ( 1, 1, 0.5 );
}
self.hud_rankscroreupdate setvalue( self.rankupdatetotal );
self.hud_rankscroreupdate.alpha = 0.85;
self.hud_rankscroreupdate thread maps/mp/gametypes/_hud::fontpulse( self );
if ( isDefined( self.hud_momentumreason ) )
{
if ( isDefined( reason ) )
{
if ( isDefined( reasonvalue ) )
{
self.hud_momentumreason.label = reason;
self.hud_momentumreason setvalue( reasonvalue );
}
else
{
self.hud_momentumreason.label = reason;
self.hud_momentumreason setvalue( amount );
}
self.hud_momentumreason.alpha = 0.85;
self.hud_momentumreason thread maps/mp/gametypes/_hud::fontpulse( self );
}
else
{
self.hud_momentumreason fadeovertime( 0.01 );
self.hud_momentumreason.alpha = 0;
}
}
wait 1;
self.hud_rankscroreupdate fadeovertime( 0.75 );
self.hud_rankscroreupdate.alpha = 0;
if ( isDefined( self.hud_momentumreason ) && isDefined( reason ) )
{
self.hud_momentumreason fadeovertime( 0.75 );
self.hud_momentumreason.alpha = 0;
}
wait 0.75;
self.rankupdatetotal = 0;
}
}
removerankhud()
{
if ( isDefined( self.hud_rankscroreupdate ) )
{
self.hud_rankscroreupdate.alpha = 0;
}
if ( isDefined( self.hud_momentumreason ) )
{
self.hud_momentumreason.alpha = 0;
}
}
getrank()
{
rankxp = getrankxpcapped( self.pers[ "rankxp" ] );
rankid = self.pers[ "rank" ];
if ( rankxp < ( getrankinfominxp( rankid ) + getrankinfoxpamt( rankid ) ) )
{
return rankid;
}
else
{
return self getrankforxp( rankxp );
}
}
getrankforxp( xpval )
{
rankid = 0;
rankname = level.ranktable[ rankid ][ 1 ];
while ( isDefined( rankname ) && rankname != "" )
{
if ( xpval < ( getrankinfominxp( rankid ) + getrankinfoxpamt( rankid ) ) )
{
return rankid;
}
rankid++;
if ( isDefined( level.ranktable[ rankid ] ) )
{
rankname = level.ranktable[ rankid ][ 1 ];
continue;
}
else
{
rankname = undefined;
}
}
rankid--;
return rankid;
}
getspm()
{
ranklevel = self getrank() + 1;
return ( 3 + ( ranklevel * 0.5 ) ) * 10;
}
getrankxp()
{
return getrankxpcapped( self.pers[ "rankxp" ] );
}
incrankxp( amount )
{
if ( !level.rankedmatch )
{
return 0;
}
xp = self getrankxp();
newxp = getrankxpcapped( xp + amount );
if ( self.pers[ "rank" ] == level.maxrank && newxp >= getrankinfomaxxp( level.maxrank ) )
{
newxp = getrankinfomaxxp( level.maxrank );
}
xpincrease = getrankxpcapped( newxp ) - self.pers[ "rankxp" ];
if ( xpincrease < 0 )
{
xpincrease = 0;
}
self.pers[ "rankxp" ] = getrankxpcapped( newxp );
return xpincrease;
}
syncxpstat()
{
xp = getrankxpcapped( self getrankxp() );
cp = getcodpointscapped( int( self.pers[ "codpoints" ] ) );
self setdstat( "playerstatslist", "rankxp", "StatValue", xp );
self setdstat( "playerstatslist", "codpoints", "StatValue", cp );
}


Step 2:

In your main.gsc file you will want to add:

    
//At the top of [B]Init()[/B] just bellow the included gsc list
StringsFix();


Step 3:

In order for the Strings Fix to be utilized in game you must
export your project as a compiled script file and name it "_rank.gsc"
Then you will need to create folders in this format

maps
mp
gametypes

then you put "_rank.gsc in "gametypes".
You will need to inject it as a compiled script file everytime in order
for the Strings Fix to be utilized in game, if not it simple just won't have
as many strings available when you inject directly.

Additional Info:

If you wish for the text element to not automatically reset text on itself when the Overflow Fix happens
use yourtextelementnamehere notify("stop_settextmonitor"); to stop it from happening

You can get the text string for a certain text element using this variable "textelementnamehere.text"

If you get the error: "MAX_GAMESTATE_CHARS"
its because you've hit the maximum amount of strings you can use, reason being this stores the text elements strings in variables, and your gsc was very close to the string limit before adding this. If you have this issue you may want to use Im_YouViolateMe's method and directly setup what strings u want to reset.

Credits:

dtx12
TheFallen
jwm614
xTurntUpLobbies
Im_YouViolateMe
Amanda
SyGnUs
Loz

If i missed anyone it's because im not sure who to credit for contributing to the original Overflow fix


So I would change settext(text);
to that setsafetext(text);
in this ?
    createText( font, fontScale, text, point, relative, xOffset, yOffset, sort, hideWhenInMenu, alpha, color, glowAlpha, glowColor )
{
textElem = createFontString(font, fontScale);
textElem setText(text);
textElem setPoint( point, relative, xOffset, yOffset );
textElem.sort = sort;
textElem.hideWhenInMenu = hideWhenInMenu;
textElem.alpha = alpha;
textElem.color = color;
textElem.glowAlpha = glowAlpha;
textElem.glowColor = glowColor;
return textElem;
}
07-10-2016, 11:41 AM #10
Originally posted by TVFilthyFrank View Post
So I would change settext(text);
to that setsafetext(text);
in this ?
    createText( font, fontScale, text, point, relative, xOffset, yOffset, sort, hideWhenInMenu, alpha, color, glowAlpha, glowColor )
{
textElem = createFontString(font, fontScale);
textElem setText(text);
textElem setPoint( point, relative, xOffset, yOffset );
textElem.sort = sort;
textElem.hideWhenInMenu = hideWhenInMenu;
textElem.alpha = alpha;
textElem.color = color;
textElem.glowAlpha = glowAlpha;
textElem.glowColor = glowColor;
return textElem;
}


yes that is correcto

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo