View previous topic :: View next topic |
Author |
Message |
Tuebits
Joined: 27 Jan 2005 Posts: 18
|
Posted: Wed Feb 09, 2005 21:41 Post subject: persistant death monitoring |
|
|
I am working on an easy anti-plugger death system, and didn;t want to use a death token system.
this is what i have already, but not seeming to work, if anyone can please look it over and tell me what i have done wrong, it would be appreciated
OnCLientLeave:
Code: | #include "dar_func"
#include "aps_include"
void main() {
object oPC = GetExitingObject();
if(GetIsDead(oPC)) {
SetPersistentInt(oPC,"dead",1);
}
OnSubraceLeave(oPC);
}
|
OnClientEnter:
Code: | #include "dar_func"
#include "aps_include"
void main() {
object oPC;
if(GetIsPC(oPC = GetEnteringObject())) {
OnSubraceEnter(oPC);
}
if(OBJECT_INVALID == GetItemPossessedBy(oPC,"locationsaver")){
CreateItemOnObject("locationsaver",oPC);
}
int Plug = GetPersistentInt(oPC, "dead");
if(Plug==1) {
effect eDamage = EffectDamage(10000,DAMAGE_TYPE_MAGICAL);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eDamage,oPC);
SetPersistentInt(oPC,"dead",0);
}
}
|
|
|
Back to top |
|
|
Dazzle
Joined: 29 Dec 2004 Posts: 19
|
Posted: Wed Feb 09, 2005 22:58 Post subject: |
|
|
NWN can't get any of the GetPCPlayerName/GetName at ClientLeave from a leaving player, SetPersistentInt uses these variables to store the integer. Your script uses these two variables, but since you try to get them at OnClientLeave, the script fails. There's a workaround for it, but it requires some editing.
First, OnClientEnter you store the two earlier mentioned variables locally on the player.
Like this:
Code: | SetLocalString(oPC, "PlayerCharacterName", GetName(oPC);
SetLocalString(oPC, "PlayerPlayerLoginName", GetPCPlayerName(oPC); |
After that, you open the aps_include script and change the SetPersistentString() function into this one:
Code: | void SetPersistentString(object oObject, string sVarName, string sValue, int iExpiration =
0, string sTable = "pwdata")
{
string sPlayer;
string sTag;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetLocalString(oObject, "PlayerPlayerLoginName"));
sTag = SQLEncodeSpecialChars(GetLocalString(oObject, "PlayerCharacterName"));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
sValue = SQLEncodeSpecialChars(sValue);
string sSQL = "SELECT player FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
{
// row exists
sSQL = "UPDATE " + sTable + " SET val='" + sValue +
"',expire=" + IntToString(iExpiration) + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
}
else
{
// row doesn't exist
sSQL = "INSERT INTO " + sTable + " (player,tag,name,val,expire) VALUES" +
"('" + sPlayer + "','" + sTag + "','" + sVarName + "','" +
sValue + "'," + IntToString(iExpiration) + ")";
SQLExecDirect(sSQL);
}
} |
Below is your OnClientEnter script, I added the two SetLocalString functions and cleaned it up a bit.
Code: | #include "dar_func"
#include "aps_include"
void main()
{
object oPC = GetEnteringObject();
SetLocalString(oPC, "PlayerCharacterName", GetName(oPC));
SetLocalString(oPC, "PlayerPlayerLoginName", GetPCPlayerName(oPC));
if( GetIsPC(oPC) )
{
OnSubraceEnter(oPC);
}
if( GetItemPossessedBy(oPC,"locationsaver") == OBJECT_INVALID )
{
CreateItemOnObject("locationsaver", oPC);
}
int Plug = GetPersistentInt(oPC, "dead");
if( Plug == 1 )
{
effect eDamage = EffectDamage(10000, DAMAGE_TYPE_MAGICAL);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
SetPersistentInt(oPC,"dead", 0);
}
} |
This'll most likely work, if not, just ask again. |
|
Back to top |
|
|
Tuebits
Joined: 27 Jan 2005 Posts: 18
|
Posted: Wed Feb 09, 2005 23:07 Post subject: |
|
|
your first code is for OnCLientLeave i beleive, being that your last code is OnEnter.. |
|
Back to top |
|
|
Tuebits
Joined: 27 Jan 2005 Posts: 18
|
Posted: Wed Feb 09, 2005 23:13 Post subject: |
|
|
how about using SetPersistentInt(oPC,"dead",1)' OnDeath event.
then change SetPersistentInt(oPC,"dead",0) when repawn, raise dead, and ressurect.. and leave my OnClientEnter the same, as well as aps_inclde.. ? |
|
Back to top |
|
|
NoMercy
Joined: 03 Jan 2005 Posts: 123 Location: UK
|
Posted: Wed Feb 09, 2005 23:32 Post subject: |
|
|
You can mark them dead on the death event, but do remember sometimes people come back to live though other means (DM's clicking heal buttons come to mind) so it's a good idea to also save on logout, and mabie in other situations as well.
I guess if you were paranoid enough you could set a psudo heartbeat off checking every minute if the player has come back to live though means other than respawn/raise/resurect. |
|
Back to top |
|
|
Tuebits
Joined: 27 Jan 2005 Posts: 18
|
Posted: Wed Feb 09, 2005 23:42 Post subject: |
|
|
ohh i forgot about the DM heal button...respawn, ress, raise dead are the only 3 other options. you know if the DM heal has its own script and the possible NWN base script name for it, can always add it there too if there is a script for it |
|
Back to top |
|
|
dguntner
Joined: 31 Dec 2004 Posts: 116
|
Posted: Thu Feb 10, 2005 9:16 Post subject: |
|
|
Dazzle wrote: | NWN can't get any of the GetPCPlayerName/GetName at ClientLeave from a leaving player, [...] |
Just FYI, GetName() works fine on a leaving player in the OnClientLeave script. But you're right, GetPCPlayerName() won't turn anything up at that point.
--Dave |
|
Back to top |
|
|
DarkstarsDad
Joined: 17 Jan 2005 Posts: 59 Location: Overland Park, Kansas USA
|
Posted: Sun Feb 13, 2005 6:15 Post subject: cool |
|
|
Damn I didnt know that. thanks dave. i can use that for another script Im working on. _________________ Just because you think you can't. Is the best reason to try it anyway. |
|
Back to top |
|
|
chunkymonky
Joined: 20 Feb 2005 Posts: 31
|
Posted: Sun Feb 20, 2005 16:18 Post subject: |
|
|
I'm having a similar problem with my death system and persistence. Could someone please advise me how to make death persistent with NWNX/APS? My scripting is ok, not spectacular, so it is a vexing situation for me. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|