Sign in to follow this  
Followers 0
Pixel

Variable help

13 posts in this topic

Normally when I do player iPrintLnBold("Example"); I put trigger waittill("trigger" , player ); before hand so player is defined. When I do trigger waittill("trigger" , player "); I can then put player infront of things like iPrintLnBold etc...

 

My question is, how do I call "player" without using it in the waittill command? I'm sure there's another way. I've also tried "self" but it looks like that also needs to be defined. I can't use the waittill command because it bugs a script I made.

 

Thanks for any help.

0

Share this post


Link to post
Share on other sites

Like this maybe ?

for(;;)
	{
		self waittill("trigger", player); // Wait until its triggered
		if(player.sessionstate != "playing")// Make sure the player is playing
			continue;

		if(!level.allow_vender)// If vending machines are not allowed then say a message
		{
			player iPrintlnBold("^2Defect");
			continue;
		}

Or like this idk, just trying to help :P

iPrintLnBold("^1What! ^5"+ player.name + " has opened the secret minigame!");

And I love this trap >: 3

minefields()
{
	minefields = getentarray("mine", "targetname");
	if (minefields.size > 0)
	{
		level.mine = loadfx ("boss/mine");
	}
	
	for(i = 0; i < minefields.size; i++)
	{
		minefields[i] thread minefield_think();
	}	
}

minefield_think()
{
	while (1)
	{
		self waittill ("trigger",other);
		
		if(isPlayer(other))
			other thread minefield_kill(self);
	}
}

minefield_kill(trigger)
{
	if(isDefined(self.minefield))
		return;
		
	self.minefield = true;
	self playsound ("click_m"); //ahh it usly says missing soundaliases

	wait(.01);
	wait(randomFloat(.01));//did you ad wait? no, I want to

	if(isdefined(self) && self istouching(trigger))
	{
		origin = self getorigin();
		range = 100;
		maxdamage = 2000;
		mindamage = 50;
        wait 0.1;
		self playsound("mine_explo");
		playfx(level.mine, origin);
		wait 0.1;
		radiusDamage(origin, range, maxdamage, mindamage);
	}
	
	self.minefield = undefined;
}
0

Share this post


Link to post
Share on other sites

You can store all player entities in a array:

players = GetEntArray( "player", "classname" );
A single player would then look like this:

players[i] // i = player's entity number in the array
A bit more information about how you want to get the player entity would be helpful though.
0

Share this post


Link to post
Share on other sites

Alright Imagine. I'll try something like you said soon :)

 

EDIT: How can I use this for:

 

player iPrintLnBold? (I don't know much about arrays unfortunately)

0

Share this post


Link to post
Share on other sites

I don't wanna reveal it, so I'll post something in the same format.

 

example1()

{

blah = getent("blah","targetname");

trigger waittill("trigger");

 

iPrintLnBold("Activator has trolled");

 

thread example2();

}

 

example2()

{

breh = getent("breh","targetname");

 

breh rotateRoll(360,2);

player iPrintLnBold("Good Luck!"); // This calls an error as player isn't a variable, it doesn't fix it if I add it in the example1() thread, using self doesn't work, and using waittill with this part bugs the trap!

}

0

Share this post


Link to post
Share on other sites

Just make a new function and have it wait for the trigger to be triggered there?

0

Share this post


Link to post
Share on other sites

Hmm I was hoping I wouldn't have to do that. I'm not asking about this to solve a temporary problem, but to also learn and expand my knowledge for future scripts.

0

Share this post


Link to post
Share on other sites

Hmm I was hoping I wouldn't have to do that. I'm not asking about this to solve a temporary problem, but to also learn and expand my knowledge for future scripts.

It's not an easy way out, there's just no point in making it any more complicated. ;)

0

Share this post


Link to post
Share on other sites

wait but which player do you want to print it to?

 

I believe he wants it to print for all jumpers.

 

As JR-Imagine said, define all players by the classname, then (in a for loop with players.size as the max loops) if players is alive && players is on allies team players printlnbold( "Your Text Here" );

 

Excuse my psuedocode but I'd rather you write the script yourself as it'll help you learn.

 

However, in the example you provided. Perhaps add a trigger multiple in front of the trap that prints the text on their screen once (using a player.variable). This way, they know the text is in reference to what is in front of them as players behind or in front of the trap shouldn't need the text I'd assume. Unless of course the trap is map-wide, in which case niiiiiiiiiiiiiiiiiiiiiiiiiiice.

 

Hopefully you can find a solution from the information i've provided.

0

Share this post


Link to post
Share on other sites

Thanks Darmuh I'll work on the information you gave me and see if I can put something together :)

0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0