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.
How to destroy an object type creature OnClientLeave?
#1
Posté 01 août 2014 - 09:46
#2
Posté 01 août 2014 - 09:52
I tried to use oPC = GetExitingObject() on module event leaving, but oPC isn't an object valid.
#3
Posté 01 août 2014 - 10:10
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
Posté 01 août 2014 - 10:11
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
Posté 01 août 2014 - 10:14
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
#6
Posté 01 août 2014 - 10:20
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
Posté 01 août 2014 - 10:23
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
Posté 01 août 2014 - 10:27
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
Posté 01 août 2014 - 10:29
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
Posté 01 août 2014 - 10:35
Modifié par WhiteTiger, 02 août 2014 - 12:05 .
#11
Posté 01 août 2014 - 11:38
//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
Posté 01 août 2014 - 11:42
Does not work =/
can't check LocalInt "fighting"
#13
Posté 02 août 2014 - 12:06
Does our last resource is to use Area OnHeartbeat?
//edited
bad idea
#14
Posté 02 août 2014 - 12:15
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
Posté 02 août 2014 - 12:19
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
Posté 02 août 2014 - 12:47
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
Posté 02 août 2014 - 12:56
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
Posté 02 août 2014 - 01:22
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
Posté 02 août 2014 - 01:23
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
Posté 02 août 2014 - 01:27
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
Posté 02 août 2014 - 01:32
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
Posté 02 août 2014 - 01:32
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
Posté 02 août 2014 - 05:04
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
Posté 02 août 2014 - 12:06
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
Posté 02 août 2014 - 12:16
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





Retour en haut






