View previous topic :: View next topic |
Author |
Message |
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Sat Mar 31, 2007 23:46 Post subject: |
|
|
No problem, thanks again! |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Sun Apr 01, 2007 23:45 Post subject: |
|
|
Well, I posting it only now, becose I was confused by bug in GetPersistentString, which maked missing SQLInit() in onmoduleload...
OK. So few word in advance:
I found out that you don't need GetFirst/NextArea - So i've written it without my functions i've posted up there...
Next thing is that I storing resref intead of object itself - resref have got big disadvantige - you'll must create a new object so every local variables on old object aren't transferred. You must know which variables are stored on placeable and then manually reapply them after create new one.
And at last: I creating placeable via item with unique power (with using tag of this item) and deleting via special item with unique power (which can also rotate placeable and so on).
Well, proceed to code:
onmoduleload event script
Code: | #include "aps_include"
void main()
{
int nCount = GetPersistentInt(OBJECT_SELF,"STORED_PLC_COUNT");
int x;
int n = 1;
object oPlaceable;
string sLocation,sn,resref;
location l;
while(x<nCount)
{
sn = IntToString(n);
resref = GetPersistentString(OBJECT_SELF,"STORED_PLC_"+sn+"_O");
if(resref!="")
{
l = GetPersistentLocation(OBJECT_SELF,"STORED_PLC_"+sn+"_L");
oPlaceable = CreateObject(OBJECT_TYPE_PLACEABLE,resref,l);
SetLocalInt(oPlaceable,"STORED_PLC_NUM",n);
x+=1;
}
n+=1;
}
} |
oncreateplaceable (script which execute onacquireitem event)
Code: | #include "aps_include"
void main()
{
object oItem = GetItemActivated();
string sTag = GetTag(oItem);
location l = GetItemActivatedTargetLocation();
object oPlaceable = CreateObject(OBJECT_TYPE_PLACEABLE,"sh_"+GetSubString(sTag,3,GetStringLength(sTag)-3),l,TRUE);
object oModule = GetModule();
int current = GetPersistentInt(oModule,"STORED_PLC_COUNT");
current+=1;
string scurrent = IntToString(current);
SetPersistentInt(oModule,"STORED_PLC_COUNT",current);
SetPersistentString(oModule,"STORED_PLC_"+scurrent+"_O",GetResRef(oPlaceable));
SetPersistentLocation(oModule,"STORED_PLC_"+scurrent+"_L",l);
SetLocalInt(oPlaceable,"STORED_PLC_NUM",current);
DestroyObject(oItem);
} |
ondeleteplaceable (script which execute onactivateitem event)
Code: | #include "aps_include"
void main()
{
object oPlaceable = GetSpellTargetObject();
string s = GetTag(oPlaceable);
int n = GetStringLength(s);
string ss = GetSubString(s,3,n-3);
CreateItemOnObject("cnr"+ss,GetPCSpeaker(),1);
int num = GetLocalInt(oPlaceable,"STORED_PLC_NUM");
object oModule = GetModule();
int count = GetPersistentInt(oModule,"STORED_PLC_COUNT");
string scurrent = IntToString(num);
SetPersistentInt(oModule,"STORED_PLC_COUNT",count-1);
DeletePersistentVariable(oModule,"STORED_PLC_"+scurrent+"_O");
DeletePersistentVariable(oModule,"STORED_PLC_"+scurrent+"_L");
DeleteLocalInt(oPlaceable,"STORED_PLC_NUM"); //i don't know if it's useful, but
//many scripters doing it ;) So it could be beneficial.
DestroyObject(oPlaceable);
} |
Well there is algoritmus, so i think you are able to re-write it for your system.
ShaDoOoW _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Tue Apr 03, 2007 4:41 Post subject: |
|
|
Thank you soooo much! With some great help from my friend Windwar, this is all set up in the system I've been working on.
You'll be in the credits for sure! Thanks again! |
|
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
|