Okay so all day ive been fiddling with this script and I cant get it to work. Basically I want it so one of the players hits a button but all the alive players has to be in the room(inside the trigger multiple) when it happens or it wont let the script continue. I took a portion of the script from the end game teleport script, and edited it to match mine. but even when the players are standing in the trigger multiple it still says "All players must be in this Room".
Here is the script that handles it
Code Snippet
Plaintext
rocket_launch() //Thread runs once all 5 fuel cans are in the rocket { cost = 5000; //How much money it costs to hit the button //who = undefined; trig = getent("rocket_launch_button","targetname"); //trigger for the button trig setcursorhint("HINT_NOICON"); trig sethintstring("Press &&1 to launch the Rocket [Cost: "+cost+"]"); trig enable_trigger();
trig_player_check = getEnt("lock_in","targetname"); //trigger multiple that covers the entire room
while(1) { trig waittill("trigger",who); //waits for the player to hit the trigger on the button
// got the money ?? if(who.score >= cost) {
who maps\_zombiemode_score::minus_to_player_score(cost);
if(alive.size != touching) { Texthud = tom_make_hud(undefined, "center", "middle", "center", "bottom", 0, -148, 1.2, 1, (1,1,1)); Texthud setText("All players must be in this Room"); //text that comes up when not all of the players are in the room
wait 0.1; // this loop won't run long so lets go mental. } Texthud destroy(); } trig playsound("cha_ching"); trig delete(); door = getent("door10","targetname"); //Door that comes down once the players hit the trigger door moveZ (1000000, .5); } else { trig playsound("no_cha_ching"); } wait 0.15; } } tom_make_hud(client, alignXArg, alignYArg, horzAlignArg, vertAlignArg, xArg, yArg, fontScale, alpha, Textcolor) { if(isDefined(client)) hud = newClientHudElem(client); else hud = newHudElem(); hud.alignX = alignXArg; hud.alignY = alignYArg; hud.horzAlign = horzAlignArg; hud.vertAlign = vertAlignArg; hud.y = yArg; hud.x = xArg; hud.foreground = true; hud.font = "default"; hud.fontScale = fontScale; hud.alpha = alpha; if(isDefined(Textcolor)) hud.color = (Textcolor); else hud.color = ( 1.0, 1.0, 1.0 ); return hud; }
GetTouchingPlayers() { if(isdefined(self)) { players = get_players(); num = 0; for(i=0;i<players.size;i++) if(players[i] istouching(self)) num ++; return num; } else { iPrintLnBold("GetTouchingPlayers(): Needs to be called on a object"); return -1; } }
Make sure the entity you're linking to is actually a trigger (it's targetname is a trigger_XXX type). Alternatively you can link to the model then spawn a trigger through script using the code below.