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
09-03-2017, 09:45 AM #20
Updated with some minor changes for when restarting game
and added more gametypes
11-23-2017, 11:07 AM #21
Updated, now uses a array to hold text element text preventing which might of been a potential freeze issue before hand
03-08-2019, 09:07 PM #22
DoraTheKiller97
Treasure hunter
Originally posted by OfficialCoolJay View Post
Updated, now uses a array to hold text element text preventing which might of been a potential freeze issue before hand

I know this is old. But this cannot be ran correctly because the "ClearStrings" function wasn't posted by you. :(
05-17-2019, 02:31 AM #23
Originally posted by DoraTheKiller97 View Post
Originally posted by OfficialCoolJay View Post
Updated, now uses a array to hold text element text preventing which might of been a potential freeze issue before hand

I know this is old. But this cannot be ran correctly because the "ClearStrings" function wasn't posted by you. :(

Above the line where that is mentioned rename the function Init() to ClearStrings()
this is a error i left in sorry, this is only needed if you are injecting the whole project as _rank.gsc

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo