01-24-2012, 07:41 AM
03-18-2012, 05:58 PM
(10-20-2010, 02:20 PM)Frontcannon Wrote: [ -> ]Some simple functions covering the basics for the people being completely new to scripting?this one doesnt work. I tried to place it onto my script but it gave me an error...
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
but its telling me that this : void KeyOnDoor(string &in asItem, string &in asEntity)
is the problem.
03-19-2012, 05:22 PM
(03-18-2012, 05:58 PM)mrscoomich Wrote: [ -> ]More detail please(10-20-2010, 02:20 PM)Frontcannon Wrote: [ -> ]Some simple functions covering the basics for the people being completely new to scripting?this one doesnt work. I tried to place it onto my script but it gave me an error...
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
but its telling me that this : void KeyOnDoor(string &in asItem, string &in asEntity)
is the problem.
03-21-2012, 12:04 AM
(03-19-2012, 05:22 PM)Stepper321 Wrote: [ -> ](03-18-2012, 05:58 PM)mrscoomich Wrote: [ -> ]More detail please(10-20-2010, 02:20 PM)Frontcannon Wrote: [ -> ]Some simple functions covering the basics for the people being completely new to scripting?this one doesnt work. I tried to place it onto my script but it gave me an error...
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
but its telling me that this : void KeyOnDoor(string &in asItem, string &in asEntity)
is the problem.
----
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?
03-21-2012, 12:47 PM
Is this your whole script. And what is your error say.
03-25-2012, 01:41 AM
Ah my apologies. I forgot to leave the void KeyOnDoor out of the OnStart()
I'm only a beginner in scripting.
^ could you please change it to this? it will seem less complicating. hehe thanks
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