I want to use this script but I can't seem to get my playermodel to swap back once I use a suit. I followed this other tutorial on random characters here:
https://ugx-mods.com/forum/index.php/topic,7214.0.html Does that affect anything? What happens is for example: I'm Dempsey and I go up to a suit and become a spaceman. When I return the spaceman suit I don't change back into Dempsey I'm just invisible.
Here is my code:
init(){ level.switchsuitsweapon = "undefined";//"zombie_melee";//make undefined if no switching wanted // SetUp(suit, viewmodel, hud, ::function); thread SuitSetup("normal","undefined", undefined, ::NormalSuit); //Use the following for one type of suit and just copy the prefab for more of that type of suit thread SuitSetup("suit0", "viewmodel_usa_marine_arms", undefined, ::Suit0Reward);//one type of suit, copy the prefab for more than one of this type of suit //uncomment the following for as many different suits that you have, spacesuit, gas, halo, for example // thread SuitSetup("suit1", undefined, undefined, ::Suit1Reward);//another type of suit, copy the prefab for more than one of this type of suit // thread SuitSetup("suit2", undefined, undefined, ::Suit2Reward);//another type of suit, copy the prefab for more than one of this type of suit // thread SuitSetup("suit3", undefined, undefined, ::Suit3Reward);//another type of suit and so on... //add more suits if you like, and add reward functions if applicable suits = getentarray("suit", "targetname"); array_thread( suits,::PickMeUp ); } SuitSetUp(suit, viewmodel, hud, function){ /*suit = string, that matches script_noteworthy kvp of trigger for suit prefab viewmodel = <optional> - change viewmodel hud = <optional> - change hud function = <optional> - function to run when suit is put on i.e. shield or fx or sounds or something */ if(!IsDefined( level.suits )) level.suits = []; level.suits[suit] = []; level.suits[suit]["viewarms"] = viewmodel; level.suits[suit]["hud"] = hud; level.suits[suit]["function"] = function; } Suit0Reward(){ self endon( "disconnect" ); self endon("suit_change"); while(1){ //your code here iPrintLnBold("I'm a Spaceman!"); wait(1); } } Suit1Reward(){ self endon( "disconnect" ); self endon("suit_change"); /*while(1){ //your code here wait(1); }*/ } Suit2Reward(){ self endon( "disconnect" ); self endon("suit_change"); /*while(1){ //your code here wait(1); }*/ } Suit3Reward(){ self endon( "disconnect" ); self endon("suit_change"); /*while(1){ //your code here wait(1); }*/ } NormalSuit(){ self endon( "disconnect" ); self endon("suit_change"); //reset anything you changed here when no suit is on } PickMeUp(){ self.active = 1; self SetCursorHint( "HINT_NOICON" ); while(1){ self FixTrigger(); self waittill("trigger", player); if(!isdefined(player.suit)){ player.suit = "normal"; } player PlayLocalSound( "deny" ); if(player.suit =="normal" & self.script_noteworthy=="normal") continue; player PutOnSuit(self); pieces = getentarray(self.target, "targetname"); for(i=0;i<pieces.size;i++){ pieces[i] thread RackSuit(player, player.suit); } suit = player.suit; player.suit = self.script_noteworthy; self.script_noteworthy = suit; player notify("suit_change"); if(IsDefined( level.suits[player.suit]["function"] )) player thread [[level.suits[player.suit]["function"]]](); wait(.01); } } FixTrigger(){ self sethintstring(""); wait(2); if(self.script_noteworthy == "normal") self sethintstring("Press &&1 to rack suit."); else self sethintstring("Press &&1 to take Suit."); } RackSuit(player, suit){ if(self.script_noteworthy=="head"){ if(player.rackhead!=player.currenthead & player.headModel!=player.rackhead) player detach(player.rackhead); self setmodel(player.rackhead); } if(self.script_noteworthy=="body") self setmodel(player.rackbody); level notify("suit_change"); } PutOnSuit(suit){ if(!IsDefined( self.currenthead )) self.currenthead = "tag_origin"; else self detach(self.currenthead , "", true); if(!IsDefined( self.currentbody )) self.currentbody = "tag_origin"; if(isdefined(self.hatModel)) self detach(self.hatModel, "", true); if(IsDefined( self.headModel )) self detach(self.headModel, ""); pieces = GetEntArray( suit.target,"targetname" ); doHead = 0; swapHead = undefined; for( i=0;i<pieces.size;i++ ){ if(pieces[i].script_noteworthy=="head"){ if(pieces[i].model=="tag_origin" & isdefined(self.headModel)) { if(suit.script_noteworthy=="normal") doHead = 1; self.rackhead = self.currenthead; self.currenthead = "tag_origin"; }else{ swapHead = pieces[i].model; self.rackhead = self.currenthead; self.currenthead = pieces[i].model; } } if(pieces[i].script_noteworthy=="body"){ if(pieces[i].model=="tag_origin" & isdefined(self.bodyModel)) { if(suit.script_noteworthy=="normal") self setModel(self.bodyModel); self.rackbody = self.currentbody; self.currentbody = "tag_origin"; }else{ self setmodel(pieces[i].model); self.rackbody = self.currentbody; self.currentbody = pieces[i].model; } } } //moved down here so the head doesn't get attached before the body is swapped if(doHead){ if(IsDefined( self.headModel )) self attach(self.headModel, "", true); if(isdefined(self.hatModel)) self attach(self.hatModel, "", true); } if(IsDefined(swapHead)) self attach(swapHead); //set viewarms if(IsDefined( self.viewmodel ) & suit.script_noteworthy == "normal") self SetViewModel( self.viewmodel); else if(IsDefined( level.suits[suit.script_noteworthy]["viewarms"] )) self SetViewModel( level.suits[suit.script_noteworthy]["viewarms"]); else if(IsDefined( level.suits["normal"]["viewarms"] )) self setViewModel(level.suits["normal"]["viewarms"]);//take off suit arms if none defined but normal was defined //add hud for suit for remove self thread MakeHud(level.suits[suit.script_noteworthy]["hud"]); //give affect for swaping self thread ChangeSleeves(); } ChangeSleeves(){ self endon( "disconnect" ); time = .6; self.suithud["transistion"] = NewClientHudelem( self ); self.suithud["transistion"].horzAlign = "fullscreen"; self.suithud["transistion"].vertAlign = "fullscreen"; self.suithud["transistion"] SetShader( "black", 640, 480 ); self.suithud["transistion"].alpha = 1; //show sleeves if the weapon is defined if(IsDefined( level.switchsuitsweapon ))self thread ShowSleeves(); self.suithud["transistion"] fadeOverTime( time ); self.suithud["transistion"].alpha = 0; wait(.5); wait(time-.5); self.suithud["transistion"] destroy(); self.suithud["transistion"] = undefined; } ShowSleeves(){ self DisableWeaponCycling( ); self GiveWeapon( level.switchsuitsweapon ); self switchToWeapon(level.switchsuitsweapon); self waittill("weapon_change_complete"); self takeWeapon( level.switchsuitsweapon ); self enableWeaponCycling( ); self switchToWeapon(self GetWeaponsListPrimaries()[0]); } MakeHud(shader){ self endon( "disconnect" ); if(!isdefined(shader)){ if(isdefined(self.suithud["suits"])) self.suithud["suits"] destroy(); return; } if(isdefined(self.suithud["suits"])) self.suithud["suits"] destroy(); self.suithud["suits"] = create_simple_hud(self); self.suithud["suits"].y = 0; self.suithud["suits"].x = 0; self.suithud["suits"].alpha = 1; self.suithud["suits"].horzAlign = "fullscreen"; self.suithud["suits"].vertAlign = "fullscreen"; self.suithud["suits"].foreground = false; self.suithud["suits"] SetShader( shader, 640, 480 ); }