Jump to content

Resetting Character instead of creating a new one?


i13thstar

Recommended Posts

how would I go about changing it so that when players die they don't create a new character and just there inventory,worldspace,medical,infected and model gets reset???
 

I basically want to do this because A. its less characters with the same ID in the database, and B. The players keep there zombie kills, bandit kills, headshot stats an what not. and  C..... it doesn't require any cleanup on the characters.

 

 

Link to comment
Share on other sites

My guess is there is an easy way to go about this...

 

Do a trigger in MYSQL....(remove 1st the delete dead players routine)...and do one that sets everyone from dead to alive when an update on table characters_data happens. That would sort out things if a player dies, before he spawns.

 

I dont know if anything should be change anything in the actual files if you do that....seems ok with me...since when a player dies, it will update the database, the database will set every dead back to alive and then when the player respawns it should read the database that the player is alive and not take him to the new character screen...but rather respawn him...

The bad thing is that it will respawn him at the same location where he died.

 

If i am wrong or anyone can think of a better way please say so

 

ps: Maybe file : dayz_server\compile\server_playerDied.sqf   can be tweaked in order to not set a player as dead in the database....but still you would have the same problem....respawn at the sme location.

Link to comment
Share on other sites

editing the games code is a pain in the arss so I quickly wrote this in PHP, it basically puts the kills stats together and deletes the dead players, if a player doesnt have a living body it keeps 1 dead body to save all his stats. run it befor the game starts.

 

if anyone can convert it be my guest, I missed out humanity as I'm not completely sure how the game alters it.

 

also got a bat file underneath that will open up a given webpage in ie and then close it after so long, just call in the bat file you use to start your server..

<?php

  @mysql_connect("localhost", "dayz", "dayz"); 
  @mysql_select_db("dayz_Epoch"); 

   $get_all = mysql_query("SELECT * FROM `character_data`");
   $player = array();
   while($x = mysql_fetch_array($get_all))
   {     
      ///sort arrays      
       $player[$x["PlayerUID"]][] = $x;          
   } 
    
   foreach ($player as $pid)
   {
      
          //set the starting count/combine for each player
       $zombie_kills      = 0;
       $zombie_headshots  = 0;
       $bandit_kills      = 0;
       $hero_kills        = 0;
       $char_alive_id     = 0;
       $last_known_char   = 0;
       $playerUID         = 0;
   
       foreach($pid as $info)
       {
         //combine stats
       $zombie_kills      = $zombie_kills+$info["KillsZ"];
       $zombie_headshots  = $zombie_headshots+$info["HeadshotsZ"];
       $bandit_kills      = $bandit_kills+$info["KillsB"];
       $hero_kills        = $hero_kills+$info["KillsH"];
      
       
         if($info["Alive"] == 1)
         {
          $char_alive_id = $info["CharacterID"];
         }
          $last_known_char = $info["CharacterID"];
          $playerUID       = $info["PlayerUID"]; 
       } 
       
       
       // insert counted starts into database
       $update_stats[] = mysql_query("UPDATE `character_data` set `KillsZ` = '$zombie_kills' WHERE `PlayerUID` = '$playerUID'");
       $update_stats[] = mysql_query("UPDATE `character_data` set `HeadshotsZ` = '$zombie_headshots' WHERE `PlayerUID` = '$playerUID'");
       $update_stats[] = mysql_query("UPDATE `character_data` set `KillsB` = '$bandit_kills' WHERE `PlayerUID` = '$playerUID'");
       $update_stats[] = mysql_query("UPDATE `character_data` set `KillsH` = '$hero_kills' WHERE `PlayerUID` = '$playerUID'"); 
       
       // delete the useless characters/      
       $total_chars =  count($pid);
       
       if($total_chars == 1)
       {
       //ignore single deletion will delete stats off the dead
       }
       else {
       
         if($char_alive_id == 0)
         {
          //player doesn't have a living body, delete all but his last known.
            mysql_query("DELETE FROM `character_data` WHERE `playerUID` = '$playerUID' AND `characterID` NOT LIKE '$last_known_char'");
         
         } else {
         
         //players has a living body, remove his dead.
            mysql_query("DELETE FROM `character_data` WHERE `playerUID` = '$playerUID' AND `Alive` = '0'");
            }
    
          
       
       }
          
   
   }



?>

BAT START/CLOSER...

@echo off
start iexplore http://YOUR WEBSITE LOCATION/PHP SCRIPT LOCATION.php
ping 127.0.0.1 -n 5 >NUL
echo.
echo.
echo.
ping 127.0.0.1 -n 5 >NUL
echo.
echo.
echo.
ping 127.0.0.1 -n 5 >NUL
echo.
echo.
echo.
ping 127.0.0.1 -n 5 >NUL
echo.
echo.
echo.
ping 127.0.0.1 -n 5 >NUL
taskkill /im iexplore.exe
exit;
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...