FallingSheep
OpenDayZ Lord!
Name: Safezones
Description: creates a safezone where players are invincible
Credits: Da0ne
Original Repository: https://github.com/Da0ne/DZMods/
stripped out from the admin tools, this is the safezone only portion (ill break all the admin tools down in to single how to for ease)
edit init.c as per below
add this at very top
change
to
create a new folder in mpmissions called Scripts
create a new file called safezones.c and paste the below into it and save inside the Scripts folder
create another new file called safezonemission.c and paste the below into it and save inside the Scripts folder
im working on making it be able to support more than 1 zone (should be very easy to do )
Description: creates a safezone where players are invincible
Credits: Da0ne
Original Repository: https://github.com/Da0ne/DZMods/
stripped out from the admin tools, this is the safezone only portion (ill break all the admin tools down in to single how to for ease)
edit init.c as per below
add this at very top
Code:
#include "$CurrentDir:\\mpmissions\\dayzoffline.chernarusplus\\scripts\\safezonemission.c"
Code:
Mission CreateCustomMission(string path)
{
return new CustomMission();
}
Code:
Mission CreateCustomMission(string path)
{
return new safezonemission();
}
create a new folder in mpmissions called Scripts
create a new file called safezones.c and paste the below into it and save inside the Scripts folder
Code:
//Credits: Da0ne
//https://github.com/Da0ne/DZMods/
vector SAFEZONE_LOACTION = "7500 0 7500"; //Map coords (position of the safe zone)
float SAFEZONE_RADIUS = 500; //In meter
string ENTRY_MESSAGE = "Welcome to The SafeZone! Godmode ENABLED!";
string EXIT_MESSAGE = "You Have Left The SafeZone! Godmode DISABLED!";
//Runs every tick (Stat time tick!) IMPORANT: Does reduce about 120 FPS when server is High-Full Pop!
void SafeZoneHandle(PlayerBase player)
{
float distance;
string ZoneCheck, GUID;
GUID = player.GetIdentity().GetPlainId(); //Steam 64
Param1<string> Msgparam;
distance = vector.Distance(player.GetPosition(),SAFEZONE_LOACTION);
if (distance <= SAFEZONE_RADIUS) //Player Inside Zone
{
g_Game.GetProfileString("SafeZoneStatus"+ GUID, ZoneCheck);
if (ZoneCheck == "true") //Already in zone
{
return;
}
else
{
g_Game.SetProfileString("SafeZoneStatus"+ GUID, "true");
Msgparam = new Param1<string>( ENTRY_MESSAGE );
GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, player.GetIdentity());
}
}
else if (distance > SAFEZONE_RADIUS) //Player Outside of Zone
{
g_Game.GetProfileString("SafeZoneStatus"+ GUID, ZoneCheck);
if (ZoneCheck == "false")
{
return;
}
else
{
g_Game.SetProfileString("SafeZoneStatus"+ GUID, "false");
Msgparam = new Param1<string>( EXIT_MESSAGE );
GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, player.GetIdentity());
}
}
}
Code:
//Credits: Da0ne
//https://github.com/Da0ne/DZMods/
class safezonemission : MissionServer
{
/////////////////////////////////////////
// Called within class as extentions NOT class mainscope DO NOT DEFINE CLASS IN FILE!
#include "$CurrentDir:\\mpmissions\\dayzoffline.chernarusplus\\Scripts\Safezones.c"
bool m_SafeZone = true; // safezone on (true) or off (false)
override void TickScheduler(float timeslice)
{
GetGame().GetWorld().GetPlayerList(m_Players);
if( m_Players.Count() == 0 ) return;
for(int i = 0; i < SCHEDULER_PLAYERS_PER_TICK; i++)
{
if(m_currentPlayer >= m_Players.Count() )
{
m_currentPlayer = 0;
}
PlayerBase currentPlayer = PlayerBase.Cast(m_Players.Get(m_currentPlayer));
if (m_SafeZone) { SafeZoneHandle(currentPlayer); } //Check if player is near safezone
currentPlayer.OnTick();
m_currentPlayer++;
}
}
/////////////////////////////////////////
void SetRandomHealth(EntityAI itemEnt)
{
int rndHlt = Math.RandomInt(40,100);
itemEnt.SetHealth("","",rndHlt);
}
override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
{
Entity playerEnt;
playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
Class.CastTo(m_player, playerEnt);
GetGame().SelectPlayer(identity, m_player);
return m_player;
}
override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
{
EntityAI itemEnt;
ItemBase itemBs;
itemEnt = player.GetInventory().CreateInInventory("Rag");
itemBs = ItemBase.Cast(itemEnt);
itemBs.SetQuantity(4);
SetRandomHealth(itemEnt);
itemEnt = player.GetInventory().CreateInInventory("RoadFlare");
itemBs = ItemBase.Cast(itemEnt);
}
}
im working on making it be able to support more than 1 zone (should be very easy to do )
Last edited: