Author Topic: OnClientLeave  (Read 500 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
OnClientLeave
« Reply #15 on: March 03, 2011, 08:58:36 pm »


               Well there is automatical method how to set script into every area in your module, see my Door System at vault, there is a special letoscript distribution (Moneo by dragonsong) and letoscript script which adds scripts into all doors in your module, it should be easy to adjust it to set area's scripts, and if you would have problem with it I can help you. Or you can put it only in the areas visited by this specific player. It doesn't have to be in all of them in order to work.
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
OnClientLeave
« Reply #16 on: March 10, 2011, 11:51:18 am »


               Note
ShaDoOw asked me to have a look in IDA for a way to hook on the ClientLeave event, in order to be able to get the player/character object in a nwnscript before they leave the server.


I had success and found a memory location for 'RemovePlayerFromWorld'.
I passed the memory addresses over to Maxrock, and hes added functionality into nwnx_funcs allowing you to use a new event hook.

Allows you to get the Character, the area, and even items in his inventory as he is leaving the server.
And use them in nwnscript.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
OnClientLeave
« Reply #17 on: March 10, 2011, 12:22:25 pm »


               Question:  Have you tested the function for when the client crashes,
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
OnClientLeave
« Reply #18 on: March 10, 2011, 02:56:19 pm »


               Short answer = No - I havent had a chance to test it at all yet.

But, in terms of when a Client Crashes, it would be indistinguishable from a Normal Client Disconnect from the point of view of the server. They both call the same function on the server.

The RemovePlayerFromWorld function would still be run, as it is kicked off by the ChangePlayerCount  function.

eg - If the ChangePlayerCount function runs, then its going to run the RemovePlayerFromWorld function.  (this is the function that makes the player character vanish from the world)
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
OnClientLeave
« Reply #19 on: March 10, 2011, 05:07:15 pm »


               True, Unless the server is sending a request for the Player Public CD key  and the client is no longer there. Also inventory would be a problem If the Server is running a local vault. The Client is just no longer there is save the Data to.
               
               

               


                     Modifié par Lightfoot8, 10 mars 2011 - 05:15 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
OnClientLeave
« Reply #20 on: March 10, 2011, 05:12:19 pm »


               Hmm how can server run these internal functions if it crashed? I don't think that, in this case anything is run...
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
OnClientLeave
« Reply #21 on: March 11, 2011, 09:52:32 am »


               If the server crashes - yes, nothing will run.
If the Client crashes - the server still retains an object of the player/character. It is the RemovePlayerFromWorld function that would remove them from existance anyway, and we are running the onClientLeave hook before this function.

Techically, and in theory, th function would be run, before the character is destroyed, even if there isnt a player around to control him.
But we are talking about a time frame of miliseconds etc,
Long enough for a script to run, before the hook ends, and carries on running the onClientLeave code.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
OnClientLeave
« Reply #22 on: March 11, 2011, 07:31:32 pm »


               ah, my bad i missed the word "client", ok so I proofed it with the MaxRock nwnx_funcs' hook and it does fire reliably and with all informations available also in case of client crash
               
               

               


                     Modifié par ShaDoOoW, 11 mars 2011 - 07:32 .