This library provides a full set of string utilities and formatting helpers for GSC scripting in Plutonium T6 (Black Ops II).
- String manipulation (split, replace, trim, reverse, etc.)
- Formatting system with
sprintf - Console and entity printing helpers
- Type detection and validation utilities
- Token-based formatting system
- Lightweight conversion helpers
Refer to each functions implementation in the source for detailed behavior
Checks if a string begins with a prefix.
Checks if a string ends with a suffix.
Replaces all occurrences of a substring.
Splits a string into an array using a separator.
Joins an array into a single string.
Removes leading and trailing spaces.
Removes leading spaces.
Removes trailing spaces.
Checks if a substring exists inside a string.
Reverses a string or array.
Returns a character at a specific index.
Returns the index of a substring.
Repeats a string multiple times.
Counts occurrences of a substring.
Removes all occurrences of a substring.
Capitalizes the first letter of a string.
Cuts a string to length and adds a suffix.
Advanced string formatter supporting:
%sstring%dinteger%uunsigned integer%ffloat%tboolean%aarray%ccolor
Returns a formatted string.
Prints formatted string to console.
Prints formatted string with newline.
Prints formatted string to a player entity.
Prints bold formatted string to a player entity.
Returns array size.
Returns string length.
Returns substring.
Converts string to integer safely.
Converts variable to a string.
Returns variable type as string.
Converts format token into readable type.
Checks if format token is valid.
Checks if value is unsigned integer.
Checks if value is boolean.
Checks if value is a color code.
Checks if string is a numeric digit.
Validates formatting tokens.
Checks if strings contains only whitespaces
#include scripts\strings;
#define color_green "^2"
init() {
s = "hello world";
if (starts_with(s, "hello")) {
printlnf("String starts correctly");
}
s = replace(s, "world", "universe");
printlnf("Modified: %s", s);
parts = split("a;b;c", ";");
printlnf("First part: %s", parts[0]);
joined = join(parts, "-");
printlnf("Joined: %s", joined);
trimmed = strip(" hello ");
printlnf("Trimmed: '%s'", trimmed);
level thread onPlayerConnect();
}
onPlayerConnect() {
level endon("game_ended");
for (;;) {
level waittill("connected", player);
printlnf(
"Player connected: %s %c(guid: %d)",
player.name,
"^2",
player.guid
);
player iprintboldf("Welcome, %s!", player.name);
}
}