DayZ
ZomBerry Admin Tools
5Andysalive 27 Jul, 2020 @ 3:38pm
init.c adding commands.
Here is my shortened init.c . Have it like this for a very long time on my tiny server and not touched much. But on updating from a old 0.5.9 to current zomberry version it crashed with the error i mentioned.. I probably did it following some sort of example file i can't find anymore:


void main()
{
// hive, weather etc removed
}


class CustomMission: MissionServer
{
void CustomMission() {
GetZomberryCmdAPI().AddCategory("ServerCustomCategory", 0xFFFFF44F); //Category name, color #FFF44F
GetZomberryCmdAPI().AddCommand("TP Prison", "TPPrison", this, "ServerCustomCategory");
GetZomberryCmdAPI().AddCommand("TP Novo", "tpnovo", this, "ServerCustomCategory");
GetZomberryCmdAPI().AddCommand("TP DEVIsland", "island", this, "ServerCustomCategory");
GetZomberryCmdAPI().AddCommand("--------------------", "untie", this, "ServerCustomCategory");
GetZomberryCmdAPI().AddCommand("Orel Gear", "Orel", this, "ServerCustomCategory");
GetZomberryCmdAPI().AddCommand("M4 Gear", "GearM42", this, "ServerCustomCategory");
GetZomberryCmdAPI().AddCommand("Buidling gear", "Gearbuild", this, "ServerCustomCategory");
}


void tpnovo( string funcName, int adminId, int targetId, vector cursor ) {
ZBGetPlayerById(targetId).SetPosition("11683.4 58.90 14099.8");
SendMsg(ZBGetPlayerById(adminId), "tp novo spawn");
}

void TPPrison( string funcName, int adminId, int targetId, vector cursor ) {
ZBGetPlayerById(targetId).SetPosition("2784.42 26.217157 1196.27");
SendMsg(ZBGetPlayerById(adminId), "TP prison island");
}

void island( string funcName, int adminId, int targetId, vector cursor ) {
ZBGetPlayerById(targetId).SetPosition("24000 25.3 0");
SendMsg(ZBGetPlayerById(adminId), "TPed Dev Island");
}

void GearM42( string funcName, int adminId, int targetId, vector cursor ) {
ZBGetPlayerById(targetId).CreateInInventory("M4A1_Green");
ZBGetPlayerById(targetId).CreateInInventory("Huntingbag");
ZBGetPlayerById(targetId).CreateInInventory("Mag_STANAGCOUPLED_30Rnd");
// and so on
}

void Orel( string funcName, int adminId, int targetId, vector cursor ) {
ZBGetPlayerById(targetId).CreateInInventory("drybag_Blue");
ZBGetPlayerById(targetId).CreateInInventory("MP5K");
ZBGetPlayerById(targetId).CreateInInventory("MP5_Compensator");
ZBGetPlayerById(targetId).CreateInInventory("MP5_RailHndgrd");
ZBGetPlayerById(targetId).CreateInInventory("MP5k_StockBttstck");
// And so on
}

void Gearbuild( string funcName, int adminId, int targetId, vector cursor ) {
ZBGetPlayerById(targetId).CreateInInventory("MountainBag_Red");
ZBGetPlayerById(targetId).CreateInInventory("shovel");
ZBGetPlayerById(targetId).CreateInInventory("hammer");
// and so on

}

void SendMsg(PlayerBase player, string msg) {
Param1<string> msgParam = new Param1<string>( msg );
GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, msgParam, true, player.GetIdentity());
}

// LOADOUT STUFF removed.

class lifespawn

{

}


Mission CreateCustomMission(string path)

{
Print("Loaded mission: " + path);
g_Game.SetMissionPath(path);

return new CustomMission();
}