Sign in to follow this  
Followers 0
Sheep_Wizard

Help with script

15 posts in this topic

Hi i was wondering if you could help me with something as you all seem quite clever :D

 

So i was making a trigger multiple, that only activates only once when you touch it:

teleporttrigger()
{
trig = getent("fov", "targetname");
level.fovtp = getent("fovtp", "targetname");
for(;;)
{
trig waittill("trigger", player);
if(!isDefined(player.trigged))
{
player.trigged = true;
}
if(player.trigged == true)
{
player thread scale();
player.trigged = false;
}
}
}

So this works but i released that if the player dies they can no longer use the trigger, therefore could not complete the map.

 

So how would i change this so you can still trigger if you die and have re-spawned.

0

Share this post


Link to post
Share on other sites

lossy_tele()

{

self endon("death"); //end on death

self endon( "disconnect" ); //end on disconnect

self endon( "joined_team" ); //end when joining team aka player gets switch to activator because old acti was afk...

self endon( "joined_spectators" ); //end when joining spectator

trig = getent("fov", "targetname");

level.fovtp = getent("fovtp", "targetname");

define_player_here thread onDeath_lossy_tele();

wait .1;

//do script stuff here

//constantly checking if player is alive

for(;;)

{

wait .1;

while(isAlive(player))

{

wait 1;

}

}

}

onDeath_lossy_tele()

{

self endon("disconnect");

self waittill("death"); //will thread script/trigger again upon death

thread lossy_tele();

}

0

Share this post


Link to post
Share on other sites
lossy_tele()
{
	self endon("death"); //end on death
	self endon( "disconnect" );	 //end on disconnect
	self endon( "joined_team" ); //end when joining team aka player gets switch to activator because old acti was afk...
	self endon( "joined_spectators" ); //end when joining spectator
	
	
	trig = getent("fov", "targetname");
	level.fovtp = getent("fovtp", "targetname");
	
	define_player_here thread onDeath_lossy_tele();
	wait .1;
	
	
	//do script stuff here
	
	//constantly checking if player is alive
    for(;;)
    {
		wait .1;		
		while(isAlive(player))
		{
			wait 1;
		}
		
    }
}

onDeath_lossy_tele()
{
	self endon("disconnect");
	
	self waittill("death"); //will thread script/trigger again upon death
	thread lossy_tele();
}

Thanks :D, but how would i make it so that multiple people can trigger it at once instead on just one person (sorry forgot to mention)

0

Share this post


Link to post
Share on other sites

Maybe something like this? Lossy's would work, but this is a bit shorter of a script, and does the same thing. Not sure if it's what you're looking for though, but you can try it?:

threadname()
{
     self endon("death"); 
     self endon( "disconnect" );  
     self endon( "joined_team" );
     self endon( "joined_spectators" );
 
     fov = getEnt("trigger_fov","targetname");
 
     while (1)
     {
          trig waittill( "trigger", player );
 
          wait 0.1;
 
         if(player isTouching(fov) && player isOnGround())
         {
             thread fov();
         }
        else()
        {
             break;
        }
     }
}
0

Share this post


Link to post
Share on other sites

 

Maybe something like this? Lossy's would work, but this is a bit shorter of a script, and does the same thing. Not sure if it's what you're looking for though, but you can try it?:

threadname()
{
     self endon("death"); 
     self endon( "disconnect" );  
     self endon( "joined_team" );
     self endon( "joined_spectators" );
 
     fov = getEnt("trigger_fov","targetname");
 
     while (1)
     {
          trig waittill( "trigger", player );
 
          wait 0.1;
 
         if(player isTouching(fov) && player isOnGround())
         {
             thread fov();
         }
        else()
        {
             break;
        }
     }
}

No this triggers it more then once, also i don't think you need the () on else

0

Share this post


Link to post
Share on other sites

The else statement isn't even needed anyway.

Anyway, what you're asking for i haven't done before but i shall and try to make a script tomorrow or day after or when ever i get the time to do so.

0

Share this post


Link to post
Share on other sites

The else statement isn't even needed anyway.

Anyway, what you're asking for i haven't done before but i shall and try to make a script tomorrow or day after or when ever i get the time to do so.

Ok thank you

0

Share this post


Link to post
Share on other sites

Even then, zach's script will not trigger once but the entire time the player is touching the trigger and on the ground fov() would be threaded 60 times in just a second.

Lossy's script was good if you only wanted one player to be able to activate it. But if you want anyone to be able to activate it but only once the script becomes much more simple.

 

darmuh_tele()
{
	self endon("death"); //end on death
	self endon( "disconnect" );	 //end on disconnect
	self endon( "joined_team" ); //end when joining team aka player gets switch to activator because old acti was afk...
	self endon( "joined_spectators" ); //end when joining spectator
	
	self.hasfov = 0;
	
	trig = getent("fov", "targetname");
	level.fovtp = getent("fovtp", "targetname");
	for(;;)
	{
		wait 0.05;
		trig waittill( "trigger", player );
		if ( player.hasfov = 0 )
		{	
			player thread scale();
			player.hasfov = 1;
			player thread onDeath_lossy_tele();
		}
		else
			continue;
    }
}

onDeath_lossy_tele()
{
	self endon("disconnect");
	
	self waittill("death"); //will thread script/trigger again upon death
	self.hasfov = 0;
}
Try this out, it may have bugs/syntax errors since I just wrote this but basically you define a boolean variable that belongs to the character and allow the trigger to be triggered at all times.

If the player who triggers the trigger has not triggered it the boolean variable will allow him to trigger it and then set it so he may not trigger it again. Any other player who comes by will have the same player defined variable that will allow him to trigger it as well. Once they have triggered it once attempting to trigger it again will just continue the loop.

The only thing which I am unsure about in the script is where I defined the player variable. I would much rather define it in main on all players using getentarray players classname bla bla bla but I don't have your main thread.

Hope this helps, if not i'm sure lossy will write something better than me :dave:

0

Share this post


Link to post
Share on other sites

Even then, zach's script will not trigger once but the entire time the player is touching the trigger and on the ground fov() would be threaded 60 times in just a second.

Lossy's script was good if you only wanted one player to be able to activate it. But if you want anyone to be able to activate it but only once the script becomes much more simple.

 

darmuh_tele()
{
	self endon("death"); //end on death
	self endon( "disconnect" );	 //end on disconnect
	self endon( "joined_team" ); //end when joining team aka player gets switch to activator because old acti was afk...
	self endon( "joined_spectators" ); //end when joining spectator
	
	self.hasfov = 0;
	
	trig = getent("fov", "targetname");
	level.fovtp = getent("fovtp", "targetname");
	for(;;)
	{
		wait 0.05;
		trig waittill( "trigger", player );
		if ( player.hasfov = 0 )
		{	
			player thread scale();
			player.hasfov = 1;
			player thread onDeath_lossy_tele();
		}
		else
			continue;
    }
}

onDeath_lossy_tele()
{
	self endon("disconnect");
	
	self waittill("death"); //will thread script/trigger again upon death
	self.hasfov = 0;
}
Try this out, it may have bugs/syntax errors since I just wrote this but basically you define a boolean variable that belongs to the character and allow the trigger to be triggered at all times.

If the player who triggers the trigger has not triggered it the boolean variable will allow him to trigger it and then set it so he may not trigger it again. Any other player who comes by will have the same player defined variable that will allow him to trigger it as well. Once they have triggered it once attempting to trigger it again will just continue the loop.

The only thing which I am unsure about in the script is where I defined the player variable. I would much rather define it in main on all players using getentarray players classname bla bla bla but I don't have your main thread.

Hope this helps, if not i'm sure lossy will write something better than me :dave:

 

Yer this worked thanks :D although if i have developer on i get the error 'cannot cast undefined too bool' the first i use the trigger but it still works. Also it all worked apart from you missed a equals sign on the 'if( player.hasfov = 0 )'

0

Share this post


Link to post
Share on other sites

Yer this worked thanks :D although if i have developer on i get the error 'cannot cast undefined too bool' the first i use the trigger but it still works. Also it all worked apart from you missed a equals sign on the 'if( player.hasfov = 0 )'

told ya there'd be syntax errors :P

0

Share this post


Link to post
Share on other sites

Damn you darmuh you beat me to it.

 

But the only problem i see with this that the players that survive the round wont have their variable reset, i'll search for the notify so that it does reset when the round ends, unless some one else does it before I get back on my pc :)

 

EDIT: nevermind i see darmuh sets it when you activate it anyway

0

Share this post


Link to post
Share on other sites

the lossy thread isn't necessary

 

player.hasfov = 1;

player waittill("death");

player.hasfov = 0;

 

 

^ will work, less code workspace.

 

I'm sure anyway.

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