Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Make an script work when Pick up key?
SilentHideButFine Offline
Member

Posts: 156
Threads: 38
Joined: May 2012
Reputation: 6
#1
Make an script work when Pick up key?

Hey!! Smile

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?

[url= http://www.moddb.com/mods/jessehmusic [/url] ,HOSPITAL OF HORROR MOD
06-13-2012, 06:34 AM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#2
RE: Make an script work when Pick up key?

Use

SetEntityPlayerInteractCallback(string&
asName, string& asCallback, bool abRemoveOnInteraction);

I think.

Sorry for the text size [Image: smile.gif]. It was small when i typed.

[Image: the-cabin-in-the-woods-masked-people.jpg]
(This post was last modified: 06-13-2012, 07:35 AM by No Author.)
06-13-2012, 07:29 AM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#3
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
Find
Mackiiboy Offline
Member

Posts: 101
Threads: 7
Joined: Jan 2012
Reputation: 11
#4
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
Website Find
SilentHideButFine Offline
Member

Posts: 156
Threads: 38
Joined: May 2012
Reputation: 6
#5
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 Smile



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

[url= http://www.moddb.com/mods/jessehmusic [/url] ,HOSPITAL OF HORROR MOD
(This post was last modified: 06-13-2012, 04:11 PM by SilentHideButFine.)
06-13-2012, 10:07 AM
Find
SilentHideButFine Offline
Member

Posts: 156
Threads: 38
Joined: May 2012
Reputation: 6
#6
RE: Make an script work when Pick up key?

Anyone?

[url= http://www.moddb.com/mods/jessehmusic [/url] ,HOSPITAL OF HORROR MOD
06-13-2012, 10:15 PM
Find
Mackiiboy Offline
Member

Posts: 101
Threads: 7
Joined: Jan 2012
Reputation: 11
#7
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
Website Find
SilentHideButFine Offline
Member

Posts: 156
Threads: 38
Joined: May 2012
Reputation: 6
#8
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 ?

[url= http://www.moddb.com/mods/jessehmusic [/url] ,HOSPITAL OF HORROR MOD
06-14-2012, 04:17 PM
Find
Mackiiboy Offline
Member

Posts: 101
Threads: 7
Joined: Jan 2012
Reputation: 11
#9
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
Website Find




Users browsing this thread: 1 Guest(s)