Aller au contenu

Photo

Destroying henchmans on client leave


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

#1
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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



#2
Shadooow

Shadooow
  • Members
  • 4 471 messages

do not use pc name for tag, instead use ObjectToString


  • WhiteTiger aime ceci

#3
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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



#4
Pstemarie

Pstemarie
  • Members
  • 2 745 messages

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


  • WhiteTiger aime ceci

#5
Shadooow

Shadooow
  • Members
  • 4 471 messages

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)


  • WhiteTiger aime ceci

#6
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Shadooow you was right.

The public CD key didn't work.
The ObjectToString worked successfully.

Thank you all anyway for the help