Aller au contenu

Photo

How to destroy an object type creature OnClientLeave?


  • Veuillez vous connecter pour répondre
31 réponses à ce sujet

#1
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Description: There is just one player with the variable "fighting". I would like to kill oBoss if the player with variable "fighting" leaves the game. 



#2
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I tried to use oPC = GetExitingObject() on module event leaving, but oPC isn't an object valid.

 

    object oBoss; //this is my object I would like to kill
    object oPC = GetExitingObject();
    if(GetLocalInt(oPC, "fighting") == TRUE) DestroyObject(oBoss);


#3
WhiZard

WhiZard
  • Members
  • 1 204 messages

You would need to identify what oBoss is (such as by GetObjectByTag()).  Also, I'm not sure if locals stay on PCs when they get to the OnClientLeave event.  You might want to test for that.  GetExitingObject() does return the PC, but there is little data left to the PC at this point. See the Lexicon.


  • WhiteTiger aime ceci

#4
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Is possible to check onclientleave if there is no players with variable "fighting" and then destroyobject(oBoss)?

 

//I just know to check if someone has the variable like this

    object oAny = GetFirstPC();

    while (GetIsObjectValid(oAny))
    {
    if(GetLocalInt(oAny, "fighting") == TRUE) doAction();
    oAny = GetNextPC();
    }



#5
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

You would need to identify what oBoss is (such as by GetObjectByTag()). 

 

my oBoss is just occult (object oBoss) from the script above

 

I need to use something like this to destroy my boss 

 

    object oPointElazul = GetObjectByTag("Point_Object_Elazul");
    object oArea = GetArea(oPointElazul);
    object oBoss = GetFirstObjectInArea(oArea);

 

while(GetIsObjectValid(oBoss))
    {
        if((GetTag(oBoss) == "Batalha_Moric") || (GetTag(oBoss) == "Batalha_Toro") || (GetTag(oBoss) == "Batalha_Gina") || (GetTag(oBoss) == "Batalha_Bauguro") || (GetTag(oBoss) == "Batalha_Kenshin") || (GetTag(oBoss) == "Batalha_Gramish") || (GetTag(oBoss) == "Batalha_Iris") || (GetTag(oBoss) == "Batalha_Boxer") || (GetTag(oBoss) == "Batalha_Tentaclus"))
        {
        DestroyObject(oBoss);
        }
    oBoss = GetNextObjectInArea(oArea);
    }


#6
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Also, I'm not sure if locals stay on PCs when they get to the OnClientLeave event.  You might want to test for that.

Yes, should be this. I cant find the locals of the player that logged out



#7
WhiZard

WhiZard
  • Members
  • 1 204 messages

Would you be able to do this through the Area's OnExit event instead?  That is, when the last player exits the area, you would then destroy all the bosses.  Or do these bosses move from area to area?


  • WhiteTiger aime ceci

#8
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Would you be able to do this through the Area's OnExit event instead?  That is, when the last player exits the area, you would then destroy all the bosses.  Or do these bosses move from area to area?

 

may be an solution, i need test



#9
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

The bosses can not leave their areas. I am using a trigger with OnExit event to destroy bosses, but this not occurs when player leave the game. I don't know if using the exit event area will occurs.



#10
WhiteTiger

WhiteTiger
  • Members
  • 479 messages
//EDITED 1
The exiting area event works when player leave, I just need to test if this identifies the locals (testing...)
 
//EDITED 2
OnExiting area does not identifies locals for leaving players =/ 

Modifié par WhiteTiger, 02 août 2014 - 12:05 .


#11
WhiZard

WhiZard
  • Members
  • 1 204 messages

//EDITED

The exiting area event works when player leave, I just need to test if this identifies the locals (testing...)

 

Should work.

 

The order of entry is Client Enter -> Module Enter -> Area Enter

 

The order of exit is Area Exit -> Module Exit -> Client Leave

 

That is, when a player logs out, he first exits the area normally before anything regarding exiting the module takes place.


  • WhiteTiger aime ceci

#12
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Does not work =/

 

can't check LocalInt "fighting" 



#13
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Does our last resource is to use Area OnHeartbeat?

 

//edited

bad idea 



#14
meaglyn

meaglyn
  • Members
  • 807 messages

Local variables are still present on client exit. It's just that the PC is no longer a PC so all the GetIsPC() related things fail.   One of the workarounds for this is to save the CD key and player name and such on the PC as variables so they are available during client exit.  The static lexicon has a typo there when it says "you can get any information off..." It should say "can't".


  • WhiteTiger aime ceci

#15
WhiZard

WhiZard
  • Members
  • 1 204 messages

Local variables are still present on client exit.

 

Thanks for the verification.  I have just tested the area exit from my dedicated server which also works.  I just didn't know when the PC and items were stripped of their variables in a server setting (they are not stripped in SP module).

 

EDIT: Meaglyn,  I am getting a negative for Client Leave, and a positive for Area Exit.  It would appear the locals are stripped in between.


  • WhiteTiger aime ceci

#16
kalbaern

kalbaern
  • Members
  • 824 messages

Why not use a custom heartbeat event for the bosses. Have it check the area/map for any PCs, you can further check to make sure any PCs found carry the variable you desire. No PCs or no PCs with the variable then causes the creature to destroy itself.


  • WhiteTiger aime ceci

#17
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Why not use a custom heartbeat event for the bosses. Have it check the area/map for any PCs, you can further check to make sure any PCs found carry the variable you desire. No PCs or no PCs with the variable then causes the creature to destroy itself.

 

//EDITED2

how to check using hb?


Modifié par WhiteTiger, 02 août 2014 - 05:16 .


#18
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

this works on client leave?

 

object oPC = GetFirstPC();

object oBoss; //my boss

 

while(GetIsObjectValid(oPC))

{

if(GetLocalInt(oPC, "fighting")) return;

oPC = GetNextPC();

}

 

DestroyObject(oBoss);



#19
meaglyn

meaglyn
  • Members
  • 807 messages

Thanks for the verification.  I have just tested the area exit from my dedicated server which also works.  I just didn't know when the PC and items were stripped of their variables in a server setting (they are not stripped in SP module).

 

EDIT: Meaglyn,  I am getting a negative for Client Leave, and a positive for Area Exit.  It would appear the locals are stripped in between.

 

Interesting.

I have this line at the end of my client exit routine:

WriteTimestampedLogEntry("PLAYER EXIT : " + GetLocalString(oPC, "player_name")
                + "(key " + GetLocalString(oPC, "player_cdkey") + " IP " + GetLocalString(oPC, "player_ip")
                        + ") as " + GetName(oPC) + " ID number " + sId);

And I see the expected output in the log file. I use a number of other variables from there and they are fine as well.

 


  • WhiteTiger aime ceci

#20
meaglyn

meaglyn
  • Members
  • 807 messages

this works on client leave?

 

object oPC = GetFirstPC();

object oBoss; //my boss

 

while(GetIsObjectValid(oPC))

{

if(GetLocalInt(oPC, "fighting")) return;

oPC = GetNextPC();

}

 

DestroyObject(oBoss);

 

Assuming oBoss is a valid object that should work.

 

Might be easier to simply do 

if (GetLocalInt(GetExitingObject(), "fighting"))
         DestroyObject(oBoss);

  • WhiteTiger aime ceci

#21
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

 

Assuming oBoss is a valid object that should work.

 

Might be easier to simply do 

if (GetLocalInt(GetExitingObject(), "fighting"))
         DestroyObject(oBoss);

 

I tried to use the 

 

if (GetLocalInt(GetExitingObject(), "fighting"))
         DestroyObject(oBoss);

 

but no returns!



#22
WhiZard

WhiZard
  • Members
  • 1 204 messages

Interesting.

I have this line at the end of my client exit routine:

WriteTimestampedLogEntry("PLAYER EXIT : " + GetLocalString(oPC, "player_name")
                + "(key " + GetLocalString(oPC, "player_cdkey") + " IP " + GetLocalString(oPC, "player_ip")
                        + ") as " + GetName(oPC) + " ID number " + sId);

And I see the expected output in the log file. I use a number of other variables from there and they are fine as well.

 

I've found the discrepancy.  Exiting by the Death GUI Panel doesn't retain variables for either the Area or the Client exit, while exiting normally would preserve the locals for both events.


  • meaglyn et WhiteTiger aiment ceci

#23
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

does it works using to OnClientLeave? 

object oPC = GetFirstPC();
object oBoss; //my boss
 
while(GetIsObjectValid(oPC))
{
if(GetLocalInt(oPC, "fighting")) return;
oPC = GetNextPC();
}
DestroyObject(oBoss);

Assuming oBoss is a valid object that should work.

 

yeah, it works well gratefull



#24
meaglyn

meaglyn
  • Members
  • 807 messages

I've found the discrepancy.  Exiting by the Death GUI Panel doesn't retain variables for either the Area or the Client exit, while exiting normally would preserve the locals for both events.

 

Cool! That's good to know.



#25
Shadooow

Shadooow
  • Members
  • 4 468 messages

There is an easy workaround for this. This workaround even allows to set local ints from OnClientLeave.

 

Basically you are setting the variables not on a PC but on the module this way

 

GetLocalInt(OBJECT_SELF,ObjectToString(oPC)+"_ACCOUNT");

 

etc. you get the idea


  • WhiteTiger aime ceci