Modme Forums
Menu:

Moving object, Loop, Trigger

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


ModmeBot:

Thread By: Another

Hi,

I want to create a system that works like this :

1. Player hit trigger > object move "A" To "B"

2. Player hit trigger > object move "B" To "C"

3. Player hit trigger > object move "C" To "A"

The player can activate it as much as he wishes, i tried to make the script but I'm confused and I don't know how to do it.

Here's the script I wrote, it's a good start or I totally failed ? I'm trying to learn so excuse me for the mistakes I probably made

tgr = GetEnt("target", "targetname");
tgr waittill( "damage", amount, attacker, direction_vec, point, type, tagName, modelName, partName, weapon, dFlags, inflictor, chargeLevel );
    
if( weapon == GetWeapon("weapon"))
{

	move = 0;
	
	for( i=0; i<move.size; i++="" )="" {="" if(move[i]="=" 1)="" {="" model="GetEnt("target"," "targetname");="" model="" moveto((-316,452,228),="" 10,="" 2.5,="" 2.5="" );="" }="" else="" if(move[i]="=" 2)="" {="" model="GetEnt("target"," "targetname");="" model="" moveto((-316,695,228),="" 10,="" 2.5,="" 2.5="" );="" }="" else="" if(move[i]="=" 3)="" {="" model="GetEnt("target"," "targetname");="" model="" moveto((-316,452,228),="" 10,="" 2.5,="" 2.5="" );="" }="" else="" if(move[i]="=" 4)="" {="" model="GetEnt("target"," "targetname");="" model="" moveto((-316,695,228),="" 10,="" 2.5,="" 2.5="" );="" move="0;" }="" move="" ++;="" }="" }=""></move.size;>


ModmeBot:

Reply By: hahaDuNOOB

if i will do this i do this like this

function main()
{
	thread setup();
}

function setup()
{
	thread trigger1();
	thread trigger2();
	thread trigger3();
}

function trigger1()
{
	tgr1 = GetEnt("tgr1", "targetname");
	model1 = GetEnt("model1", "targetname");
	tgr1 waittill("trigger", user);
	model1 MoveTo((-316,452,228), 10, 2.5, 2.5 );
	//if need to delete
	//tgr1 Delete();
	//model1 Delete();
}

function trigger2()
{
	tgr2 = GetEnt("tgr2", "targetname");
	model2 = GetEnt("model2", "targetname");
	tgr2 waittill("trigger", user);
	model2 MoveTo((-316,452,228), 10, 2.5, 2.5 );
	//if need to delete
	//tgr1 Delete();
	//model1 Delete();
}

function trigger3()
{
	tgr3 = GetEnt("tgr3", "targetname");
	model3 = GetEnt("model3", "targetname");
	tgr3 waittill("trigger", user);
	mode3 MoveTo((-316,452,228), 10, 2.5, 2.5 );
	//if need to delete
	//tgr1 Delete();
	//model1 Delete();
}


ModmeBot:

Reply By: DTZxPorter

So to clarify for other users, you're basically creating like in-game arrow keys for an object, press (trigger) move left, press (trigger) move right?


ModmeBot:

Reply By: Another

DTZxPorter

So to clarify for other users, you're basically creating like in-game arrow keys for an object, press (trigger) move left, press (trigger) move right?

Yes, that's it

EDIT: It's good, I finally succeeded. I used a different method but it suits me

Thanks for your help.

Here is the script I use :

function name_your_function()
{
	trigger_1 = GetEnt("target", "targetname");
	model_1 = GetEnt("target", "targetname");

	while(1)
        {
	      trigger_1 waittill("trigger", user);
	      random = RandomIntRange( 0, 5 ); 
	      switch( random )
	{
		case 0: //Loc. 1
			model_1 MoveTo((X, Y, Z), 2, 0.05, 0.05 );
			wait (2.5);
			break;
		case 1: //Loc. 2
			model_1 MoveTo((X, Y, Z), 2, 0.05, 0.05 ); 
			wait (2.5);
			break;
		case 2: //Loc. 3
			model_1 MoveTo((X, Y, Z), 2, 0.05, 0.05 ); 
			wait (2.5);
			break;
		case 3: //Loc. 4
			model_1 MoveTo((X, Y, Z), 2, 0.05, 0.05 ); 
			wait (2.5);
			break;
		case 4: //Loc. 5
			model_1 MoveTo((X, Y, Z), 2, 0.05, 0.05 ); 
			wait (2.5);
			break;
		default: //Default Location
			model_1 MoveTo((X, Y, Z), 2, 0.05, 0.05 ); 
			wait (2.5);
			break;
//2  time to move the entity in seconds
//0.05 time spent accelerating
//0.05 time spent decelerating
	}
    }
}