Author Topic: Destroying henchmans on client leave  (Read 332 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Destroying henchmans on client leave
« on: January 16, 2015, 02:58:57 pm »


               

How to destroy PCs henchman on client leave?


 


I tried add a tag when creating the henchmans with the PC name:


 


object oPC = GetPCSpeaker();


CreateObject(..., "hen_"+GetName(oPC));


 


and on client leave this code:


 


object oPC = GetExitingObject();


object oHenchman = GetObjectByTag("hen_"+GetName(oPC));


if(oHenchman != OBJECT_INVALID) DestroyObject(oHenchman);


 


 


This didn't work because there is players with TWO names like (White Tiger) and the space beetwen White and Tiger does not match to search for tags


 


the tag is: "hen_WhiteTiger"


 


and I search for "hen_White Tiger" does not work



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Destroying henchmans on client leave
« Reply #1 on: January 16, 2015, 04:52:23 pm »


               

do not use pc name for tag, instead use ObjectToString



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Destroying henchmans on client leave
« Reply #2 on: January 16, 2015, 05:24:42 pm »


               

Interesting, Shadooow


 


I was happy trying to make it work with ObjectToString, but oLeavingPC is not a valid object =/


 


On Client Leave just keep PC name, not playername or object



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Destroying henchmans on client leave
« Reply #3 on: January 16, 2015, 06:12:48 pm »


               

Use the player's public cd key maybe to tag the henchman? Also you should use "if (GetIsObjectValid(oHenchman))" instead of checking for "if (oHenchman != OBJECT_INVALID)" in the OnClientLeave code. The expression you use isn't as fool proof as the check I prefer.


 


object oPC = GetPCSpeaker();


CreateObject(..., "hen_"+GetPCPublicCDKey(oPC));


 


and on client leave this code:


 


object oPC = GetExitingObject();


object oHenchman = GetObjectByTag("hen_"+GetPCPublicCDKey(oPC));


if(GetIsObjectValid(oHenchman)) DestroyObject(oHenchman);



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Destroying henchmans on client leave
« Reply #4 on: January 16, 2015, 07:50:33 pm »


               

ah i forget... neither getpcpubliccdkey will work


 


you just need to store henchman as a local object on PC (or his tag as local string on pc)



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Destroying henchmans on client leave
« Reply #5 on: January 18, 2015, 05:13:22 pm »


               

Shadooow you was right.


The public CD key didn't work.

The ObjectToString worked successfully.


Thank you all anyway for the help