• Before registering an account on PlayerSquared you must first agree that you are at least 13 years of age & have read & agree to our Terms & rules & our Privacy policy.

Mod BO2 [Plutonium/T6] Some useful GSC scripts I've made whilst making servers

Dec

N00b
May 22, 2026
1
0
10
Code:
/////////////////////////////////////
// Database Query Function         //
/////////////////////////////////////
// Sends a query to the database   //
/////////////////////////////////////
utility_database_query(statement, parameters) {

    query = mysql::prepared_statement(statement, parameters);
    query waittill("done", result, affected_rows, error);

    return array(
        result,
        affected_rows,
        error
    );

}

Examples:
self.pers["user"] = utility_database_query(
    "INSERT INTO user_zombies (guid,name,created_at,updated_at) VALUES (?,?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE guid=VALUES(guid),name=VALUES(name)",
    array(self.guid,self.name)
)[0][0];

self.pers["user"] = utility_database_query("SELECT guid,name,zm_level,zm_prestige,experience FROM user_zombies WHERE guid=?", array(self.guid))[0][0];

this requires t6 utils

Code:
////////////////////////////////////////////
// Utility Format Number Function         //
////////////////////////////////////////////
// Returns numbers formatted by thousands //
////////////////////////////////////////////
utility_format_number(num) {

    strNum = num + "";

    len = 0;
    while (strNum[len] != undefined) {
        len++;
    }

    if (len <= 3)
        return strNum;

    formatted = "";
    firstGroupLen = len % 3;
    if (firstGroupLen == 0)
        firstGroupLen = 3;

    for (i = 0; i < firstGroupLen; i++) {
        formatted += strNum[i];
    }

    for (i = firstGroupLen; i < len; i += 3) {
        formatted += ",";
        for (j = 0; j < 3; j++) {
            formatted += strNum[i + j];
        }
    }

    return formatted;

}

Examples:
self.pers["example"] = int(1000000);
self tell(utility_format_number(self.pers["example"]));
returns (string) "1,000,000" instead of an int or use normally if you want it as an integer

Code:
///////////////////////////////////////////////////
// Utility Current Map Function                  //
///////////////////////////////////////////////////
// Returns the current map the server is running //
///////////////////////////////////////////////////
utility_current_map() {

    switch(getDvar("ui_zm_mapstartlocation"))
    {
        case "processing": return "Buried"; break;
        case "rooftop": return "DieRise"; break;
        case "prison": return "Prison"; break;
        case "nuked": return "Nuketown"; break;
        case "tomb": return "Origins"; break;
        case "town": return "Town"; break;
        case "farm": return "Farm"; break;
        case "transit":
            if (getDvar("ui_gametype") == "zclassic")
                return "Tranzit";
            else
                return "Depot";
            break;
        default: return "NA";
    }

}

Examples:
self tell(utility_current_map());
returns the name of the map being played to chat
}

Code:
/////////////////////////////////////////////////
// Player Names String Function                //
/////////////////////////////////////////////////
// Loops through players and puts names into   //
// a single string                             //
/////////////////////////////////////////////////
utility_player_names_to_string() {

    names = "";
    players = level.players;

    for (i = 0; i < players.size; i++) {
        if(names == "") {
            names = players[i].pers["user"]["name"];
        } else {
            names = names + ", " + players[i].pers["user"]["name"];
        }
    }

    return names;

}

Examples:
players in lobby [0 = Dec, 1 = scooby, 2 = jason]
self tell(utility_player_names_string());
will return (string) "dec, scooby, jason,"

Code:
////////////////////////////////////////
// Include Base Game Scripts          //
////////////////////////////////////////
#include maps/mp/_utility;            //
#include common_scripts/utility;      //
#include maps/mp/zombies/_zm_utility; //
#include maps/mp/zombies/_zm;         //
////////////////////////////////////////

///////////////////////////////////////////////
// Utility Kick Player Function              //
///////////////////////////////////////////////
// Kicks the given player from the server    //
///////////////////////////////////////////////
utility_kick_player(reason) {

    executeCommand("clientkick_for_reason  " + self getEntityNumber() + " \"" + reason + "\"");

}

Example:
self utility_kick_player("You've been kicked for not following the rules");
will kick self aka you
player utility_kick_player("You've been kicked for not following the rules");
will kick the entity you attached to the player variable (you could loop through players in the lobby to kick by guid or name)