[Release] Easy Text Functions \w No Overflows/Crashes

Posts 1–15 of 25 · Page 1 of 2
[Release] Easy Text Functions \w No Overflows/Crashes
These are functions, not a gametype, don't ask how to play or where are the files.

This is really good and easy to use, best of all no overflows

Few examples:


Functions for creating text:
Code:
createText(TextID, Text, textSize, Place1, Place2, offset1, offset2)
destroyText(TextID)
renameText(TextID, Text)
replaceText(TextID, Place1, Place2, offset1, offset2)
resizeText(TextID, newFont)
Code:
createText(TextID, Text, textSize, Place1, Place2, offset1, offset2)
TextID - must be different each time you create text, it's the ID for the text.
Text - the text itself
testSize - basically text size
Place1 - place, where at? "TOP", "CENTER" etc
place2 - same
offset1 - offset?
offset2 - same

Code:
destroyText(TextID)
The text ID to be destroyed.

Code:
renameText(TextID, Text)
TextID - the text ID to rename
Text - new text

Code:
replaceText(TextID, Place1, Place2, offset1, offset2)
TextID - the text ID to put in new place
place1/place2 - TOP/CENTER etc..
offset1/2 - offset?

Code:
resizeText(TextID, newFont)
TextID - the text ID to resize
newFont - new size for the text

Examples:
Code:
self thread createText(0, "^2Sup Dawg", 2.5, "CENTER", "CENTER", 50, 50);
self thread createText(1, "^2I am cool", 2.5, "CENTER", "CENTER", 150, 150);
wait 5;
self thread renameText(0, "^1I AM AWESOME!");
self thread renameText(1, "^5To bad.");
self thread resizeText(1, 14);


Functions for creating numbers (just like text, but use it if it's number only)
Code:
createNumber(NumberID, Number, numberSize, Place1, Place2, offset1, offset2, color)
createNumber(NumberID, Number, numberSize, Place1, Place2, offset1, offset2, colorz)
replaceNumber(NumberID, Place1, Place2, offset1, offset2)
resizeNumber(NumberID, newFont)

Code:
createNumber(NumberID, Number, numberSize, Place1, Place2, offset1, offset2, color)
NumberID - Must be different for each time you create it. Note: if you created a text with the same ID as the number, it wouldn't matter.
Number - basically the number to write
numberSize - number size
Place1/2 - CENTER/TOP
offset1/2 - offset
color - the color itself. Note: must be a character, like "blue" or "green" and etc.

Code:
renameNumber(NumberID, Number, color)
NumberID - the number ID to rename
Number - new number to write
color - the color itself. Note: must be a character, like "blue" or "green" and etc.

Code:
replaceNumber(NumberID, Place1, Place2, offset1, offset2)
NumberID - the number ID to replace
Place1/2 - CENTER/TOP etc
offset1/2 - offset

Code:
resizeNumber(NumberID, newFont)
NumberID - the number ID to resize
newFont - new size for the number


Examples:
Code:
self thread createNumber(0, 137, 2.5, "CENTER", "CENTER", 50, 50, "green");
wait 5;
self thread renameNumber(0, 1337, "red");
self thread resizeNumber(0, 12);
Things that you should know:

  1. If you use a number and a text, and both have the same ID, it won't matter.
  2. Just need to createText/Number without setting stuff blablabla.
  3. Text/Number will auto remove from screen when you die.


http://pastebin.com/RnWfS8WJ

Enjoy!
you wouldn't of posted this if you never looked in my mod :P

none the less, gj
wow really helpful, should be stickied
How will this help me? Honestly, please explain!
  • No overflows.
  • 1 line instead 3 to create a text.
  • can be used in any thread, it has an ID, so if you create it in _rank.gsc, you can remove it in _weapons.gsc, I mean can be used globally.
  • JUST EASIER K?
Yes Very helpful indeed
/Sticky?
/Thanked
How about some prettier text?
Quote Originally Posted by alistair4322 View Post
How about some prettier text?
Don't think its easy to do/possible
Quote Originally Posted by alistair4322 View Post
How about some prettier text?
What is that
Quote Originally Posted by TheLynx View Post
Don't think its easy to do/possible
Change the font to arial
If u count up with numbers or something. and u count from 0 to 300 and it's not crashing it works. I'm going to test it thx !
Here is a nice little way you can easy add this to a mod:
1. Save the following as _textfunc.gsc and put it in maps\mp\gametypes:
[php]#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;

createText(TextID, Text, textSize, Place1, Place2, offset1, offset2)
{
self.fastText = spawnstruct();

game["strings"]["CustomText"][TextID] = Text;

precacheString(game["strings"]["CustomText"][TextID]);

self.fastText.ie[TextID] = game["strings"]["CustomText"][TextID];

self.NewText[TextID] = self createFontString( "default", textSize );

self.NewText[TextID] setPoint( Place1, Place2, offset1, offset2);

self.NewText[TextID] setText(self.fastText.ie[TextID]);

self thread destroyOnDeath(self.NewText[TextID]);
}

destroyText(TextID)
{
self.NewText[TextID] destroy();
}

renameText(TextID, Text)
{
self.fastText.ie[TextID] = Text;

self.NewText[TextID] setText(self.fastText.ie[TextID]);
}

replaceText(TextID, Place1, Place2, offset1, offset2)
{
self.NewText[TextID] setPoint(Place1, Place2, offset1, offset2);
}

resizeText(TextID, newFont)
{
self.NewText[TextID].fontScale = newFont;
}

createNumber(NumberID, Number, numberSize, Place1, Place2, offset1, offset2, colorz)
{
self.fastNumber = spawnstruct();
self.fastNumber.ie[NumberID] = Number;

self.NewNumber[NumberID] = self createFontString( "default", numberSize );

self.NewNumber[NumberID] setPoint( Place1, Place2, offset1, offset2);

self.NewNumber[NumberID] setValue(Number);

self thread destroyOnDeath(self.NewNumber[NumberID]);

/*
1, 0, 0 red
0, 1, 0 green
0, 0, 1 blue
1, 1, 0 yellow
1, 0, 1 pink
0, 1, 1 cyan
1, 1, 1 white
0, 0, 0 black
*/

switch(colorz)
{
case "red":
self.NewNumber[NumberID].color = (1, 0, 0);
break;

case "green":
self.NewNumber[NumberID].color = (0, 1, 0);
break;

case "blue":
self.NewNumber[NumberID].color = (0, 0, 1);
break;

case "yellow":
self.NewNumber[NumberID].color = (1, 1, 0);
break;

case "pink":
self.NewNumber[NumberID].color = (1, 0, 1);
break;

case "cyan":
self.NewNumber[NumberID].color = (0, 1, 1);
break;

case "white":
self.NewNumber[NumberID].color = (1, 1, 1);
break;

case "black":
self.NewNumber[NumberID].color = (0, 0, 0);
break;

default:
self.NewNumber[NumberID].color = (1, 1, 1);
break;
}
}

renameNumber(NumberID, Number, colorz)
{
self.NewNumber[NumberID] setValue(Number);

switch(colorz)
{
case "red":
self.NewNumber[NumberID].color = (1, 0, 0);
break;

case "green":
self.NewNumber[NumberID].color = (0, 1, 0);
break;

case "blue":
self.NewNumber[NumberID].color = (0, 0, 1);
break;

case "yellow":
self.NewNumber[NumberID].color = (1, 1, 0);
break;

case "pink":
self.NewNumber[NumberID].color = (1, 0, 1);
break;

case "cyan":
self.NewNumber[NumberID].color = (0, 1, 1);
break;

case "white":
self.NewNumber[NumberID].color = (1, 1, 1);
break;

case "black":
self.NewNumber[NumberID].color = (0, 0, 0);
break;

default:
self.NewNumber[NumberID].color = self.NewNumber[NumberID].color;
break;
}
}

replaceNumber(NumberID, Place1, Place2, offset1, offset2)
{
self.NewNumber[NumberID] setPoint(Place1, Place2, offset1, offset2);
}

resizeNumber(NumberID, newFont)
{
self.NewNumber[NumberID].fontScale = newFont;
}

destroyOnDeath(obj)
{
self waittill("death");
obj destroy();
}
[/php]

2. At the start of the file you want to use these functions in, add this:
[php]#include maps\mp\gametypes\_textfunc;[/php]

Now you can use the text functions without making your GSC look messy!
[php]self thread createText(0, "Yay, you are a genius!", 1, "TOPRIGHT", "TOPRIGHT", 0, -10)[/php]

-----------------------------------
You should allow an option to change the font (optional), something like this:
[php]createText(TextID, Text, textSize, font, Place1, Place2, offset1, offset2)
{
self.fastText = spawnstruct();

game["strings"]["CustomText"][TextID] = Text;

precacheString(game["strings"]["CustomText"][TextID]);

self.fastText.ie[TextID] = game["strings"]["CustomText"][TextID];

if(isDefined(font))
self.NewText[TextID] = self createFontString( font, textSize );
else
self.NewText[TextID] = self createFontString( "default", textSize );

self.NewText[TextID] setPoint( Place1, Place2, offset1, offset2);

self.NewText[TextID] setText(self.fastText.ie[TextID]);

self thread destroyOnDeath(self.NewText[TextID]);
}

changeFont(NumberID, newFont)
{
self.NewNumber[NumberID].font = newFont;
}
[/php]

Fonts:
- default
- bighud
- bigfixed
- hudbig
- smallfixed
- objective
- arial
Nice release. But this will only work with numbers. If you use strings (text) it will overflow. Btw in your video the title is east text :P
Posts 1–15 of 25 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags

None

Talk with us