Frictional Games Forum (read-only)

Full Version: Scripts Recollection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12
(01-24-2012, 03:27 AM)flamez3 Wrote: [ -> ]Oops, use (string &in asEntity) instead ^^
Thanks man it worked!! I really appreciate it! Big Grin Big Grin
(10-20-2010, 02:20 PM)Frontcannon Wrote: [ -> ]Some simple functions covering the basics for the people being completely new to scripting?
Let's see what I can find..

How to make a locked door and a key to unlock it

Spoiler below!

Code:
void OnStart()
{
    AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("mansion_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}

What it does:
AddUseItemCallback - calls a function when an item is used on an entity
R01_Key1 - the item used, in this case our key
mansion_1 - the entity the key is used on, the normal mansion door
KeyOnDoor - the function the callback calls (true means to remove it when called once)

SetSwingDoorLocked - locks/unlocks a door, false means to set it NOT locked, and the true is to wether use effects or not
PlaySoundAtEntity - plays a sound at an entity, in this case the "unlocked a door"- sound at mansion_1, our door, the float value is the time it takes to fade in and the true is some strange boolean Big Grin

this one doesnt work. I tried to place it onto my script but it gave me an error...
but its telling me that this : void KeyOnDoor(string &in asItem, string &in asEntity)
is the problem.

(03-18-2012, 05:58 PM)mrscoomich Wrote: [ -> ]
(10-20-2010, 02:20 PM)Frontcannon Wrote: [ -> ]Some simple functions covering the basics for the people being completely new to scripting?
Let's see what I can find..

How to make a locked door and a key to unlock it

Spoiler below!

Code:
void OnStart()
{
    AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("mansion_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}

What it does:
AddUseItemCallback - calls a function when an item is used on an entity
R01_Key1 - the item used, in this case our key
mansion_1 - the entity the key is used on, the normal mansion door
KeyOnDoor - the function the callback calls (true means to remove it when called once)

SetSwingDoorLocked - locks/unlocks a door, false means to set it NOT locked, and the true is to wether use effects or not
PlaySoundAtEntity - plays a sound at an entity, in this case the "unlocked a door"- sound at mansion_1, our door, the float value is the time it takes to fade in and the true is some strange boolean Big Grin

this one doesnt work. I tried to place it onto my script but it gave me an error...
but its telling me that this : void KeyOnDoor(string &in asItem, string &in asEntity)
is the problem.
More detail please
(03-19-2012, 05:22 PM)Stepper321 Wrote: [ -> ]
(03-18-2012, 05:58 PM)mrscoomich Wrote: [ -> ]
(10-20-2010, 02:20 PM)Frontcannon Wrote: [ -> ]Some simple functions covering the basics for the people being completely new to scripting?
Let's see what I can find..

How to make a locked door and a key to unlock it

Spoiler below!

Code:
void OnStart()
{
    AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("mansion_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}

What it does:
AddUseItemCallback - calls a function when an item is used on an entity
R01_Key1 - the item used, in this case our key
mansion_1 - the entity the key is used on, the normal mansion door
KeyOnDoor - the function the callback calls (true means to remove it when called once)

SetSwingDoorLocked - locks/unlocks a door, false means to set it NOT locked, and the true is to wether use effects or not
PlaySoundAtEntity - plays a sound at an entity, in this case the "unlocked a door"- sound at mansion_1, our door, the float value is the time it takes to fade in and the true is some strange boolean Big Grin

this one doesnt work. I tried to place it onto my script but it gave me an error...
but its telling me that this : void KeyOnDoor(string &in asItem, string &in asEntity)
is the problem.
More detail please





----
Code:
void OnStart()
{
AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}


When I copy and paste that (replacing the examples with my entity/ door names),
it says Error( a number, a number)

and when I stare back at my .hps file, it seems that the error told me it was the line where the
void KeyOnDoor(string &in asItem, string &in asEntity)

was placed. i've tried to fix this a couple times and not sure if there is a typo or where to.

why doesnt it work?
Is this your whole script. And what is your error say.
Ah my apologies. I forgot to leave the void KeyOnDoor out of the OnStart()
I'm only a beginner in scripting.
Code:
void OnStart()
//IN OnStart
{
AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}
//OUTSIDE of OnStart
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}


^ could you please change it to this? it will seem less complicating. hehe thanks
Pages: 1 2 3 4 5 6 7 8 9 10 11 12