Jump to content

edhunter

Member
  • Posts

    62
  • Joined

  • Last visited

Reputation Activity

  1. Like
    edhunter reacted to Spectral in [HOWTO / RELEASE] Keep your plot pole after you die!!!   
    I created a MySQL trigger that will update a characters plot pole with their new CharacterID once they die.
     
    In MySQL Workbench CE connect to your mysql server. open the dayz_epoch db right click on character_data and select 'Alter Table' click on the Triggers tab at the bottom. Select After Insert from the list and click Add Trigger Replace the generated code with the below and select Apply DELIMITER $$ DROP TRIGGER IF EXISTS dayz_epoch.`character_data_AINS_plot`; CREATE TRIGGER `dayz_epoch.character_data_AINS_plot` AFTER INSERT ON dayz_epoch.character_data FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one BEGIN DECLARE oldCharacterID INT; SELECT CharacterID INTO oldCharacterID FROM dayz_epoch.character_data WHERE PlayerUID = new.PlayerUID AND Alive = '0' ORDER BY CharacterID Desc LIMIT 1; IF (oldCharacterID IS NOT NULL) THEN UPDATE dayz_epoch.object_data SET CharacterID = new.CharacterID WHERE Classname = 'Plastic_Pole_EP1_DZ' AND CharacterID = oldCharacterID; END IF; END My next attempt will be to have the characters buildables follow them as well so that they can remove their walls and what not.
     
    What this does sets the players previous plot pole from their old characterID to their new characterID when they rejoin and select a new character.
     
    UPDATE:
     
    In addition to the above I have written scripts so that you do NOT have to restart the server... I have tested these and have worked for me.
     
    Unpack your dayz_server.pbo file and open compile/server_playerLogin.sqf. find 
    dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected]; at the bottom and just before this line add
    if (_isNew) then { diag_log format["Player %1 Character %2 is NEW", _playerID, _charID]; [_charID, _playerID, _playerObj] call server_changePlotsOwner; }; open server_functions.sqf and add 
    DeadPlayerPlotObjects = []; just above
    BIS_Effects_Burn = {}; now find
    server_maintainArea = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_maintainArea.sqf"; and add this code just below it
    server_changePlotsOwner = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_changePlotsOwner.sqf";  open server_playerDied.sqf
    find:
    _newObject setVariable["processedDeath",diag_tickTime]; if (typeName _minutes == "STRING") then { _minutes = parseNumber _minutes; }; diag_log ("PDEATH: Player Died " + _playerID); and add the below code just above it
    _allPoleObjs = allMissionObjects "Plastic_Pole_EP1_DZ"; _playerOwnedPlots = []; diag_log format["Running pole stuff for char %1", _characterID]; diag_log format["All Poles: %1", _allPoleObjs]; { diag_log format["Pole: %1",_x]; _ownerID = _x getVariable["CharacterID","0"]; diag_log format["Owner of pole: %1", _ownerID]; if (_ownerID == _characterID) then { diag_log format["Owner: %1 == Char: %2", _ownerID, _characterID]; _playerOwnedPlots set [(count _playerOwnedPlots), _x]; }; } forEach (_allPoleObjs); diag_log format["Player owned plots: %1", _playerOwnedPlots]; _player_death_object_record = [ _characterID, _playerID, _playerOwnedPlots ]; diag_log format["Player death records: %1", _player_death_object_record]; DeadPlayerPlotObjects set [(count DeadPlayerPlotObjects), _player_death_object_record]; diag_log format["DeadPlayerObjects: %1", DeadPlayerPlotObjects]; now create a new file in the /compile folder called server_changePlotsOwner.sqf and add
    private ["_charID", "_playerID", "_playerObj", "_oldCharID", "_playaID", "_plots", "_removePlayerObjects", "_loc", "_dir", "_objCharID", "_classname", "_obj"]; _charID = _this select 0; _playerID = _this select 1; _playerObj = _this select 2; //Check if player had any plots diag_log ("Hello New player"); diag_log format["Your ID: %1 - %2 - %3", _playerID, _playerObj, _charID]; diag_log DeadPlayerPlotObjects; diag_log format["Dead players count: %1", (count DeadPlayerPlotObjects)]; { diag_log format["player object found: %1",_x]; _oldCharID = _x select 0; _playaID = _x select 1; _plots = _x select 2; diag_log format["Old Character: %1 PlayerID: %2 Plots: %3", _oldCharID, _playaID, _plots]; if (count _plots > 0) then { if (_playaID == _playerID) then { // User was found { // assign plots to new character diag_log format["Type: %1", typeOf _x]; _x setVariable ["CharacterID", _charID, true]; diag_log format["Plot %1 is now owned by %2", _x, _x getVariable ["CharacterID","0"]]; } forEach (_plots); _removePlayerObjects set [count _removePlayerObjects, _x]; }; }; } forEach (DeadPlayerPlotObjects); DeadPlayerPlotObjects = DeadPlayerPlotObjects - _removePlayerObjects; Thats it... feel free to remove the diag_log lines if you want. Now save all the files and repack your dayz_server.pbo file.
     
    I'm trying to get object swapping to work so that there is no need for the database triggers but having issues with that part. For now the above works fine
×
×
  • Create New...