Jump to content

Home

3 questions about script


jrc24

Recommended Posts

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

Link to comment
Share on other sites

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);
}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...