View Full Version : giving Items with scripting

06-13-2009, 07:33 PM
I'm sure alot of you know about JCarter's Class Clothing. It supposedly restores the different clothes for classes (whether your a Guardian, Sentinel or Consular)

Well, I thought of a different more efficient way to do this.. unfortunately I know nothing of scripting, so I'm asking for a bit of help here.

Would it be possible to write a script that give your pc a certain item based on the class they are? (I'm guessing it could be, and ultimately, this isn't the hard part anyways)

secondly, what would need to be done to make this work so that the PC will have this item equipped in the force cage at the TSF base? Would you have to edit an existing compiled script?

EDIT: I'm sorry for being so dumb. I should've checked out the tutorials first. I guess I just didn't want to script, but I guess it doesn't look so bad. I'm getting DeNcs as we speak, and I am going to attempt to make this script on my own... though, expect a post asking for help in the near future.

06-14-2009, 10:47 AM
Im pretty sure you could. You'd wanna make a script with three similar parts: each checking the class and giving a different item (if consular, give x; if guardian, give y; etc).
As for the second part, you would probably have to edit some 2da file to set that robe as their default robe. Not sure if you could make it different for each class though.
Sorry I couldn't be of more help. The computer I'm on doesn't have Kotor Tool. You may wanna look at the script function filters and/or tutorials on this site for more info.

06-14-2009, 11:14 AM
I think I figured out how to do it... too bad I suck at script syntax. I was going to compile it, except my nwscript.nss and nwnsscomp.exe weren't working right, and then my KotorTool stopped working. I've been having problems with this issue forever and it pretty much sucks.

06-15-2009, 12:52 PM
For the KT not working, if it still isn't working after a restart, try uninstalling and reinstalling it. It sometimes goes bad for me after a while and I've heard others say the same

06-16-2009, 10:56 PM
Well, I've recovered from my KTool error. I managed to find and decompile the script I was looking for. Using my little knowledge of If/Then statements, I attempted to modify the code, but I seriously doubt it will work. I haven't tried it yet mostly because I'm pretty sure it won't work. What do I need to do get this to work properly? (my code is in red)

void main() {
object oLockerTSFINV = GetObjectByTag("LockerTSFINV", 0);
int int1 = 0;
object oPC = GetFirstPC();
object oKreia = GetObjectByTag("Kreia", 0);
object oAtton = GetObjectByTag("Atton", 0);
if (((!GetIsObjectValid(oKreia)) || (!GetIsObjectValid(oAtton)))) {
AurPostString("No NPC avaialable to remove items FROM", 5, 25, 30.0);
object object9 = GetObjectByTag("LockerTSFINV", 0);
object object11 = GetObjectByTag("LockerTSFINV", 1);
object object13 = GetObjectByTag("LockerTSFINV", 2);
object object15 = GetObjectByTag("LockerTSFINV", 3);
object oInvItem = GetFirstItemInInventory(oPC);
while ((oInvItem != OBJECT_INVALID)) {
switch ((int1 % 4)) {
case 0:
oLockerTSFINV = object9;
case 1:
oLockerTSFINV = object11;
case 2:
oLockerTSFINV = object13;
case 3:
oLockerTSFINV = object15;
if ((("SonicImprintSensor" == GetTag(oInvItem)) || ("comlink" == GetTag(oInvItem)))) {
oInvItem = GetNextItemInInventory(oPC);
else {
GiveItem(oInvItem, oLockerTSFINV);
oInvItem = GetFirstItemInInventory(oPC);
int int4;
oLockerTSFINV = GetObjectByTag("LockerTSFINV", 4);
int4 = (20 - 1);
while ((int4 >= 0)) {
GiveItem(GetItemInSlot(int4, oPC), oLockerTSFINV);
GiveItem(GetItemInSlot(int4, oAtton), oLockerTSFINV);
GiveItem(GetItemInSlot(int4, oKreia), oLockerTSFINV);
if ((int4 == 1)) {

if ( GetLevelByClass ( CLASS_TYPE_JEDISENTINEL, GetFirstPC () ) )
AssignCommand(oPC, ActionEquipItem(CreateItemOnObject("g_a_clothes02", oPC, 1, 1), 1, 1))

if ( GetLevelByClass ( CLASS_TYPE_JEDIGUARDIAN, GetFirstPC () ) )
AssignCommand(oPC, ActionEquipItem(CreateItemOnObject("g_a_clothes01", oPC, 1, 1), 1, 1))

if ( GetLevelByClass ( CLASS_TYPE_JEDICONSULAR, GetFirstPC () ) )
AssignCommand(oPC, ActionEquipItem(CreateItemOnObject("g_a_clothes03", oPC, 1, 1), 1, 1)):

AssignCommand(oAtton, ActionEquipItem(CreateItemOnObject("g_a_clothes01", oAtton, 1, 1), 1, 1));
AssignCommand(oKreia, ActionEquipItem(CreateItemOnObject("g_a_clothes01", oKreia, 1, 1), 1, 1));

I need all the help I can get.

EDIT: I thought I posted this earlier but it was gone when I went to check. If this for some reason was removed by a moderator, I was not aware so please give me a break.

06-18-2009, 11:57 PM
well i gota go but I'll try to help tomorrow. one thing i noticed after looking a bit is that I believe you must change the second two "if"s to "else if"s

06-19-2009, 06:16 PM
Of course... else if! I'm going to try it out. I've been having troubles compiling the script, and then KotorTool crashed again. This time I found the source though. Apparently I had some infected exes, that whenever I ran them, it well, gave me a virus. Hopefully I can compile this, and then test it to see if it works. Thanks for the help so far Malxados.

EDIT: After a few syntax fixes, i compiled the script and.....

It totally worked ;)

For some reason, KotorTool doesn't like to compile scripts for me, so I had to use Kotor Script Editor instead.