Neverwinter Nights > Script Request

Script help needed

(1/4) > >>

Ser Red Ronnet Connington:
int nInt;
object oTarget;

void main()
{

object oPC = GetExitingObject();

if(!GetIsPC(oPC)) return;

if(GetPCPlayerName(oPC) == "Ser Red Ronnet Connington")
  {
   AssignCommand(GetObjectByTag("SerRedRonnetConnington"), ActionSpeakString("The master of this realm has left!!!", TALKVOLUME_SHOUT));

   oTarget = GetObjectByTag("SerRedRonnetConnington");

   nInt = GetObjectType(oTarget);

   if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), oTarget);
   else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), GetLocation(oTarget));

   DestroyObject(oTarget, 3.0);

}

if(GetPCPlayerName(oPC) == "DemonRot")
  {
   AssignCommand(GetObjectByTag("masteravatar"), ActionSpeakString("Master Avatar has left!!!", TALKVOLUME_SHOUT));

   oTarget = GetObjectByTag("masteravatar");


   nInt = GetObjectType(oTarget);

   if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), oTarget);
   else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), GetLocation(oTarget));

   DestroyObject(oTarget, 3.0);

}

if(GetPCPlayerName(oPC) == "God of Ruin")
  {
   AssignCommand(GetObjectByTag("masterbane"), ActionSpeakString("Master Bane has left!!!", TALKVOLUME_SHOUT));

   oTarget = GetObjectByTag("masterbane");


   nInt = GetObjectType(oTarget);

   if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), oTarget);
   else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), GetLocation(oTarget));

   DestroyObject(oTarget, 3.0);

}

}

This script is intended to make a NPC announce a message, when a certain account has logged out of the module. The NPC is then supposed to be destroyed. The script works on my onexit area event, but not on the onclienet leave module event, which is where I want to put it. Can anyone help with this problem?

420:

--- Quote ---The script works on my onexit area event, but not on the onclienet leave module event, which is where I want to put it. Can anyone help with this problem?
[snapback]36231[/snapback]
--- End quote ---
You can't use functions that return player information (like GetPCPlayerName) in the OnClientLeave event because the player is no longer there.

However, the player's avatar object still exists, so you can get any local variables set on it.

So, add these lines into the OnClientEnter event trigger:

--- Code: ---object oPC = GetEnteringObject();

SetLocalString(oPC, "PCName", GetPCPlayerName());

--- End code ---

Then instead of using GetPCPlayerName in OnClientLeave use GetLocalString. Use this method for GetPCPublicCDKey and GetPCIPAddress too.

-420

Ser Red Ronnet Connington:

--- Quote ---You can't use functions that return player information (like GetPCPlayerName) in the OnClientLeave event because the player is no longer there.

However, the player's avatar object still exists, so you can get any local variables set on it.

So, add these lines into the OnClientEnter event trigger:

--- Code: ---object oPC = GetEnteringObject();

SetLocalString(oPC, "PCName", GetPCPlayerName());

--- End code ---

Then instead of using GetPCPlayerName in OnClientLeave use GetLocalString. Use this method for GetPCPublicCDKey and GetPCIPAddress too.

-420
[snapback]36233[/snapback]
--- End quote ---

Thanks for the help again 420, but would it not be:

SetLocalString(oPC, "PCName", GetPCPlayerName(oPC));
instead of:
SetLocalString(oPC, "PCName", GetPCPlayerName());
?

Ser Red Ronnet Connington:
int nInt;
object oTarget;

void main()
{

object oPC = GetExitingObject();

if(!GetIsPC(oPC)) return;

if(GetLocalString(oPC,"Ser Red Ronnet Connington"))
  {
   AssignCommand(GetObjectByTag("SerRedRonnetConnington"), ActionSpeakString("The master of this realm has left!!!", TALKVOLUME_SHOUT));

   oTarget = GetObjectByTag("SerRedRonnetConnington");


   nInt = GetObjectType(oTarget);

   if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), oTarget);
   else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), GetLocation(oTarget));

   DestroyObject(oTarget, 3.0);

}

if(GetLocalString(oPC,"DemonRot"))
  {
   AssignCommand(GetObjectByTag("masteravatar"), ActionSpeakString("Master Avatar has left!!!", TALKVOLUME_SHOUT));

   oTarget = GetObjectByTag("masteravatar");


   nInt = GetObjectType(oTarget);

   if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), oTarget);
   else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), GetLocation(oTarget));

   DestroyObject(oTarget, 3.0);

}

if(GetLocalString(oPC,"God of Ruin"))
  {
   AssignCommand(GetObjectByTag("masterbane"), ActionSpeakString("Master Bane has left!!!", TALKVOLUME_SHOUT));

   oTarget = GetObjectByTag("masterbane");

   nInt = GetObjectType(oTarget);

   if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), oTarget);
   else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SWINGING_BLADE), GetLocation(oTarget));

   DestroyObject(oTarget, 3.0);

}

}


This is what i did to the onclientleave. It wont compile, an integer error.

420:

--- Quote ---Thanks for the help again 420, but would it not be:

SetLocalString(oPC, "PCName", GetPCPlayerName(oPC));
instead of:
SetLocalString(oPC, "PCName", GetPCPlayerName());
?
[snapback]36235[/snapback]
--- End quote ---
Yeah, I didn't compile the code.


--- Quote ---int nInt;
object oTarget;

void main()
{

[snapback]36237[/snapback]
--- End quote ---
Those declarations (int and object) should be below the "void main()" and {

-420

Navigation

[0] Message Index

[#] Next page

Go to full version