Modme Forums

How do I set up the buyable trigger for my elevator (Five)?

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: Akrime
So, I'm working on an elevator (Five style). I'm new to triggers, so I've set up the "use trigger". I want to change them, so the player has to pay 250 points to use the elevator.

Here's a preview of my elevator (the door moving slightly down is fixed now):



I might release this elevator for public use, if you guys want it.


ModmeBot:

Reply By: ZombieKid164
I actually have an elevator (better than my released versions) which has actual elevator parts, sounds, etc., and yes, the script works perfectly. Send me a message on discord if you are interested. I'm ZombieKid164#7657, but you could also find me on the modme discord.


ModmeBot:

Reply By: Abnormal202
not bad. Mind if I see your script? I always appreciate when people script for their own. I've made many an elevator in my time and could help you with any specific problems you have.


ModmeBot:

Reply By: Akrime

Abnormal202
not bad. Mind if I see your script? I always appreciate when people script for their own. I've made many an elevator in my time and could help you with any specific problems you have.


I managed to fix my doors, my elevator moves properly now. I need help about making the trigger not useable until my elevator is up. I'd also like sounds to play for everyone in a radius.

Inside of main()

// Lift
level.liftStatus = "down";
level.liftDoorStatus = "open";
thread Lift();


My functions:
NOTE: I pass the Entites (lift, liftdoorright, liftdoorleft) through the functions because I'm going to use 4 lifts in my map. My doors are models, so I had to set up clips for them, that's why I have an array for it.

function Lift()
{
	// Variables
	liftDoorRight = GetEntArray("liftdoorright", "targetname");
	liftDoorLeft = GetEntArray("liftdoorleft", "targetname");
	lift = GetEntArray("lift", "targetname");
	trig = GetEnt("lifttrigger", "targetname");

	// Process
	trig setHintString("Press &&1 to use the elevator");

	while(true)
	{
		trig waittill("trigger", player);
		LiftDoors(liftDoorRight, liftDoorLeft, 39, 1);
		wait 1.5;
		MoveEntireLift(1298.5, trig, lift, liftDoorRight, liftDoorLeft, 7);
		wait 7.5;
		LiftDoors(liftDoorRight, liftDoorLeft, 39, 1);
		wait 1.5;
	}
}

function MoveEntireLift(distance, trigger, lift, liftDoorRight, liftDoorLeft, seconds)
{
	if(level.liftStatus == "down")
	{
		// Move doors up
		foreach(liftDoorRight in liftDoorRight)
		{
			liftDoorRight MoveZ(distance, seconds);	
		}

		foreach(liftDoorLeft in liftDoorLeft)
		{
			liftDoorLeft MoveZ(distance, seconds);	
		}
		
		// Move every model up
		foreach(lift in lift)
		{
		lift MoveZ(distance, seconds);
		}
		level.liftstatus = "up";
	}
	else
	{
		// Move doors down
		foreach(liftDoorRight in liftDoorRight)
		{
			liftDoorRight MoveZ(-distance, seconds);	
		}

		foreach(liftDoorLeft in liftDoorLeft)
		{
			liftDoorLeft MoveZ(-distance, seconds);	
		}

		// Move every model down
		foreach(lift in lift)
		{
			lift MoveZ(-distance, seconds);
		}
		level.liftstatus = "down";
	}
}

function LiftDoors(liftDoorRight, liftDoorLeft, distance, seconds)
{
	// NOTE: This function checks if the doors are already closed or not, so it's impossible that the doors open twice

	if(level.liftDoorStatus == "closed")
	{
		foreach(liftDoorRight in liftDoorRight)
		{
			liftDoorRight MoveY(-distance, seconds);	
		}
		
		foreach(liftDoorLeft in liftDoorLeft)
		{
			liftDoorLeft MoveY(distance, seconds);
		}

		level.liftDoorStatus = "open";
	}
	else
	{
		foreach(liftDoorRight in liftDoorRight)
		{
			liftDoorRight MoveY(distance, seconds);	
		}

		foreach(liftDoorLeft in liftDoorLeft)
		{
			liftDoorLeft MoveY(-distance, seconds);	
		}
		
		level.liftDoorStatus = "closed";
	}
}


ModmeBot:

Reply By: Harry Bo21

#using scripts\zm\_zm_audio;
#using scripts\zm\_zm_score;

function Lift()
{
	// Variables
	liftDoorRight = GetEntArray("liftdoorright", "targetname");
	liftDoorLeft = GetEntArray("liftdoorleft", "targetname");
	lift = GetEntArray("lift", "targetname");
	trig = GetEnt("lifttrigger", "targetname");

	// Process
	trig setHintString("Press &&1 to use the elevator [Cost: 250]");

	while(true)
	{
		trig waittill("trigger", player);

                if( !player zm_score::can_player_purchase( 250 ) )
		{
			self playSound( "evt_perk_deny" );
			player zm_audio::create_and_play_dialog( "general", "outofmoney" );
			continue;
		}

		LiftDoors(liftDoorRight, liftDoorLeft, 39, 1);
		wait 1.5;
		MoveEntireLift(1298.5, trig, lift, liftDoorRight, liftDoorLeft, 7);
		wait 7.5;
		LiftDoors(liftDoorRight, liftDoorLeft, 39, 1);
		wait 1.5;
	}
}


ModmeBot:

Reply By: Akrime

Harry Bo21
#using scripts\zm\_zm_audio; #using scripts\zm\_zm_score; function Lift() { // Variables liftDoorRight = GetEntArray("liftdoorright", "targetname"); liftDoorLeft = GetEntArray("liftdoorleft", "targetname"); lift = GetEntArray("lift", "targetname"); trig = GetEnt("lifttrigger", "targetname"); // Process trig setHintString("Press &&1 to use the elevator [Cost: 250]"); while(true) { trig waittill("trigger", player); if( !player zm_score::can_player_purchase( 250 ) ) { self playSound( "evt_perk_deny" ); player zm_audio::create_and_play_dialog( "general", "outofmoney" ); continue; } LiftDoors(liftDoorRight, liftDoorLeft, 39, 1); wait 1.5; MoveEntireLift(1298.5, trig, lift, liftDoorRight, liftDoorLeft, 7); wait 7.5; LiftDoors(liftDoorRight, liftDoorLeft, 39, 1); wait 1.5; } }

Thank you! Just what I was looking for.