Re: Become invisible .. but how ?
Posted: 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;
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.

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.