Modme Forums
Menu:

Stuck with a script

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


ModmeBot:

Thread By: soul-toktzt
I'm trying to makea script where players need to press a button and run to the other side of the hallway, but if they don't make it in time, they get teleported back.

i've been trying for a long time now and i can't really manage it, everything works, except the teleportation happens the moment you touch the trigger when you start to run into the hallway, not when you are touching the trigger AFTER the doors closed again.


Could anyone take a look please?

Thanks in advance!


ModmeBot:

Reply By: Abnormal202

soul-toktzt
I'm trying to make a script where players need to press a button and run to the other side of the hallway, but if they don't make it in time, they get teleported back. i've been trying for a long time now and i can't really manage it, everything works, except the teleportation happens the moment you touch the trigger when you start to run into the hallway, not when you are touching the trigger AFTER the doors closed again. Could anyone take a look please? Thanks in advance!

I'm not entirely sure what the problem is, but I do see some inefficiencies with the script. For one, since you are moving all the gates at the same times, I would recommend making them an array by giving them all the KVP targetname: gate and using this:
gates = GetEntArray("gate","targetname");
then everytime in script when you want to move all of them, just use:
for(i=0;i<gates.size;i++) {="" gates[i]="" movez(91,1);=""></gates.size;i++)>
It's not necessary, but it's important you start working with arrays if you want to get better at scripting, and saving long list typing of things like:
front_gate movez(91,1);
end_gate1 movez(91,1);
end_gate2 movez(91,1);
end_gate3 movez(91,1);
wait 10;
front_gate movez(-91,5);
end_gate1 movez(-91,5);
end_gate2 movez(-91,5);
end_gate3 movez(-91,5);
wait 5;
maybe it's not so bad with 4 items, but wait til you have to move 20 things, or a 100 things at once.

Then you have a while() in there for no reason:
while(1)
    {
    areatrig waittill("trigger", player);
    player_teleporter_init();
    }
    break;
since you're not looping anything, it could just be:
areatrig waittill("trigger", player);
player_teleporter_init();
you're gonna have to be specific with the problem. Although your script is a little inefficient, I think it should still work, except for that you never thread your original function again, so it should be impossible to hit the button and run for the gates again (but maybe you wanted it that way).

Anyway, don't think I'm being mean, we all have to start somewhere, and mistakes are how we learn. I prefer a post asking for help on a script way more than a post asking for someone else to make a script for them.


ModmeBot:

Reply By: soul-toktzt

Abnormal202
soul-toktzt I'm trying to make a script where players need to press a button and run to the other side of the hallway, but if they don't make it in time, they get teleported back. i've been trying for a long time now and i can't really manage it, everything works, except the teleportation happens the moment you touch the trigger when you start to run into the hallway, not when you are touching the trigger AFTER the doors closed again. Could anyone take a look please? Thanks in advance! I'm not entirely sure what the problem is, but I do see some inefficiencies with the script. For one, since you are moving all the gates at the same times, I would recommend making them an array by giving them all the KVP targetname: gate and using this: gates = GetEntArray("gate","targetname"); then everytime in script when you want to move all of them, just use: for(i=0;i<gates.size;i++) {="" gates="" movez(91,1);="" }="" it's="" not="" necessary,="" but="" it's="" important="" you="" start="" working="" with="" arrays="" if="" you="" want="" to="" get="" better="" at="" scripting,="" and="" saving="" long="" list="" typing="" of="" things="" like:="" front_gate="" movez(91,1);="" end_gate1="" movez(91,1);="" end_gate2="" movez(91,1);="" end_gate3="" movez(91,1);="" wait="" 10;="" front_gate="" movez(-91,5);="" end_gate1="" movez(-91,5);="" end_gate2="" movez(-91,5);="" end_gate3="" movez(-91,5);="" wait="" 5;="" maybe="" it's="" not="" so="" bad="" with="" 4="" items,="" but="" wait="" til="" you="" have="" to="" move="" 20="" things,="" or="" a="" 100="" things="" at="" once.="" ="" then="" you="" have="" a="" while()="" in="" there="" for="" no="" reason:="" while(1)="" {="" areatrig="" waittill("trigger",="" player);="" player_teleporter_init();="" }="" break;="" since="" you're="" not="" looping="" anything,="" it="" could="" just="" be:="" areatrig="" waittill("trigger",="" player);="" player_teleporter_init();="" you're="" gonna="" have="" to="" be="" specific="" with="" the="" problem.="" although="" your="" script="" is="" a="" little="" inefficient,="" i="" think="" it="" should="" still="" work, except="" for="" that="" you="" never="" thread="" your="" original="" function="" again,="" so="" it="" should="" be="" impossible="" to="" hit="" the="" button="" and="" run="" for="" the="" gates="" again="" (but="" maybe="" you="" wanted="" it="" that="" way).="" ="" anyway,="" don't="" think="" i'm="" being="" mean,="" we="" all="" have="" to="" start="" somewhere,="" and="" mistakes="" are="" how="" we="" learn.="" i="" prefer="" a="" post="" asking="" for="" help="" on="" a="" script="" way="" more="" than="" a="" post="" asking="" for="" someone="" else="" to="" make="" a="" script="" for="" them.=""
=""></gates.size;i++)> Hey, thanks, i was planning to do it in an array, but no idea why i didn't do it.

The problem is, that once the 10 seconds are over, players inside the hallway have to teleport back to the beginning. But everytime when i enter the hallway after the door opens, i get instantly teleported. NOT after the 10 seconds.

I could've just done wait 10 and then the teleport script, but if players went through the hallway, they would've teleported back eventually, (i tried it already on a different location.)


What i actually wanted is a trigger_multiple across the whole hallway with the teleport script, but you will only get teleported back if you are inside the trigger after the 10 seconds.


Edit: I don't think you're mean, i've been trying to build this map with my own scripting, (except some scripts like the teleport).

Edit2: I changed it a bit, so now the end-gate pushes the ones inside the hallway all the way to the beginning :)


ModmeBot:

Reply By: Abnormal202

soul-toktzt
Edit2: I changed it a bit, so now the end-gate pushes the ones inside the hallway all the way to the beginning :)

Does that mean you got it working? or are you still having problems?


ModmeBot:

Reply By: soul-toktzt

Abnormal202
soul-toktzt Edit2: I changed it a bit, so now the end-gate pushes the ones inside the hallway all the way to the beginning :) Does that mean you got it working? or are you still having problems?

What i actually wanted isn't working. But i changed the script to an alternative. And that one works.