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]
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:
object oPC = GetEnteringObject();
SetLocalString(oPC, "PCName", GetPCPlayerName());
Then instead of using GetPCPlayerName in OnClientLeave use GetLocalString. Use this method for GetPCPublicCDKey and GetPCIPAddress too.
-420
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:
object oPC = GetEnteringObject();
SetLocalString(oPC, "PCName", GetPCPlayerName());
Then instead of using GetPCPlayerName in OnClientLeave use GetLocalString. Use this method for GetPCPublicCDKey and GetPCIPAddress too.
-420
[snapback]36233[/snapback]
Thanks for the help again 420, but would it not be:
SetLocalString(oPC, "PCName", GetPCPlayerName(oPC));
instead of:
SetLocalString(oPC, "PCName", GetPCPlayerName());
?
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]
Yeah, I didn't compile the code.
int nInt;
object oTarget;
void main()
{
[snapback]36237[/snapback]
Those declarations (int and object) should be below the "void main()" and {
-420
Yeah, I didn't compile the code.
Those declarations (int and object) should be below the "void main()" and {
-420
[snapback]36238[/snapback]
420, thanks for the help. I have done that, moving the int and object below the void main and {. It still wont compile in that form.
I changed this for example:
if(GetLocalString(oPC,"Ser Red Ronnet Connington"))
{
AssignCommand(GetObjectByTag("SerRedRonnetConnington"), ActionSpeakString("The master of this realm has left!!!", TALKVOLUME_SHOUT));
oTarget = GetObjectByTag("SerRedRonnetConnington");
TO THIS, and even though it now compiles it still does not work.
if(GetLocalString(oPC,"") == "Ser Red Ronnet Connington")
{
AssignCommand(GetObjectByTag("SerRedRonnetConnington"), ActionSpeakString("The master of this realm has left!!!", TALKVOLUME_SHOUT));
oTarget = GetObjectByTag("SerRedRonnetConnington");
"Then" is an old C convention. It is implied in more modern languages.
Sorry I wasn't more clear on how to get the local strings to work.
OnClientEnter
object oPC = GetEnteringObject();
SetLocalString(oPC, "Name", GetPCPlayerName(oPC));
SetLocalString(oPC, "CD", GetPCPublicCDKey(oPC));
SetLocalString(oPC, "IP", GetPCIPAddress(oPC));
OnClientLeave
object oPC = GetExitingObject();
string PCName = GetLocalString(oPC, "Name");
string PCCD = GetLocalString(oPC, "CD");
string PCIP = GetLocalString(oPC, "IP");
Once those lines of code are set up you can do things like:
if(PCName == "Ser Red Ronnet Connington")
{
}
-420
[snapback]36261[/snapback]
Thanks for the help again 420. Unfortunetly its compiling now but not working.
I assume this is what I need to do:
Onclient enter
SetLocalString(oPC, "Ser Red Ronnet Connington", GetPCPlayerName(oPC));
SetLocalString(oPC, "DemonRot", GetPCPlayerName(oPC));
SetLocalString(oPC, "God of Ruin", GetPCPlayerName(oPC));
I dont think I need to do it for Cd Key and Ip? And am supposed to put the account names inbetween the inverted comma's?
Then for Onclient leave id assume I only need:
object oPC = GetExitingObject();
string PCNamea = GetLocalString(oPC, "Ser Red Ronnet Connington");
string PCNameb = GetLocalString(oPC, "DemonRot");
string PCNamec = GetLocalString(oPC, "God of Ruin");
So the whole script would read.
void main()
{
int nInt;
object oTarget;
object oPC = GetExitingObject();
string PCNamea = GetLocalString(oPC, "Ser Red Ronnet Connington");
string PCNameb = GetLocalString(oPC, "DemonRot");
string PCNamec = GetLocalString(oPC, "God of Ruin");
if(!GetIsPC(oPC)) return;
if(PCNamea == "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(PCNameb == "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(PCNamec == "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);
}
}
Should that work?
I am really struggling to get it to.
Thanks 420, removing that line has made the script work!
[snapback]36273[/snapback]
Cool and since the OnClient events only trigger when a player logs into or out of a mod the GetIsPC function is superfluous in those scripts.
Looks like GetIsPC checks to see if an object is currently controlled by a player. So it can probably also be used to see if a player is possessing their familiar.
-420