Post: Overflow Fix
11-02-2014, 11:38 PM #1
TheFallen
Former Dark Night
(adsbygoogle = window.adsbygoogle || []).push({}); Overflow Fix
An easy to implement way of preventing any string overflows.

Introduction

Make sure to read the entire thread before attempting to use otherwise there may be issues with it not working properly.

Usage

First get the source from You must login or register to view this content.. You are going to need everything in here so do not try to edit it or remove things as it will most likely cause issues. To use this you must first call initOverflowFix() once in onPlayerSpawned(). You must only call this once for each player otherwise there will be problems.
    
onPlayerSpawned()
{
self endon("disconnect");
level endon( "game_ended" );

// YOU MUST HAVE THIS
isFirstSpawn = true;


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

// YOU MUST HAVE THIS
// only runs once when the player spawns for the first time
if(isFirstSpawn)
{
initOverFlowFix();

isFirstSpawn = false;
}
}
}


Creating Text

When creating text make sure to use my createText function or if you would rather use your own you must have these three lines at the bottom just before the return statement:
    
// textElem is the name of the object you defined with createFontString()
// view my createText function for an example
textElem.type = "text";
addTextTableEntry(textElem, getStringId(text));
textElem setSafeText(self, text);

You must do this for every text element you use otherwise it will result in an overflow.

Setting Text

When setting text make sure to call setSafeText(<player>, <text>Winky Winky instead of setText(<text>Winky Winky. If you do not do this it will result in an overflow. To use setSafeText() you must call it like so:
    
// textElement is the text element you wish to set text for. This is the object you would normally call setText() on.
// self is the player object you wish to set text for. If you don't know what this is just use self.
textElement setSafeText(self, "text");


Destroying Text

When destroying text you must call clear(<player>Winky Winky instead of destroy(). Clear takes one argument and that is the player that the text element belongs to. If you don't know what I mean by that just use self.
    
textElement clear(self);


Simple Example by Exelo
You can view an example of how to use this You must login or register to view this content..

Real Menu Examples
Last edited by TheFallen ; 11-03-2014 at 03:39 AM. Reason: added more examples

The following 33 users say thank you to TheFallen for this useful post:

AlexNGU, Bigmoneyhustlin, BossamBemass, canadiancaper, Chris, codybenti, Devilemi, FatalityMods, Full-Evil, HiddenHour, Im Not Boobdidas, Krypton, Dzre-, LegitGamer264, Magnate13Snake, ModernTriicks, Nothingbutbread, Obris, Patrick, RTE, SaberNGU, ScaRzModZ, Script Kiddie, Shark, Dacoco, SnaY, Taylor, SyGnUs, ViRuzModzHD, xePixTvx, xJessex, xKasper, Zambie
11-02-2014, 11:40 PM #2
xJessex
I am error
Nice bro, Keep up the good work Tustin
11-02-2014, 11:43 PM #3
xSprint
Pokemon Trainer
Sweet! Will try this later when I get home.
11-03-2014, 01:21 AM #4
TheFallen
Former Dark Night
Added some more examples.
11-04-2014, 02:08 AM #5
Chris
Former Staff
Thanks for sharing the fix with the community, since some others felt the need to keep it to themselves.

This is modding, who keeps stuff private anymore? tears

The following user thanked Chris for this useful post:

MiseryLegion
11-05-2014, 09:18 PM #6
Taylor
Former Black Knight.
Originally posted by TheFallen View Post
Overflow Fix
An easy to implement way of preventing any string overflows.

Introduction

Make sure to read the entire thread before attempting to use otherwise there may be issues with it not working properly.

Usage

First get the source from You must login or register to view this content.. You are going to need everything in here so do not try to edit it or remove things as it will most likely cause issues. To use this you must first call initOverflowFix() once in onPlayerSpawned(). You must only call this once for each player otherwise there will be problems.
    
onPlayerSpawned()
{
self endon("disconnect");
level endon( "game_ended" );

// YOU MUST HAVE THIS
isFirstSpawn = true;


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

// YOU MUST HAVE THIS
// only runs once when the player spawns for the first time
if(isFirstSpawn)
{
initOverFlowFix();

isFirstSpawn = false;
}
}
}


Creating Text

When creating text make sure to use my createText function or if you would rather use your own you must have these three lines at the bottom just before the return statement:
    
// textElem is the name of the object you defined with createFontString()
// view my createText function for an example
textElem.type = "text";
addTextTableEntry(textElem, getStringId(text));
textElem setSafeText(self, text);

You must do this for every text element you use otherwise it will result in an overflow.

Setting Text

When setting text make sure to call setSafeText(<player>, <text>Winky Winky instead of setText(<text>Winky Winky. If you do not do this it will result in an overflow. To use setSafeText() you must call it like so:
    
// textElement is the text element you wish to set text for. This is the object you would normally call setText() on.
// self is the player object you wish to set text for. If you don't know what this is just use self.
textElement setSafeText(self, "text");


Destroying Text

When destroying text you must call clear(<player>Winky Winky instead of destroy(). Clear takes one argument and that is the player that the text element belongs to. If you don't know what I mean by that just use self.
    
textElement clear(self);


Simple Example by Exelo
You can view an example of how to use this You must login or register to view this content..

Real Menu Examples


First time looking at this since you texted me about a week ago. :p I am highly impressed, even more so that it actually works.

Stickied since it is a good resource and will help many gsc scripters.

The following user thanked Taylor for this useful post:

TheFallen
11-06-2014, 03:51 AM #7
TheFallen
Former Dark Night
Originally posted by Taylor View Post
First time looking at this since you texted me about a week ago. :p I am highly impressed, even more so that it actually works.

Stickied since it is a good resource and will help many gsc scripters.


Lmao I wouldn't have posted it if it didn't :p it might be a little over kill but it's at least reliable and works for every text/string you need.
11-08-2014, 11:26 AM #8
Turk_Warrior
League Champion
Originally posted by TheFallen View Post
Lmao I wouldn't have posted it if it didn't :p it might be a little over kill but it's at least reliable and works for every text/string you need.


so for this to work i have to redo all my shit ? that i made with the writing if so ill just remake my menu its a complete mess atm lol
11-08-2014, 03:43 PM #9
xJessex
I am error
Originally posted by Warrior View Post
so for this to work i have to redo all my shit ? that i made with the writing if so ill just remake my menu its a complete mess atm lol


You just need to convert string into your menu, no need to remake everything lol
11-09-2014, 03:36 AM #10
ybnice1234779
Do a barrel roll!
This will stop freezes and such?

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo