Page 2 of 5
Re: Invisible script bug
Posted: April 15th, 2011, 9:54 pm
by Drofder2004
Code: Select all
if(!isdefined(self.pers["savedmodel"]))
maps\mp\gametypes\_teams::model();
else
maps\mp\_utility::loadModel(self.pers["savedmodel"]);
Code: Select all
if(!isdefined(self.pers["savedmodel"]))
self maps\mp\gametypes\_teams::model();
else
self maps\mp\_utility::loadModel(self.pers["savedmodel"]);
Re: Invisible script bug
Posted: April 16th, 2011, 7:02 am
by megazor
i think you would rather add a few strings to the 'damage' or 'killed' callbacks.
using pseudocode:
Code: Select all
if player is invisible -> kill him
i also faced such an invulnerable bug, with player's health bar shown empty. when debugging, i noticed that the 'sessionteam' of such players was NOT "playing", it was "spectator". and the game doesn't kill players whose session team is spectator. that is because of the corresponding check in the 'killed' callback
im talking cod1 so the content of callbacks may vary.
Re: Invisible script bug
Posted: April 16th, 2011, 8:22 am
by megazor
is the same as
except hard-coded functions.
example:
Code: Select all
func_1()
{
players = getEntArray("player", "classname");
if (players.size)
players[0] thread func_2();
}
func_2()
{
thread func_3();
level thread func_4();
}
func_3()
{
while(1)
{
wait 1;
}
}
func_4()
{
while(1)
{
wait 1;
}
}
in func_1, self = level
in func_2, self = player
in func_3, self = player
in func_4, self = level
this is very important:
if, inside a function, self stands for the level, the function dies on map restart/change;
but if self stands for a player, the function dies after the player has disconnected.
so, func_3 will die on player's disconnect or, obviously, on map restart/change.
but func_4 will die only on map restart or change.
keep it in your mind.
if you don't want a function to stop upon player's disconnect, make sure its self is the level, not a player!
Re: Invisible script bug
Posted: April 16th, 2011, 8:55 am
by IzNoGoD
thread does always run on level, wheter it is called from a level or a self thread.
Then, it doesnt simply die, because you need some "self endon("disconnect");" thing in there for it to die.
Re: Invisible script bug
Posted: April 16th, 2011, 9:25 am
by megazor
you are wrong. if there is nothing before "thread function()", then it will run on 'self', which may be either player or level.
i have just tested it on cod1 and the test confirmed what i wrote.
Re: Invisible script bug
Posted: April 16th, 2011, 12:10 pm
by <LT>YosemiteSam[NL]
megazor wrote:i think you would rather add a few strings to the 'damage' or 'killed' callbacks.
using pseudocode:
Code: Select all
if player is invisible -> kill him
i also faced such an invulnerable bug, with player's health bar shown empty. when debugging, i noticed that the 'sessionteam' of such players was NOT "playing", it was "spectator". and the game doesn't kill players whose session team is spectator. that is because of the corresponding check in the 'killed' callback
im talking cod1 so the content of callbacks may vary.
Well, the script is working like it should (the one I posted earlier) but my main concern is that it (most likely it is this script) crashes the server with the error message "too many variables". I'll test it on monday when I play the map with friends again.
Re: Invisible script bug
Posted: April 16th, 2011, 12:29 pm
by Drofder2004
megazor wrote:you are wrong. if there is nothing before "thread function()", then it will run on 'self', which may be either player or level.
i have just tested it on cod1 and the test confirmed what i wrote.
This is correct.
When no entity is given, the parent entity (I think this is the correct term) is taken.
If you call a thread by doing "self thread()", then you no longer need to reference "self" unless you are caling a stock function.
Although, again this is an aesthetics and etiquette position, where I will always place "self" before a function if self is not 'level'.
Re: Invisible script bug
Posted: April 16th, 2011, 12:52 pm
by megazor
Code: Select all
invisible()
{
       thread waitforconnect();
       thread monitortrig();
}
waitforconnect()
{
       for(;;)
       {
              level waittill("connecting", player);
              player thread waitforspawn();
       }
}
waitforspawn()
{
       //self endon("disconnect");
       self.isInv=false;
       for(;;)
       {
              self waittill("spawned");
              self.isInv = false;
       }
}
monitortrig()
{
       trigger=getent("invisible","targetname");
       fx = loadfx ("fx/dust/morpheus_spawnarmorinvis.efx");
       invissound = getent("invisible_sound","targetname");
       for(;;)
       {
         trigger waittill("trigger",user);
         if(!user.isInv)
         {
            user.isInv = true;
            user iprintln("^2 You have invisibility");
                 user thread makeinvisible(45);
               user playsound("invisibility");
            wait 150;
            invissound playsound("spawnsound");
            playfx (fx, (-100,-996,224));
  Â
        }
}
makeinvisible(time)
{
       //self endon("disconnect");
       self endon("killed_player");
       self endon("spawned");
       self endon("suicide");
  Â
       self detachall();
       self setmodel("");
       for (i = 0; i < time; i++)
       {
                wait 1;
             if (self.health <= 0) // caught fatal damage or joined spectators
            {
                        if (self.sessionstate == "playing")
                        {
                         self.health = 100;
                           self suicide();
                        }
             return;
        }
    }
        if (self.sessionstate != "playing")
                return;
        self.isInv = false;
       if(!isDefined(self.pers["savedmodel"]))
              mapsmpgametypes_teams::model();
       else
              mapsmp_utility::loadModel(self.pers["savedmodel"]);
       self iprintln("^2 Invisibility has worn off"); Â
}Â
Re: Invisible script bug
Posted: April 16th, 2011, 12:56 pm
by Rezil
Code: Select all
invisible()
{
thread waitforconnect();
thread monitortrig();
}
waitforconnect()
{
for(;;)
{
level waittill("connecting",player);
player thread waitforspawn();
}
}
waitforspawn()
{
self endon("disconnect");
for(;;)
{
self waittill("spawned");
self.isInv=false;
}
}
monitortrig()
{
trigger=getent("invisible","targetname");
fx = loadfx ("fx/dust/morpheus_spawnarmorinvis.efx");
invissound = getent("invisible_sound","targetname");
for(;;)
{
trigger waittill("trigger",user);
if(!user.isInv)
{
user.isInv=true;
user iprintln("^2 You have invisibility");
user thread makeinvisible(45);
user playsound("invisibility");
wait 150;
invissound playsound("spawnsound");
playfx (fx, (-100,-996,224));
}
}
}
makeinvisible(time)
{
//time = 45; //<-lolwat
self endon("disconnect");
self endon("killed_player");
self endon("spawned");
self endon("suicide");
self detachall();
self setmodel("");
self invHealth(time); //blocking for <time> seconds
if(self.isInv) self.isInv=false;
if(!isdefined(self.pers["savedmodel"])) self maps\mp\gametypes\_teams::model();
else self maps\mp\_utility::loadModel(self.pers["savedmodel"]);
self iprintln("^2Invisibility has worn off");
}
invHealth(time)
{
for(i=0;i<time;i++)
{
if(self.health <= 0)
{
self.isInv=false;
self suicide();
self.health = 100;
break;
}
wait 1;
}
}
Try.
On a semi-related note: Code formatting sucks on these boards. It's high time the forums got an upgrade(some color schemes or something--I'm looking at you, Peds

).
EDIT: No idea what's posted above me, so try his method first, then mine.
Re: Invisible script bug
Posted: April 16th, 2011, 1:11 pm
by megazor
the problem of max variables is, most likely, your script attempts to set a model on a dead player

so really try my script firstly.
Re: Invisible script bug
Posted: April 16th, 2011, 1:19 pm
by <LT>YosemiteSam[NL]
megazor wrote:the problem of max variables is, most likely, your script attempts to set a model on a dead player

so really try my script firstly.
aha, ok. I tried yor script m8. But you do not become visible and don't die when getting more than 100 damage.
Gonna try Rezil's script now.
Tried Rezil's cript and when you get over 100 damage you become visible, the health get's set to 0 (=self suicice) and then to 100.
You don't die.
I tried putting the self suicide line after where the health is put to 100 but that doesn't kill the player. The health then gets set to zero.
Re: Invisible script bug
Posted: April 16th, 2011, 2:13 pm
by Rezil
Code: Select all
if(self.health <= 0)
{
self.isInv=false;
self suicide();
//self.health = 100; <- remove this part and try again
break;
}
@KS: yeah, but all of the other colors are different than the original php code scheme so using php, while it does color the code, makes it even less readable:
Code: Select all
if(self.health <= 0)
{
self.isInv=false;
self suicide();
//self.health = 100; <- remove this part and try again
break;
}
Re: Invisible script bug
Posted: April 16th, 2011, 2:50 pm
by megazor
try this one
Code: Select all
invisible()
{
thread waitforconnect();
thread monitortrig();
}
waitforconnect()
{
for(;;)
{
level waittill("connecting", player);
player thread waitforspawn();
}
}
waitforspawn()
{
//self endon("disconnect");
self.isInv=false;
for(;;)
{
self waittill("spawned");
self.isInv = false;
}
}
monitortrig()
{
trigger=getent("invisible","targetname");
fx = loadfx ("fx/dust/morpheus_spawnarmorinvis.efx");
invissound = getent("invisible_sound","targetname");
for(;;)
{
trigger waittill("trigger",user);
if(!user.isInv)
{
user.isInv = true;
user iprintln("^2 You have invisibility");
user thread makeinvisible(45);
user playsound("invisibility");
wait 150;
invissound playsound("spawnsound");
playfx (fx, (-100,-996,224));
}
}
makeinvisible(time)
{
//self endon("disconnect");
self endon("killed_player");
self endon("spawned");
self endon("suicide");
self detachall();
self setmodel("");
for (i = 0; i < time; i++)
{
wait 1;
if (self.health <= 0) // caught fatal damage or joined spectators
{
self.health = 100;
self suicide();
return;
}
}
if (self.sessionstate != "playing")
return;
self.isInv = false;
if(!isDefined(self.pers["savedmodel"]))
maps\mp\gametypes\_teams::model();
else
maps\mp\_utility::loadModel(self.pers["savedmodel"]);
self iprintln("^2 Invisibility has worn off");
}
Re: Invisible script bug
Posted: April 16th, 2011, 7:18 pm
by <LT>YosemiteSam[NL]
Tried both but they don't work.
The megazor script keeps you invisible and your health goes to zero. If you get hit again your health goes into the negatives.
Re: Invisible script bug
Posted: April 16th, 2011, 10:46 pm
by Drofder2004
Ok, lets try again

Change only the "makeInvisble" function from Megaz script.
There are two "wait" calls, commented out, these may be required or may not. Try them without first.
Code: Select all
makeinvisible(time)
{
//self endon("disconnect");
self endon("killed_player");
self endon("spawned");
self endon("suicide");
self detachall();
self setmodel("");
for (i = 0; i < time; i++)
{
wait 1;
if (self.health <= 0)
{
self makevisible();
// wait 0.05; // Uncomment line if code does not work and retry
self.health = 100;
// wait 0.05; // Again, if not working, remove comment and retry
self suicide();
return;
}
}
self makeVisible();
self iprintln("^2 Invisibility has worn off");
}
makeVisible()
{
if(!isDefined(self.pers["savedmodel"]))
maps\mp\gametypes\_teams::model();
else
maps\mp\_utility::loadModel(self.pers["savedmodel"]);
self.isInv = false;
}