Jump to content
  • 0

Player Model Morph


therisingdead

Question

Hi, I want to morph a players skin live in game, similar to the way it was done in origins. So if a player reaches a certain humanity level there default_model is changed.

This is what I have soo far but it doesn't work:

 

// Skin Changer
Private ["_humanity"];

waitUntil {!isNil ("PVDZE_plr_LoginRecord")}; // Check that player is logged in
_humanity = (player getVariable["humanity",0]); // Get and set humanity

if((_humanity) <= -15000) then {
diag_log "You are a level 3 Bandit -  Your default skin has been changed";
//Overridden default skin here
DefaultModel = "TK_Soldier_Spotter_EP1";
}; // Level 3 Bandit

if((_humanity) >= -14999) and ((_humanity) <= -10000) then {
diag_log "You are a level 2 Bandit -  Your default skin has been changed";
//Overridden default skin here
DefaultModel = "TK_INS_Soldier_AAT_EP1";
}; // Level 2 Bandit

if((_humanity) >= -9999) and ((_humanity) <= -1) then {
diag_log "You are a level 1 Bandit -  Your default skin has been changed";
//Overridden default skin here
DefaultModel = "TK_CIV_Takistani02_EP1";
}; // Level 1 Bandit

if((_humanity) >= 15000) then {
diag_log "You are a level 3 Hero -  Your default skin has been changed";
//Overridden default skin here
DefaultModel = "FR_Assault_R";
}; // Level 3 Hero

if((_humanity) <= 14999) and ((_humanity) >= 10000) then {
diag_log "You are a level 2 Hero -  Your default skin has been changed";
//Overridden default skin here
DefaultModel = "USMC_Soldier_Medic";
}; // Level 2 Hero

if((_humanity) <= 9999) and ((_humanity) >= 0) then {
diag_log "You are a level 1 Hero -  Your default skin has been changed";
//Overridden default skin here
DefaultModel = "CDF_Soldier_Light";
}; // Level 1 Hero
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

I don't see you changing the character model anywhere. All you are doing is setting a variable to the skin you want to use. Where is your actual model change?

 

Here is an example of how to do the change correctly. You will need to test to see if this deletes your backpack. If it does, I will give you code to counteract that.

if((_humanity) <= -15000) then {
diag_log "You are a level 3 Bandit -  Your default skin has been changed";
//Overridden default skin here
[dayz_playerUID,dayz_characterID,"TK_Soldier_Spotter_EP1"] spawn player_humanityMorph;
}; // Level 3 Bandit

Link to comment
Share on other sites

  • 0

Well remember this will only run when you log in to the server and your humanity is -15000 for the example I gave you. If you want it to run only when a change in humanity happens then you would need to implement a custom player_humanityChange.sqf and add it to the custom compiles. I would personally suggest doing it this way. I know spawning humanity morph works because that is how I do it on the admin tools.

 

I also just noticed you have some issues in your code:

if((_humanity) >= -14999) and ((_humanity) <= -10000) then {

should be 

if((_humanity) >= -14999) and ((_humanity) <= -10000)) then {

You have this issue in a few spots.

Link to comment
Share on other sites

  • 0

Something Along the lines of this?

 

private ["_object","_change","_wait","_humanity","_model","_isMen","_isMenH","_isMenB","_isWomen","_isWomenH","_isWomenB"];
_object = _this select 0;
_change = _this select 1;
_wait = if (count _this > 2) then { _this select 2 } else { 0 };

if (_object == player) then {
	_humanity = (player getVariable["humanity",0]) + _change;
	player setVariable["humanity",_humanity,true];
	if (_change < 0) then { //non-bandit player can be "punished" in next "_wait" seconds w/o loosing humanity
		if ((_humanity > -2000) and (_wait > 0)) then {
			player setVariable ["freeTarget",true,true];
			player setVariable ["FTcounter",((player getVariable ["FTcounter",0]) + _wait)];
			[_wait] spawn {
				private ["_endtime","_wait"];
				_wait = _this select 0;
				_endTime = diag_tickTime + _wait;
				waitUntil { sleep 1; diag_tickTime > _endTime };
				player setVariable ["FTcounter",((player getVariable ["FTcounter",0]) - _wait)];
				if ((player getVariable ["FTcounter",0]) <= 0) then {
					player setVariable ["FTcounter",0];
					player setVariable ["freeTarget",false,true];
				};
			};
		};
	};

	_model = typeOf player;

	//if model will not be changed by humanity
	if (_model in ["Sniper1_DZ","Soldier1_DZ","Camo1_DZ","Skin_Soldier1_DZ"]) exitWith{};



	_isMen =		_model == "Survivor2_DZ";
	_isMenH =		_model == "Survivor3_DZ";
	_isMenB =		_model == "Bandit1_DZ";
	_isWomen =		_model == "SurvivorW2_DZ";
	_isWomenH =		_model == "SurvivorW3_DZ"; //TODO
	_isWomenB =		_model == "BanditW1_DZ";



	// Bandit
	if (_humanity <= -2000) then {
		if (_isMen || _isMenH) then {
			[dayz_playerUID,dayz_characterID,"Bandit1_DZ"] spawn player_humanityMorph;
		};
		if (_isWomen || _isWomenH) then {
			[dayz_playerUID,dayz_characterID,"BanditW1_DZ"] spawn player_humanityMorph;
		};
	};
/*
	// Survivor p.I //proceed [what if hero become "bad"?]  
	if (_humanity > -2000 && _humanity <=0) then {
		if (_isMenH) then {
			[dayz_playerUID,dayz_characterID,"Survivor2_DZ"] spawn player_humanityMorph;
		};
		if (_isWomenH) then {
			[dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph;
		};
	};
	// Survivor p.II //proceed [time to be "normal"]
	if (_humanity > 0 && _humanity <= 5000) then {
*/
	//Survivor
	if (_humanity > -2000 && _humanity <= 5000) then {
		if (_isMenH || _isMenB) then {
			[dayz_playerUID,dayz_characterID,"Survivor2_DZ"] spawn player_humanityMorph;
		};
		if (_isWomenH || _isWomenB) then {
			[dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph;
		};
	};
	// Hero
	if (_humanity > 5000) then {
		if (_isMen || _isMenB) then {
			[dayz_playerUID,dayz_characterID,"Survivor3_DZ"] spawn player_humanityMorph;
		};
		/*
		if (_isWomen || _isWomenB) then {  //TODO
			[dayz_playerUID,dayz_characterID,"SurvivorW3_DZ"] spawn player_humanityMorph;
		};
		*/
		if (_isWomenB) then { 
			[dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph;
		};
	};
};
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...