Skip to content

ZenFunctions.c

Zenarchist edited this page Apr 15, 2026 · 4 revisions

There are 2 function classes in this core mod. One is in 3_game scope, the other is in 4_world scope and inherits from the 3_game functions.

The 3_game function class is ZenGameFunctions.c, and the 4_world class is ZenFunctions.c.

This means you can use ZenGameFunctions.* in any class contained in the 3_game scope or the 4_world and 5_mission scopes, but you can only use ZenFunctions.* in the 4_world and 5_mission scopes, and in 4_world and above you can use ZenFunctions.* to reference any function contained in ZenGameFunctions.

Here is a brief overview of some of the included functions - check the mod's source code for more detailed documentation or parameter lists:

ZenGameFunctions.c

Available in 3_game scope and above:

void ZMPrint(Object obj)		// Prints the given string/object with a timestamp to printlogs

//! GENERAL HELPER FUNCTIONS
bool IsFreshWipe() 				// Returns true if this is the FIRST startup of a new server wipe.
bool EndsWith(str, str) 		// Returns true if the given string ends with the given suffix
bool IsKeyNumber(int keyCode)	// Returns true if the given key is a number (or backspace/caret mover)
bool IsNumberChar(str)			// Returns true if the given single letter/character is a number 
bool IsAllNumbers(str)			// Returns true if the given string is only numbers
int CountInString(str, str)		// Returns how many times the second string appears in the first
string GetMapLinkPosition(pos)	// Returns a Izurvie map link to the given vector coordinates
vector GetWorldCenterPosition()	// Returns the true vector coordinates of the map's center position
int GetSurfaceParticleType(pos)	// Returns the particle ID for the given vector position

// SEASONAL MOD FUNCTIONS
bool IsDeepWinter()				// Returns true if WinterChernarusV2 or WinterLivonia mods are present
bool IsLateOrEarlyWinter()		// Returns true if Early Winter Chernarus/Livonia mods are present
bool IsWinter()					// Returns true if EITHER deep winter or early winter mods are present
	
// DATE-BASED FUNCTIONS
bool IsChristmas()				// Returns true if server irl date is >= 24th December & <= 25th
bool IsEaster()					// Returns true if server irl date is >= 5th April & <= 6th
bool IsHalloween()				// Returns true if server irl date is >= 30th October & <= 31st
bool IsAustraliaDay()			// Returns true if server irl date is >= 25th January & <= 27th
	
// OBJECT FUNCTIONS

void AlignToTerrain(Object obj) // Aligns the given object to the underlying terrain slope
	
// Spawns the given object with the given parameters and returns it
Object SpawnObject(string type, vector position, vector orientation = "0 0 0", float scale = 1.0, int flags = ECE_SETUP, bool allowDuplicate = true)
	
// Spawns the given object with the relative offsets to the parent object
Object SpawnObjectRelative(
	Object parent,
	string type,
	vector localOffsetPos,
	vector localOffsetOri = "0 0 0",
	float scale = 1.0,
	int createFlags = ECE_SETUP,
	int createRotationFlags = RF_IGNORE)

ZenFunctions.c

Available in 4_game scope and above, and you can use ZenFunctions.* to access any ZenGameFunctions in 4_world and above:

void SendGlobalMessage(msg)				// Sends the given message to ALL players on the server 
void ZenClientMessage(msg)				// Displays a text message on the client (only works client-side)
void DebugMessage(msg)					// Displays a [CLIENT] or [SERVER] debug message
void SendPlayerMessage(player, msg)		// Send a message to the given player 

bool IsRaining()						// Return true if the rain is higher than a tiny trickle
int GetCameraPitch()					// Return player's client camera pitch angle (useful for actions @ sky/ground)
void OrientObjectToPosition(obj, pos)	// Orientate the given object towards the given vector position 
vector GetRandomPointInCircle(pos, r)	// Return a random vector pos within the given 'r' circle radius in meters

// Returns a vector coordinate X meters closer to the player, from the original position, based on player's direction
vector MovePositionCloserToThisPosition(origPos, playerOrientation, meters)

bool HasItemType(player, item)			// Return true if the given player has the given item classname
bool SetQuantity(item, quantity)		// Set the given item's quantity regardless of its item type

// Move the inventory from the old item to the new item, and (optionally) delete the old item.
// This should ideally be used on items with identical cargo & attachments (eg. painting a bag).
// Note: I have experienced crashing at times with this function - use at your own risk & test it!
bool MoveInventory(oldItem, newItem, bool deleteOldItem = true)

string string GetTimeToString(seconds)	// Returns a readable time string based on the given seconds 

bool IsUnderRoof(fromPos)				// Returns true if the given position is under a roof

array<Object> GetObjectsRayCastCamera()	// Returns a list of objects the player is looking at
array<Object> GetObjectsRayCastBeneath()// Returns a list of objects underneath the player

void SetPlayerControl(enabled, hideHud)	// Enable/disable player control & HUD (for GUIs)
void EnablePlayerControl()				// Enable the player's controls (ignore HUD)
void DisablePlayerControl()				// Disable the player's controls (ignore HUD)
PlayerBase GetPlayerByIdentity(id)		// Get the PlayerBase for the given PlayerIdentity
PlayerBase GetPlayerByID(stringID)		// Get the PlayerBase for the given Steam/BattlEye ID

// Get the PlayerBase who sent a chat message based on their chat name
// Note: names *should* be unique to all players. If two players have the same name one should have (2) on the end.
PlayerBase GetIdentityFromChatName(string name)

// Get the EntityAI attached to the given slot NAME on the given entity 
EntityAI GetItemOnSlotBySlotName(notnull EntityAI entityAI, string slot_type)

// Get the EntityAI attached to the given slot ID on the given entity 
EntityAI GetItemOnSlotBySlotID(notnull EntityAI entityAI, int slot_id)

// Get the first attached entity found with the given classname
EntityAI GetItemOnSlotByType(notnull EntityAI entityAI, string className)

// Get the nearest territory flag to the given position (Expansion + Basic Territories compatible)
TerritoryFlag GetNearestTerritoryFlag(vector pos)

// Send the given message to CF Cloud chat with the given position on the map 
// NOTE: This will use a random player to "deploy" the message @ pos, so ignore player name
void GameLabs_SendServerDeployed(vector pos, string message)

Clone this wiki locally