Hi all!
This is my first Toolset script: I'm trying to create a custom runscript command to add items(specifying amount also) into party inventory but there are some syntax issues that I cannot resolve. Here is the code:
void main()
{
string sVar = GetLocalString(GetModule(), "RUNSCRIPT_VAR");
int nFind = FindSubString(sVar, " ");
string sArg0;
string sArg1;
if (nFind > 0)
{
sArg0 = SubString(sVar, 0, nFind) + ".uti";
sArg1 = SubString(sVar, (nFind + 1), GetStringLength(sVar));
}
else
{
sArg0 = SubString(sVar, 0, GetStringLength(sVar)) + ".uti";
sArg1 = "1";
}
resource rItemFileName = sArg0;
int nStackSize = StringToInt(sArg1);
if ((nStackSize < 0) || (nStackSize > 99))
nStackSize = 1;
CreateItemOnObject(rItemFileName, OBJECT_SELF, nStackSize);
}
The error obviously concerns the string containing the item name and it's conversion to resource type.
I've read some tutorial but I can't still figure out how to create a resource from a given string variable because I want to enter the item name manually and adding a little "R" before doesn't do the job.
I've seen a lot of examples about CreateItemOnObject, but it's always used with a declared string:
CreateItemOnObject(R"item_name.uti", OBJECT_SELF, nStackSize);
Can someone help me please? Thanks!
Help with a console command, please!
Débuté par
Divino Zarathos
, févr. 14 2010 10:37





Retour en haut






