PDA

View Full Version : Scripting Problem


MasterWaffle
01-13-2008, 11:48 PM
I'm having trouble compiling a script. Every time I compile I get a message saying "Error: Undeclared Identifier 'oContainer' (and 'oLocker')".

Can anyone tell me what I'm doing wrong? Script is below.

SCRIPT:

void main()
{
object oEntering = GetEnteringObject();
object oPC=GetFirstPC();
if (GetIsPC(oEntering))
{
if (!GetIsObjectValid(GetObjectByTag("metalbox033")))
{
oContainer= CreateObject(OBJECT_TYPE_PLACEABLE, "metalbox033", Location(Vector(169.35, 132.94, 2.26), 00.0));

CreateItemOnObject("g_a_class4066", oLocker);
CreateItemOnObject("g_i_belt002", oLocker);
CreateItemOnObject("g_w_blstrpstl002", oLocker);
CreateItemOnObject("g_i_pazcard_011", oLocker);
CreateItemOnObject("g_i_upgrade002", oLocker);
CreateItemOnObject("g_i_mask05", oLocker);

}
ExecuteScript("old_k_ptar_a10aa_en", OBJECT_SELF);
}

Stream
01-14-2008, 01:28 AM
You forgot to tell the script what oContainer & oLocker are, try this



void main(){

object oConatiner = GetObjectbyTag("EnterTagHere");
object oLocker = GetObjectByTag("EnterTagHere");
object oEntering = GetEnteringObject();
object oPC=GetFirstPC();
if (GetIsPC(oEntering))
{
if (!GetIsObjectValid(GetObjectByTag("metalbox033")))
{
CreateObject(OBJECT_TYPE_PLACEABLE,"metalbox033",Location(Vector(169.35, 132.94, 2.26), 00.0));

CreateItemOnObject("g_a_class4066", oLocker);
CreateItemOnObject("g_i_belt002", oLocker);
CreateItemOnObject("g_w_blstrpstl002", oLocker);
CreateItemOnObject("g_i_pazcard_011", oLocker);
CreateItemOnObject("g_i_upgrade002", oLocker);
CreateItemOnObject("g_i_mask05", oLocker);

}
ExecuteScript("old_k_ptar_a10aa_en", OBJECT_SELF);
}



That should sort it out for you.

--Stream

MasterWaffle
01-14-2008, 01:32 AM
Thank you, that clears things up.

stoffe
01-14-2008, 08:00 AM
I'm having trouble compiling a script. Every time I compile I get a message saying "Error: Undeclared Identifier 'oContainer' (and 'oLocker')".

Can anyone tell me what I'm doing wrong? Script is below.


There are three problems with your script. The first is that you have no closing block delimiter after the if-statement that checks if the container already exists. The second is that you have not declared either the oLocker or oContainer variables before you try to use them. The third is that you assign the object reference of the container to oContainer, which you then do nothing with, and instead try to create the items on a non-existing object since oLocker has not had any value assigned.

So if I've understood correctly what you are trying to do: to make it work properly you check if the container does not exist. If it does not, you spawn it into the area and add a number of items to its inventory. Like:


void main() {
if (GetEnteringObject() == GetFirstPC()) {
object oLocker = GetObjectByTag("metalbox033");
if (!GetIsObjectValid(oLocker)) {
oLocker = CreateObject(OBJECT_TYPE_PLACEABLE, "metalbox033", Location(Vector(169.35, 132.94, 2.26), 00.0));

CreateItemOnObject("g_a_class4066", oLocker);
CreateItemOnObject("g_i_belt002", oLocker);
CreateItemOnObject("g_w_blstrpstl002", oLocker);
CreateItemOnObject("g_i_pazcard_011", oLocker);
CreateItemOnObject("g_i_upgrade002", oLocker);
CreateItemOnObject("g_i_mask05", oLocker);
}
}
ExecuteScript("old_k_ptar_a10aa_en", OBJECT_SELF);
}

MasterWaffle
01-15-2008, 07:26 PM
Thanks for your help.