Author Topic: How to destroy an object type creature OnClientLeave?  (Read 670 times)

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #15 on: August 02, 2014, 01:47:52 am »


               

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.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #16 on: August 02, 2014, 01:56:42 am »


               


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 .
                     
                  


            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #17 on: August 02, 2014, 02:22:01 am »


               

this works on client leave?


 


object oPC = GetFirstPC();


object oBoss; //my boss


 


while(GetIsObjectValid(oPC))


{


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


oPC = GetNextPC();


}


 


DestroyObject(oBoss);



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #18 on: August 02, 2014, 02:23:25 am »


               


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.



 


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #19 on: August 02, 2014, 02:27:02 am »


               


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);

               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #20 on: August 02, 2014, 02:32:06 am »


               


 


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!


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #21 on: August 02, 2014, 02:32:22 am »


               


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.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #22 on: August 02, 2014, 06:04:11 am »


               

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



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #23 on: August 02, 2014, 01:06:33 pm »


               


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.


               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #24 on: August 02, 2014, 01:16:05 pm »


               

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



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #25 on: August 02, 2014, 01:37:33 pm »


               


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.




how are you testing that? I was doing some research on this in past and since I didnt remembered this issue I double checked and cannot reproduce your results. I was able to retrieve local var from oPC object in OnExit even when I was dead and pressed exit game from dead GUI.


 


Edit: I rewritten pages in lexicon per my research.



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #26 on: August 02, 2014, 04:45:28 pm »


               

Here are my scripts


 


 


On Client Enter


void main()

{

object oPC = GetEnteringObject();

int nLocal = GetCampaignInt("test", "test");

if(nLocal && GetIsPC(oPC))

  {

  DestroyCampaignDatabase("test");

  }

SetLocalInt(oPC, "test", 1);

}


 


On Client Leave


void main()

{

object oPC = GetExitingObject();

int nLocal = GetLocalInt(oPC, "test");

if(nLocal)

  SetCampaignInt("test", "test", 1);

DeleteLocalInt(oPC, "test");

}


 


Basically, I am checking my database folder of my dedicated server to see if the "test" database exists.  I can check this both in-game and out of game.  For checking Area Enter/Exit, I just move the scripts to those locations removing the check from on Client Enter/Leave.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #27 on: August 02, 2014, 04:48:09 pm »


               

Well i used writelog and checked nwserverlog1.txt and I found the value of the string variable there in all cases. Using windows server without NWNX. Can a third person try it?



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #28 on: August 02, 2014, 05:21:12 pm »


               

Okay now I am seeing it create the database for the DeathPanel exit, so there must be some other common factor that is preventing locals to be shown, because I am sometimes seeing an inconsistency.



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
How to destroy an object type creature OnClientLeave?
« Reply #29 on: August 02, 2014, 06:13:08 pm »


               

Found my problem.  I had four modules labeled for whether or not the Death GUI Panel was called by PopUpGUIPanel() or PopUpDeathGUIPanel() and whether the scripts were client or area.  One of the labels was incorrect, so I had two area ones with PopUpGUIPanel(), while the PopUpDeathGUIPanel() had one for client and one for area.  This mislabeling caused some of the area test data to be confused with client test data.  Since the area exit did not fire in the case of exiting by death, I was incorrectly finding issues with the client.  So I should now agree with Shadooow and Meaglyn.