UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: Ege115 on July 29, 2014, 11:54:10 pm

Title: Check if the player is either dead or downed?
Post by: Ege115 on July 29, 2014, 11:54:10 pm
What is the best way to check if the player is either downed or dead?
This is what I did a little quick, but I don't know if it's the best way.
Code Snippet
Plaintext
total_dead_check()
{
while(1)
{
if(self maps\_laststand::player_is_in_laststand() || self.dead == true || self.downed == true)
{
// Stuff when player is either downed or dead
}
wait .1;
}
}

dead_check()
{
while(1)
{
self.dead = false;
self waittill("death");
self.dead = true;
wait .1;
}
}

downed_check()
{
while(1)
{
self.downed = false;
self waittill("player_downed");
self.downed = true;
wait .1;
}
}
Thanks in advance.

What I know is that the laststand downed function only works in coop.
Title: Re: Check if the player is either dead or downed?
Post by: n123q45 on July 29, 2014, 11:58:48 pm
for downed i would go with:
Code Snippet
Plaintext
player maps\_laststand::player_is_in_laststand()
for dead:
Code Snippet
Plaintext
!isalive(player)
Title: Re: Check if the player is either dead or downed?
Post by: PROxFTW on July 30, 2014, 12:05:13 am
This should do the trick. Is there something you are trying to accomplish? If there is something you would like to do for Solo and Co-Op. This would work for Co-Op and if you had Solo Revive.
Code Snippet
Plaintext
CheckDowned()
{
while( 1 )
{
if( self.sessionstate == "spectator" || IsDefined( self.revivetrigger ) )
{
// Code
}
wait .01;
}
}
Title: Re: Check if the player is either dead or downed?
Post by: Ege115 on August 04, 2014, 09:02:43 am
This should do the trick. Is there something you are trying to accomplish? If there is something you would like to do for Solo and Co-Op. This would work for Co-Op and if you had Solo Revive.
Code Snippet
Plaintext
CheckDowned()
{
while( 1 )
{
if( self.sessionstate == "spectator" || IsDefined( self.revivetrigger ) )
{
// Code
}
wait .01;
}
}
Hey sorry for taking so long, I tried this and the seesionstate didn't work if you would play solo, it would return as true.

But I tried to use the waittill anyway and it seems like it works. Thanks for the help. :)
Code Snippet
Plaintext
total_down_check()
{
while(1)
{
self.down = false;
self waittill_any( "fake_death", "death", "player_downed" );
self.down = true;

if( self.down == true )
{
// code
}
wait .1;
}
}
And I tried the IsAlive function but it didn't work for the player apparently.
Title: Re: Check if the player is either dead or downed?
Post by: DidUknowiPwn on August 04, 2014, 05:00:46 pm
Code Snippet
Plaintext
if( isAlive(entity) || self.playerzombie_soundboard_disable )
<- that var is located in playerzombie_downed_state() _zombiemode and it checks if it's true automatically by the way.
Title: Re: Check if the player is either dead or downed?
Post by: treminaor on August 04, 2014, 06:36:55 pm
Why isn't anyone referencing actual zombie scripts that check for downed players?... nearly every purchase trigger in zombiemode checks to make sure the player is not in last stand before going forward with the purchase.

laststand:
Code Snippet
Plaintext
if(!player maps\_laststand::player_is_in_laststand()

dead:
Code Snippet
Plaintext
if(!isAlive(player))


Edit: n123q45 already gave this answer, I would mark it as Best Answer so that you will stop getting additional suggestions. This code is the standard check for what you are asking.
Title: Re: Check if the player is either dead or downed?
Post by: n123q45 on August 04, 2014, 07:43:16 pm
Why isn't anyone referencing actual zombie scripts that check for downed players?... nearly every purchase trigger in zombiemode checks to make sure the player is not in last stand before going forward with the purchase.

laststand:
Code Snippet
Plaintext
if(!player maps\_laststand::player_is_in_laststand()

dead:
Code Snippet
Plaintext
if(!isAlive(player))


Edit: n123q45 already gave this answer, I would mark it as Best Answer so that you will stop getting additional suggestions. This code is the standard check for what you are asking.
:troll: