Jump to content
  • 0

How to check if other player is alive?


BigBurrito

Question


  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

Hi, I'm doing a script and in one of the "if" statements I need to check if certain player is alive. Some information you need to know first.
I've attached all party members to the script prior the IF statement using "addrid(2,0,getcharid(1))"; and I only need to check if the party leader is alive.
I Will leave an example.

 

-	script	partyleader	-1,{

getpartymember getcharid(1), 1;
getpartymember getcharid(1), 2;

addrid(2,0,getcharid(1))

for ( .@i = 0; .@i < $@partymembercount; .@i++)
   {                                     
	  if( PartyLeaderisdead)
       	 {
			dispbottom "Leader is dead";
			set .@i,$@partymembercount;
       		continue;
		 }
    }                                    

end;
}                                


I need the Loop to stop once the Party leader is dead.

I have tried 

if (getpartyleader(getcharid(1),2) && HP<2)

But it only stopped for the Leader, and not for everyone.
I need the loop to stop for everyone attached on the script.

I would try using Global Integers ($@) however, this would be true for the whole server.
And since the script is intended to be used by others aswell, it might interfere. So this option is not good for me.

Thank you in advance.
 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

.@party_leader_aid = getpartyleader(getcharid(1), 1);
if (attachrid(.@party_leader_aid)) {
	if (Hp < 1) {
		getpartymember getcharid(1), 2;
		.@count = $@partymembercount;
		copyarray(.@pt_aid, $@partymemberaid, .@count);
		for (.@i = 0; .@i < .@count; .@i++) 
			if (.@pt_aid[.@i] != .@party_leader_aid)
				if (attachrid(.@pt_aid[.@i])) {
					dispbottom "Your party leader is dead.";
					detachrid;
				}
	}
	detachrid;
}

you can try like this...

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

just add a a OnPcDieEvent: for the party leader
something like this

if(strcharinfo(3) == "mapname" && getcharid(0) == getpartyleader(getcharid(1),2))
 announce "Party Leader is Dead";

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

@crazyarashi is not for announcement tho. Is for the loop to stop for all attached players.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

@Emistry Did not work. When I added this part on the loop, it somehow deatached all the party members from the script except the leader. So the loop did not start for the others other than the leader. 


I solved this issue by using OnPCLogoutEvent: and OnPCDieEvent: setting some $@value[getcharid(1)] and using an if statement on the beginning of the Loop. However, now when I tested, the loop stops, but it also check the loop for the Party leader, and since the party leader is dead and it detaches the Script apparently when the player dies, an error appears on one of the retrieving values of the loop. And overtime it bugs the script. :S.. 
 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

Solved. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...