Become invisible .. but how ?

Have questions about CoD2 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Become invisible .. but how ?

Post by <LT>YosemiteSam[NL] » March 18th, 2011, 9:13 pm

Thx m8 it works, I had to change the code a bit ... 2 "{" removed and a few typo's. :) But it works fine now.
This is the final script;

Code: Select all

invisible() //only call this thread
//dont call any other threads, this one handles everything


{
   thread waitforconnect();
   thread monitortrig();
}

waitforconnect()
{
   for(;;)
   {
      level waittill("connecting",player);
      player thread waitforspawn();
   }
}

waitforspawn()
{
   self endon("disconnect");
   self.isInv=false;
   for(;;)
   {
      self waittill("spawned_player"); //might be "spawned" instead
      self.isInv=false;
   }
}

monitortrig()
{
   trigger=getent("invisible","targetname");
   for(;;)
   {
     trigger waittill("trigger",user);
     if(!user.isInv)

         user iprintlnbold("you are invisible");
         user thread makeinvisible(5); //for 5 seconds the user will be invisible remove the "thread" to make the trigger wait until the user is visible again
     }
   }

makeinvisible(time)
{
   self endon("disconnect");
   self endon("killed_player");
   self endon("spawned_player");
   
   self detachall();
   self setmodel("");
   self.isInv=true;

   wait time;
   
   self iprintlnbold("Invisibility has worn off");

   self.isInv=false;
   
   if(!isdefined(self.pers["savedmodel"]))
      maps\mp\gametypes\_teams::model();
   else
      maps\mp\_utility::loadModel(self.pers["savedmodel"]);
}

The only hickup now is that the sentence "invisibility has worn off" displays not once but more like 10 times. Have to look into that. Now I can combine this with the spawn/respawn weapon and trigger script and I'm good to go.

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Become invisible .. but how ?

Post by IzNoGoD » March 18th, 2011, 11:32 pm

yeah, you need those {} around

Code: Select all

         user iprintlnbold("you are invisible");
         user thread makeinvisible(5); //for 5 seconds the user will be invisible remove the "thread" to make the trigger wait until the user is visible again
else it will only use the "if" on the first line, and make the user invisible like 100 times
LMGTFY!

Its not a glitch... Its the future!

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Become invisible .. but how ?

Post by <LT>YosemiteSam[NL] » March 19th, 2011, 12:18 am

Aha ok.
When they were in the script it gave an error but now that the threading is ok it doesn't. I've put them back in and it works fine. Thx m8 !
I'll give you credit in the map for your hellp btw.
Here is a little demo;

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Become invisible .. but how ?

Post by IzNoGoD » March 19th, 2011, 10:48 am

Still has 2 "worn of" iprintlns.
Silly me, should have scripted the last 2 threads like this:

Code: Select all

monitortrig()
{
   trigger=getent("invisible","targetname");
   for(;;)
   {
     trigger waittill("trigger",user);
     if(!user.isInv)
     {
         user.isInv=true;
         user iprintlnbold("you are invisible");
         user thread makeinvisible(5); //for 5 seconds the user will be invisible remove the "thread" to make the trigger wait until the user is visible again
     }
   }

makeinvisible(time)
{
   self endon("disconnect");
   self endon("killed_player");
   self endon("spawned_player");
   
   self detachall();
   self setmodel("");

   wait time;
   
   self iprintlnbold("Invisibility has worn off");

   self.isInv=false;
   
   if(!isdefined(self.pers["savedmodel"]))
      maps\mp\gametypes\_teams::model();
   else
      maps\mp\_utility::loadModel(self.pers["savedmodel"]);
}
Moved self.isInv to the non-threaded one
Should work 100%
LMGTFY!

Its not a glitch... Its the future!

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Become invisible .. but how ?

Post by <LT>YosemiteSam[NL] » March 19th, 2011, 4:17 pm

Thx m8, works like a charm now.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests