SilentHideButFine
Member
Posts: 156
Threads: 38
Joined: May 2012
Reputation:
6
|
Make an script work when Pick up key?
Hey!!
I wanna know how i make like this
You are in the first room(there are 2) the script is on the door BUT the door script is gonna work when pickup key and enter area?
any tip clue?
|
|
06-13-2012, 06:34 AM |
|
No Author
Posting Freak
Posts: 962
Threads: 10
Joined: Jun 2012
Reputation:
13
|
RE: Make an script work when Pick up key?
Use
SetEntityPlayerInteractCallback(string&
asName, string& asCallback, bool abRemoveOnInteraction);
I think.
Sorry for the text size . It was small when i typed.
(This post was last modified: 06-13-2012, 07:35 AM by No Author.)
|
|
06-13-2012, 07:29 AM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
RE: Make an script work when Pick up key?
nope it's AddUseItemCallback, RemoveItem, SetSwingDoorLocked and PlaySoundAtEntity. I'm writing this on my phone so the codes might be a little wrong
If you are supposed to unlock the door with the key, if its just going to open without the key then its SetEntityPlayerInteractCallback
(This post was last modified: 06-13-2012, 08:29 AM by SilentStriker.)
|
|
06-13-2012, 08:27 AM |
|
Mackiiboy
Member
Posts: 101
Threads: 7
Joined: Jan 2012
Reputation:
11
|
RE: Make an script work when Pick up key?
If you want something to happen when you pick up the key, you will need to use this:
void OnStart()
{
SetEntityCallbackFunc("name_of_your_key", "PickUpKeyFunc");
}
void PickUpKeyFunc(string &in entity, string &in type)
{
if(type == "OnPickup")
{
// Put everything you want to happen here after you have picked up your key.
}
}
So, if you have a script area that is inactive in the level editor and want to be active, you could put a SetEntityActive("Your_Script_Area", true); inside the PickUpKeyFunc.
(This post was last modified: 06-13-2012, 08:34 AM by Mackiiboy.)
|
|
06-13-2012, 08:32 AM |
|
SilentHideButFine
Member
Posts: 156
Threads: 38
Joined: May 2012
Reputation:
6
|
RE: Make an script work when Pick up key?
(06-13-2012, 08:32 AM)Mackiiboy Wrote: If you want something to happen when you pick up the key, you will need to use this:
void OnStart()
{
SetEntityCallbackFunc("name_of_your_key", "PickUpKeyFunc");
}
void PickUpKeyFunc(string &in entity, string &in type)
{
if(type == "OnPickup")
{
// Put everything you want to happen here after you have picked up your key.
}
}
So, if you have a script area that is inactive in the level editor and want to be active, you could put a SetEntityActive("Your_Script_Area", true); inside the PickUpKeyFunc. When pick up key you are supposed to go out but when you come like 2 m away from the door the doors opens by it self
void PickUpKeyFunc(string &in entity, string &in type)
{
if(type == "OnPickup")
{
AddBodyForce("mansion_2", -3.388, 0, 0, "world");
StartPlayerLookAt("mansion_2", 5, 5, "");
PlaySoundAtEntity("", "react_scare.snt", "mansion_2", 3, true);
AddTimer("StopLookAt", 3, "StopLookAtEvent");
}
}
void StopLookAtEvent(string &in asTimer)
{
StopPlayerLookAt();
}
There is the script with funcs
Sound and bodyforce dosnt work only the look at :S
|
|
06-13-2012, 10:07 AM |
|
SilentHideButFine
Member
Posts: 156
Threads: 38
Joined: May 2012
Reputation:
6
|
RE: Make an script work when Pick up key?
Anyone?
|
|
06-13-2012, 10:15 PM |
|
Mackiiboy
Member
Posts: 101
Threads: 7
Joined: Jan 2012
Reputation:
11
|
RE: Make an script work when Pick up key?
(06-13-2012, 10:15 PM)SilentHideButFine Wrote: Anyone? .
Try an impulse instead of a force on the door:
AddPropImpulse("mansion_2", 50, 0, -50, "world");
You will not hear the sound if it should fade out in 3 seconds, try to put the value 0 instead and it will work just fine.
PlaySoundAtEntity("", "react_scare.snt", "mansion_2", 3, true);
(This post was last modified: 06-14-2012, 09:42 AM by Mackiiboy.)
|
|
06-14-2012, 09:41 AM |
|
SilentHideButFine
Member
Posts: 156
Threads: 38
Joined: May 2012
Reputation:
6
|
RE: Make an script work when Pick up key?
(06-14-2012, 09:41 AM)Mackiiboy Wrote: (06-13-2012, 10:15 PM)SilentHideButFine Wrote: Anyone? .
Try an impulse instead of a force on the door:
AddPropImpulse("mansion_2", 50, 0, -50, "world");
You will not hear the sound if it should fade out in 3 seconds, try to put the value 0 instead and it will work just fine.
PlaySoundAtEntity("", "react_scare.snt", "mansion_2", 3, true); AddPropImpulse("mansion_2", 50, 0, -50, "world"); dosnt work :S want screenshot of the door ?
|
|
06-14-2012, 04:17 PM |
|
Mackiiboy
Member
Posts: 101
Threads: 7
Joined: Jan 2012
Reputation:
11
|
RE: Make an script work when Pick up key?
(06-14-2012, 04:17 PM)SilentHideButFine Wrote: AddPropImpulse("mansion_2", 50, 0, -50, "world"); dosnt work :S want screenshot of the door ? .
Experiment and try different impulse-values (afX & afZ) till' it works. I think the result depends on how you have rotated your door in the level editor, in some cases you will just need to use X-values, some times Z-values, and some times both. You might need to use SetSwingDoorDisableAutoClose("mansion_2", true); as well to deactivate the auto-close-thing when a door is nearly closed.
-------
You could use propforces as well as propimpulses, but you will need higher values when you use forces.
(This post was last modified: 06-14-2012, 06:23 PM by Mackiiboy.)
|
|
06-14-2012, 06:19 PM |
|
|