PDA

View Full Version : Syntax Error on a Script


harIII
10-26-2009, 07:42 PM
I have absolutely no idea what is going on with this script:

void main() {

int nInventorySlot01 = ("INVENTORY_SLOT_HEAD");
int nInventorySlot02 = ("INVENTORY_SLOT_BODY");


AssignCommand(GetFirstPC(), ActionEquipItem("g_w_lghtsbr01", nInventorySlot01);

AssignCommand(GetFirstPC(), ActionEquipItem("g_w_lghtsbr02", nInventorySlot02);

}

I keep getting an syntax error at line 7 and 9 with the ";" but I don't see anything that I can do with it.

Does anybody have any suggestions?

Laar_Dha
10-26-2009, 07:55 PM
It looks alike you forgot to close your first set of parentheses at the end of each line. Try it this way.
AssignCommand(GetFirstPC(), ActionEquipItem("g_w_lghtsbr01", nInventorySlot01));

AssignCommand(GetFirstPC(), ActionEquipItem("g_w_lghtsbr02", nInventorySlot02));

harIII
10-26-2009, 08:12 PM
I'm sorry but I'm still getting some problems, there were about 8 errors; can you try compiling it?

Laar_Dha
10-26-2009, 09:22 PM
Well, some progress. Errors reduced. The problem seems to be that the ActionEquipItem() commands wants an integer in the first parameter. Unfortunately, I have no I idea how to assign a value that will point to the lightsabers. This is what I came up with so far, but it needs more help. void main()
{

object oPC=GetFirstPC();

AssignCommand(oPC, ActionEquipItem("g_w_lghtsbr01", INVENTORY_SLOT_HEAD));

AssignCommand(oPC, ActionEquipItem("g_w_lghtsbr02", INVENTORY_SLOT_BODY));

}

harIII
10-26-2009, 09:29 PM
Thanks Laar_Dha, but I still can't get it, if anybody else knows what to do, it will be greatly appreciated.

DarthStoney
10-26-2009, 10:33 PM
Give this a shot and see if it's what you need,not sure but I don't think lightsabers will go into head or body inventory
void main(){
object oPC=GetFirstPC();
object oLS2 = CreateItemOnObject("g_w_lghtsbr02", oPC, 1, 1);
object oLS = CreateItemOnObject("g_w_lghtsbr01", oPC, 1, 1);
AssignCommand(oPC, ActionEquipItem(oLS, INVENTORY_SLOT_RIGHTWEAPON));
AssignCommand(oPC, ActionEquipItem(oLS2, INVENTORY_SLOT_LEFTWEAPON));
}

harIII
10-26-2009, 11:02 PM
I know that the items wouldn't go to the head and body but I didn't want to reveal what I going to do because I'm part of a project that hasn't been announced yet.

It's compiling but I'm not seeing the items equip this is the ultimate script. It's suppose to give you the helmet and armor, equip both, and then start a conversation on spawn:

void main() {
object oPC=GetFirstPC();

object oLS2 = CreateItemOnObject("storm_helmet", oPC, 1, 1);
object oLS = CreateItemOnObject("storm_armour", oPC, 1, 1);

AssignCommand(oPC, ActionEquipItem(oLS, INVENTORY_SLOT_BODY));
AssignCommand(oPC, ActionEquipItem(oLS2, INVENTORY_SLOT_HEAD));

}

It's compiling correctly but it's not equiping the items. Any ideas?

DarthStoney
10-27-2009, 12:10 AM
Forgot the void main(){ ? :)
void main(){
object oPC=GetFirstPC();

object oLS2 = CreateItemOnObject("storm_helmet", oPC, 1, 1);
object oLS = CreateItemOnObject("storm_armour", oPC, 1, 1);

AssignCommand(oPC, ActionEquipItem(oLS, INVENTORY_SLOT_BODY));
AssignCommand(oPC, ActionEquipItem(oLS2, INVENTORY_SLOT_HEAD));

}

harIII
10-27-2009, 12:43 AM
That wouldn't allow me to compile. I had the void main in the script but simply forgot to copy everything. The problem is that it will compile but won't equip the items in the game.

DarthStoney
10-27-2009, 08:43 AM
Oh,ok are you using the res_referance value for these;
object oLS2 = CreateItemOnObject("storm_helmet", oPC, 1, 1);
object oLS = CreateItemOnObject("storm_armour", oPC, 1, 1);

or if your using the tag value try this,(not sure if this is correct)
object oLS2 = CreateItemOnObject(GetObjectByTag("storm_helmet") , oPC, 1, 1));
object oLS = CreateItemOnObject(GetObjectByTag("storm_armour") , oPC, 1, 1));

glovemaster
10-27-2009, 09:30 AM
CreateItemOnObject("storm_helmet", oPC, 1, 1)
This parameter is the name of the UTI file, or the "resref". If you are using the tag, then that's probably the problem. Otherwise there could be a problem with the UTI files you are using.

Hope that helps ;)

harIII
10-27-2009, 12:17 PM
I still had a problem with a parenthese and fooled around with it for a while but got it working. Here is the final script that I used for those curious:

void main() {

object oPC=GetFirstPC();

object oHelmet = CreateItemOnObject("storm_helmet",oPC);
object oArmour = CreateItemOnObject("storm_armour",oPC);
object oSaber = CreateItemOnObject("g_w_lghtsbr02",oPC);


AssignCommand (oPC, ActionEquipItem(oHelmet, INVENTORY_SLOT_HEAD));
AssignCommand (oPC, ActionEquipItem(oArmour, INVENTORY_SLOT_BODY));
AssignCommand (oPC, ActionEquipItem(oSaber, INVENTORY_SLOT_RIGHTWEAPON));

ExecuteScript("start_zorin", OBJECT_SELF);

}

I think the problem was that the uti files were in a subfolder in the override.

glovemaster
10-27-2009, 01:02 PM
I think the problem was that the uti files were in a subfolder in the override.

That shouldn't have been a problem, but if it's working now I wouldn't look into it :p