Hmmmm... That script may work for kotor1 but there is an easier way to do it for kotor 2.
Code:
void main()
{
int nQuantity = 1;
CreateItemOnObject("g_w_lghtsbr01", GetFirstPC(), nQuantity);
}
In this script i want to get 1 item.
Code:
void main()
{
int nQuantity = 3;
CreateItemOnObject("g_danceroutfit", GetFirstPC(), nQuantity);
}
In this script i want to get 3 items.
To compile scripts go to the kotor tool text editor and make your script. use the text editor for your script then save it in the override folder as "myscriptname".nss. Then go to the scripts menu and say script is for kotor/2 (each games use different scripts. The one in this tutorial is for kotor2.) then press F5. you should get this message
Lookup path root set to C://program Files//LucasArts//SWKotOR2
Loaded nwscript.nss form C://program Files//LucasArts//SWKotOR2//Override
Compiling: myscriptname.nss
Total Execution time = X ms
If it says that then you have sucessfuly compiled your script!
If you don't, then try not to get mad and check your scripts. one of the most common reasons may be one of you things is wrong.
Then on the dialouge editor (kotor tool or DLGEditor by Tk102, a very talanted scripter), go to the string of dialouge you want to add the script to.Go to the scripts menu. Under the script option there are 2 things
1)script that fires when spoken
2)script that needs to run
The script that fires when spoken is the bit you need type in the name of your script,without the .nss/.ncs extention. The Needed script is best left alone as many functions in game are required with these.
*NOTE* There are different functions of scripting for kotor1 and 2. This scripting tutorial covers kotor 2 scripts. Also as Gsccc said there is no way to get LS/DS, exp, gold or infuence through these scripts. You may change the resref to a custom item if you use the UTI file in game.
Have fun With scripting!
~Mandalorian16965