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.
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
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;
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%