logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Trouble with OnAcquireItem

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
ironhorse



Joined: 02 May 2005
Posts: 13
Location: uk

PostPosted: Wed Nov 03, 2010 2:53    Post subject: Trouble with OnAcquireItem Reply with quote

Hi,

I am having a little trouble with the OnAcquireItem. I have done the following script that when a player buys a key off a merchant, that it stores the info I need.

Code:
#include "aps_include"
void main()
{
object oItem = GetModuleItemAcquired();
object oPC = GetModuleItemAcquiredBy();
string sItem = GetTag(oItem);
string sHouseKey = GetStringLeft(sItem, 3);
string sName = GetName (oPC);


if ((sHouseKey) == "KEY")
    {
    string sHouseName = GetLocalString (oItem, "HOUSE_TAG");
    SendMessageToPC(oPC, ""+sHouseName+"");
    object oHouseSign = GetObjectByTag(""+sHouseName+"");
    SetPersistentString (oHouseSign, "House_Owner", ""+sName+"", 0, "housing"); //Sets the house to the buyer.
    SetPersistentInt (oHouseSign, "House_Rent", 500, 0, "housing"); //Sets the rent to make sure the house isnt taken.
    }


}


Now it works fine untill the player logs back in, for some reason it fires off the script in OnAcquireItem. I cannot figure out why it does it.

Can anyone help.

Thanks,

Ironhorse
Back to top
View user's profile Send private message Visit poster's website
axs



Joined: 11 Feb 2005
Posts: 76

PostPosted: Wed Nov 03, 2010 3:01    Post subject: Reply with quote

OnClientEnter:
Code:
SetLocalInt(oPC, "LoggedIn", TRUE);


OnClientLeave:
Code:
SetLocalInt(oPC, "LoggedIn", FALSE);


OnAcquireItem:
Code:
if(GetLocalInt(oPC, "LoggedIn")) { /*do something*/ }


This workaround should solve problem.
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Fri Nov 05, 2010 3:09    Post subject: Reply with quote

Yes, OnAcquireItem fires every time someone logs in for all of their items. It's usually undesirable behaviour and a poor design decision by Bioware. (Well you've got to balance out all the good ones - like providing a complete toolset - somehow!)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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