PDA

View Full Version : 3 questions about script


jrc24
06-22-2004, 08:59 PM
hi

how can I do that ?

- give credits to player with a script but without seeing the message : credits won "number"

- call a script when I get an item (uti file)

- get a script but just once

exemple : I open first once a footlocker (I get my script) but I do not want get the script when I open again the footlocker


thank u

tk102
06-23-2004, 01:20 AM
give credits to player with a script but without seeing the message : credits won "number"
Instead of using the GiveGoldToCreature function, you can use the CreateItemOnObject function and for the Item, use one of the g_i_creditsXXX.uti templates. For example:


void main() {
// this will give 5 x 2000 credits to the PC
CreateItemOnObject("g_i_credits011",GetFirstPC(),5);
}


call a script when I get an item (uti file)Hmm... that's a tricky one. In theory you could do it in the module.ifo file (Mod_OnAcquirItem event). I've never done it before and it's not a very effecient way -- you have to pack the entire module and redistribute it as a .mod file. Plus you have to check for each item that is acquired. May be better to check with a Trigger object nearby using the GetFirstItemInInventory and GetNextItemInInventory functions.

- get a script but just once
That is done with the SetLocalBoolean/GetLocalBoolean function.

void main() {
int nBoolSlot=2; //any number 0-7
int nCheck=GetLocalBoolean(GetObjectByTag("object_tag"),nBoolSlot);
if (nCheck) { return; } //exit if TRUE

//
// do main script here
//

// now close the door so we can't re-enter
SetLocalBoolean(GetObjectByTag("object_tag"),nBoolSlot,TRUE);
}

jrc24
06-23-2004, 02:13 AM
ok

Instead of using the GiveGoldToCreature function, you can use the CreateItemOnObject function and for the Item, use one of the g_i_creditsXXX.uti templates. For example:


void main() {
// this will give 5 x 2000 credits to the PC
CreateItemOnObject("g_i_credits011",GetFirstPC(),5);
}


thank you very much for the information (we can do many things with this)

------------------------------------------------------------

Hmm... that's a tricky one. In theory you could do it in the module.ifo file (Mod_OnAcquirItem event). I've never done it before and it's not a very effecient way -- you have to pack the entire module and redistribute it as a .mod file. Plus you have to check for each item that is acquired. May be better to check with a Trigger object nearby using the GetFirstItemInInventory and GetNextItemInInventory functions.

I understand

------------------------------------------------------------

That is done with the SetLocalBoolean/GetLocalBoolean function.


void main() {
int nBoolSlot=2; //any number 0-7
int nCheck=GetLocalBoolean("object_tag",nBoolSlot);
if (nCheck) { return; } //exit if TRUE

//
// do main script here
//

// now close the door so we can't re-enter
SetLocalBoolean("object_tag",nBoolSlot,TRUE);
}


I try to do a script with this
I write that :


void main() {
int nBoolSlot=2;
int nCheck=GetLocalBoolean("credbox",nBoolSlot);
if (nCheck) { return; }
int nGoldPieces = (500000);
object oNPC=GetFirstPC();
GiveGoldToCreature(oNPC, nGoldPieces);
SetLocalBoolean("credbox",nBoolSlot,TRUE);
}


credbox is a footlocker placeable " that is not the problem :) "

when I try to compile, nwnnsscomp say to me :

givecred.nss(3): Error: Type mismatch in parameter 1 in call to "GetLocalBoolean"
givecred.nss(8): Error: Type mismatch in parameter 1 in call to "SetLocalBoolean"

if you see what is the problem...thank you

tk102
06-23-2004, 10:55 AM
jrc24--

I've edited the Set/GetLocalBoolean function (parameter 1 needed an object not a string) :rolleyes:

jrc24
06-23-2004, 11:34 AM
NOW IT WOOOORKS !!!

thank you tk