Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Keel feed messages, kill and die score with save to server profile with uid

Newbie Spellweaver
Joined
Mar 7, 2018
Messages
12
Reaction score
2
With comments and logging.
I only add code, no any changes in native code

Place this code in to PlayerBase.c on server side, and comment native EEKilled function

kill and die scores saves to server profile w/players steam uids and load if server restarts

Code:
 // BY BORIZZ.K, s-platoon.ru (ThX Mizev, NoNameUltima, 123New and DaOne)
 //MY ---
 //PLAYER DEATH with MESSAGES START //MY
 int killscore = 0; // usage p_killer.killscore = p_killer.killscore + 1; // for kills count in EEKilled function. //p_killer must be PlayerBase - use p_killer = PlayerBase.Cast(killer) //See EEKilled function
 int diescore = 0; // usage Player.diescore = Player.diescore + 1; // for death count in EEKilled function. //Player must be playerbase
 override void EEKilled( Object killer )
 {
  //MY ---
  PlayerBase  p_Killer   = NULL; // Killer
  
  PlayerBase   Player     =  this; // Killed player
  PlayerIdentity Player_Identity  = Player.GetIdentity(); //Killed player Identity
  string   Player_Name   = Player_Identity.GetName(); //Killed player name
  string    p_UID     =  Player_Identity.GetPlainId(); // Killed player UID
  
  bool    enableSaveKills  =  true; // enable/disable save kill count to profile/file by Killer UID
  if ( GetGame().ServerConfigGetInt("enableSaveKills") == 0 ) //place parameter enableSaveKills = 0; for disable SaveKills to server profile
   enableSaveKills  =  false;
  bool    enableSaveDies  =  true; // enable/disable save death count to profile/file by Player UID
  if ( GetGame().ServerConfigGetInt("enableSaveDies") == 0 )//place parameter enableSaveDies = 0; for disable SaveDies to server profile
   enableSaveDies  =  false;
  
  string   deathMsg   = "";
  string   deathMsgDist  = "";
  string   deathMsgKillScore =  "";
  string    DebugMessage;
  Print("::: EEKilled: Debug: Input: killer " + killer.ToString() + " => Class: " + killer.GetType() + ", Player " + Player.ToString() + " => Class: " + Player.GetType()); //DEBUG
  //Phase #1
  if ( killer.IsMan() )
  {
   if ( killer.IsKindOf("SurvivorBase") )
   { 
    p_Killer = PlayerBase.Cast(killer);
    DebugMessage = "killer.IsMan(): killer.IsKindOf('SurvivorBase'): killer " + p_Killer.ToString() + " kill player " + Player.ToString(); //DEBUG
   }
  }
  else
  {
   if ( killer.IsItemBase() )
   {
    ItemBase bitem = ItemBase.Cast(killer);
    p_Killer = PlayerBase.Cast(bitem.GetHierarchyRootPlayer());
    DebugMessage = "killer.IsItemBase(): killer " + p_Killer.ToString() + " => " + bitem.ToString() + " kill player " + Player.ToString(); //DEBUG
   }
   else
   {
    DebugMessage = "killer " + killer.ToString() + " kill player " + Player.ToString(); //DEBUG
   }
  } 
  Print("::: EEKilled Debug: " + DebugMessage); //DEBUG
  
  //Phase #2
  if (p_Killer)
  {
   if (Player == p_Killer)
   {
    deathMsg = Player_Name + " committed suicide.";
   }
   else
   {
    PlayerIdentity Killer_Identity = p_Killer.GetIdentity();
    string killer_name    = Killer_Identity.GetName();
    string k_UID      =  Killer_Identity.GetPlainId(); //Get killer UID
    vector position_killer   = p_Killer.GetPosition();
    vector position_player   =  Player.GetPosition();
    int dist      = vector.Distance(position_player, position_killer);      
    EntityAI itemInHands   = p_Killer.GetHumanInventory().GetEntityInHands();
    if (enableSaveKills)
    {
     string strkillscore;
     g_Game.GetProfileString("killscore"+k_UID,strkillscore);
     if (strkillscore)
     {
      Print("::: EEKilled Debug: LoadKills: Killer: " + killer_name + ", loaded killscore: " + strkillscore); //DEBUG
      p_Killer.killscore = strkillscore.ToInt();
     }
    }
    p_Killer.killscore = p_Killer.killscore + 1; //You must declare a variable: int KillScore = 0; in PlayerBase class
    if (enableSaveKills)
    {
     g_Game.SetProfileString("killscore"+k_UID,p_Killer.killscore.ToString());
     g_Game.SaveProfile();
     Print("::: EEKilled Debug: SaveKills: Killer: " + killer_name + ", killscore: " + diescore.ToString()); //DEBUG
    }
    
    if ( itemInHands.IsItemBase() )
    {
     ItemBase item  = ItemBase.Cast(itemInHands);
     string className = item.GetType();
     deathMsg   = killer_name + " kill: " + Player_Name;
     deathMsgDist        =   " from a distance: " + dist.ToString() + "m by " + className;
     deathMsgKillScore = killer_name + " kills: " + p_Killer.killscore.ToString();
    }
    else
    {
     deathMsg         = killer_name + " kill: " + Player_Name;
     deathMsgDist        = " from a distance: " + dist.ToString() + "m.";
     deathMsgKillScore = killer_name + " kills: " + p_Killer.killscore.ToString();
     
    }
   }
  }
  else
  {
   if ( killer.IsKindOf("AnimalBase") )
   {
    deathMsg = Player_Name + " killed by animal.";
   } 
   else if ( killer.IsKindOf("ZombieBase") )
   {
    deathMsg = Player_Name + " killed by zombie."; 
   }
   else
   {
    deathMsg = Player_Name + " died for an unknown reason.";
   }
  }
  
  //Phase #3
  GetGame().ChatPlayer(5, deathMsg);
  Print("::: EEKilled Debug: killer: " + killer.ToString () + " ::: " + deathMsg); //DEBUG
  if (deathMsgDist)
  {
   GetGame().ChatPlayer(5, deathMsgDist);
   Print("::: EEKilled Debug: killer: " + killer.ToString () + " ::: " + deathMsgDist); //DEBUG
  }
  if (deathMsgKillScore)
  {
   GetGame().ChatPlayer(5, deathMsgKillScore);
   Print("::: EEKilled Debug: killer: " + killer.ToString () + " ::: " + deathMsgKillScore); //DEBUG
  }
  
  if (enableSaveDies)
  {
   string strdiescore;
   g_Game.GetProfileString("diescore"+p_UID,strdiescore);
   if (strdiescore)
   {
    Print("::: EEKilled Debug: Load Die's: Player: " + Player_Name + ", loaded diescore: " + strdiescore); //DEBUG
    Player.diescore = strdiescore.ToInt();
   }
  }
  Player.diescore = Player.diescore + 1;
  if (enableSaveDies)
  {
   g_Game.SetProfileString("diescore"+p_UID,Player.diescore.ToString());
   g_Game.SaveProfile();
   Print("::: EEKilled Debug: SaveDeath: Player: " + Player_Name + ", diescore: " + diescore.ToString()); //DEBUG
  }
  //MY ---
  
  
  //native
  Print("EEKilled, you have died");
  
  DayZPlayerSyncJunctures.SendDeath(this, -1, 0);
  
  if( GetBleedingManagerServer() ) delete GetBleedingManagerServer();
  
  if( GetHumanInventory().GetEntityInHands() )
  {
   if( CanDropEntity(this) )
   {
    if( !IsRestrained() )
    {
     GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(ServerDropEntity,1000,false,( GetHumanInventory().GetEntityInHands()));
    }
   }
   
  }
  
  // kill character in database
  if (GetHive())
  {
   GetHive().CharacterKill(this);
  }
 
  // disable voice communication
  GetGame().EnableVoN(this, false);
 
  
  if ( GetSoftSkillManager() )
  {
   delete GetSoftSkillManager();
  } 
  
  GetSymptomManager().OnPlayerKilled();
  
  //! log melee kill in case of melee
  LogMeleeKill();
  //native
 }
 //PLAYER DEATH with MESSAGES END
 //MY
 
Initiate Mage
Joined
May 20, 2019
Messages
2
Reaction score
0
Hello,Thank you for the tip, but this one gives me an error, can you update it?

GSNE-FR505-OH, 20.05 2019 09:54:20Can't compile "World" script module!scripts/4_World/entities\manbase\playerbase.c(6): Function 'EEKilled' is marked as override, but there is no function with this name in the base class
Thank you
 
Back
Top