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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help on a script ;) [solved!]
VeNoMzTeamHysterical Offline
Member

Posts: 240
Threads: 36
Joined: Dec 2012
Reputation: 3
#1
Question  Need help on a script ;) [solved!]

I wanna make if you interact something you teleport i made that.
But now i want that you need a key for it..
So if you didn't use the key on it starts SetMessage and then a text like. I'ts locked i need a key to enter. and if you interact then you teleport to the cellar.

If you don't understand what i mean i show some pictures to make it clear.

Script in spoiler
Spoiler below!

HPS.

////////////////////////////
// Run first time starting map
void OnStart()
{
//---- COLLIDE CALLBACKS ----//
AddUseItemCallback("", "Cellar_Key", "CellarDoor1", "OpenCellarDoor1", true);

}

void OpenCellarDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("CellarDoor1", false, true);
PlaySoundAtEntity("", "unlock_door", "CellarDoor1", 0, false);
RemoveItem("Cellar_Key");
}

void EnterCellar(string &in asEntity)
{
TeleportPlayer("InCellar");
SetMessage("Messages", "EnteringTheCellar", 5.0);
}

void LeaveCellar(string &in asEntity)
{
TeleportPlayer("OutCellar");
}
////////////////////////////
// Run when entering map
void OnEnter()
{

AutoSave();
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

LANG.

<LANGUAGE>
<RESOURCES>
</RESOURCES>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">[br][br][br][br][br][br][br][br][br][br][br][br][br][br][br]</Entry>
</CATEGORY>

<CATEGORY Name="Messages">
<Entry Name="EnteringTheCellar">This seems like a storage, Maybe i can find something useful!</Entry>
</CATEGORY>

<CATEGORY Name="Inventory">
<Entry Name="ItemDesc_Cellar_Key">It's a Rusty Key, There is marked something on it, It is very rusty and hard to read[br]F*r Ent*r*ng Th*e C*ll*r.</Entry>
<Entry Name="ItemName_Cellar_Key">Rusty Key!</Entry>
</CATEGORY>

<CATEGORY Name="Journal">
<Entry Name="Note_DiaryJane_Name">Diary Jane 1/1</Entry>
<Entry Name="Note_DiaryJane_Text">My husband Jake is a miner.[br]He works in the mine here nearby already for 15 years.[br]Still im really scared that the mine is gonna colapsed,[br]The mine has been here for centuries![br]There is still a myth going around that there are some kind of monsters in there.[br]Me and Jake dont believe in myths,[br]But...What if they are really there.[br][br]Former.[br]Jane.</Entry>
</CATEGORY>

<CATEGORY Name="Levels">
</CATEGORY>

</LANGUAGE>


Pictures! Smile

Inside the cellar where it should go when used key and interact the door.

[Image: 10p5ybl.jpg]

The Cellar entrance at the back of the house.

[Image: 2052gr9.jpg]

Hope you can help me already thanks for helping!
Cheers Wink

http://www.frictionalgames.com/forum/thread-21719.html
Evil Awaking Work In Progress!
Hours Spend 472.
(This post was last modified: 04-13-2013, 11:44 PM by VeNoMzTeamHysterical.)
04-13-2013, 04:11 PM
Website Find
Tiger Away
Posting Freak

Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation: 55
#2
RE: Need help on a script ;)

I really don't understand your question, but you have no variable that activated the 'EnterCellar'-function.
04-13-2013, 04:23 PM
Find
VeNoMzTeamHysterical Offline
Member

Posts: 240
Threads: 36
Joined: Dec 2012
Reputation: 3
#3
RE: Need help on a script ;)

(04-13-2013, 04:23 PM)Tiger Wrote: I really don't understand your question, but you have no variable that activated the 'EnterCellar'-function.

I mean i want that if you interact whitout using the key. it says you need a key to open this. something like that

After you used it you can interact and get teleported to the cellar location.

http://www.frictionalgames.com/forum/thread-21719.html
Evil Awaking Work In Progress!
Hours Spend 472.
04-13-2013, 04:28 PM
Website Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#4
RE: Need help on a script ;)

Create a script area around the door and make sure that it has ItemInteraction enabled. I named the area ScriptArea_1 in the script. You'll also need the change the entry name for the message.
PHP Code: (Select All)
////////////////////////////
// Run first time starting map
void OnStart()
{
    
SetLocalVarInt("CellarDoorOpen"0);
    
    
AddUseItemCallback("""Cellar_Key""ScriptArea_1""OpenCellarDoor1"true);
    
SetEntityPlayerInteractCallback("ScriptArea_1""EnterCellar"false);


void OpenCellarDoor1(string &in asItemstring &in asEntity)
{
    
AddLocalVarInt("CellarDoorOpen"1);
    
PlaySoundAtEntity("""unlock_door""CellarDoor1"0false);
    
RemoveItem("Cellar_Key");
}

void EnterCellar(string &in asEntity)
{
    if(
GetLocalVarInt("CellarDoorOpen") != 1) {
        
SetMessage("Messages""EntryName"0);
        return;
    }
    
    
TeleportPlayer("InCellar");
    
SetMessage("Messages""EnteringTheCellar"5.0);
}

void LeaveCellar(string &in asEntity)
{
    
TeleportPlayer("OutCellar");
}

////////////////////////////
// Run when entering map
void OnEnter()
{    
    
AutoSave();
}

////////////////////////////
// Run when leaving map
void OnLeave()
{



In Ruins [WIP]
04-13-2013, 05:34 PM
Find
VeNoMzTeamHysterical Offline
Member

Posts: 240
Threads: 36
Joined: Dec 2012
Reputation: 3
#5
RE: Need help on a script ;)

(04-13-2013, 05:34 PM)NaxEla Wrote: Create a script area around the door and make sure that it has ItemInteraction enabled. I named the area ScriptArea_1 in the script. You'll also need the change the entry name for the message.
PHP Code: (Select All)
////////////////////////////
// Run first time starting map
void OnStart()
{
    
SetLocalVarInt("CellarDoorOpen"0);
    
    
AddUseItemCallback("""Cellar_Key""ScriptArea_1""OpenCellarDoor1"true);
    
SetEntityPlayerInteractCallback("ScriptArea_1""EnterCellar"false);


void OpenCellarDoor1(string &in asItemstring &in asEntity)
{
    
AddLocalVarInt("CellarDoorOpen"1);
    
PlaySoundAtEntity("""unlock_door""CellarDoor1"0false);
    
RemoveItem("Cellar_Key");
}

void EnterCellar(string &in asEntity)
{
    if(
GetLocalVarInt("CellarDoorOpen") != 1) {
        
SetMessage("Messages""EntryName"0);
        return;
    }
    
    
TeleportPlayer("InCellar");
    
SetMessage("Messages""EnteringTheCellar"5.0);
}

void LeaveCellar(string &in asEntity)
{
    
TeleportPlayer("OutCellar");
}

////////////////////////////
// Run when entering map
void OnEnter()
{    
    
AutoSave();
}

////////////////////////////
// Run when leaving map
void OnLeave()
{


Not working 100% like i want to but thx anyway.
Really nice that the text shown when i interact but.
When i use the key its open but the text is still getting shown.
And also if i interact it again i don't teleport to the cellar Wink

http://www.frictionalgames.com/forum/thread-21719.html
Evil Awaking Work In Progress!
Hours Spend 472.
04-13-2013, 05:44 PM
Website Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#6
RE: Need help on a script ;) [not solved!]

That's strange :\ When I tested it, it worked perfectly

Here's the exact script I used to test it. I also made it so that the text will only show up the first time the player enters the cellar. You'll need to change the names teleport areas and .lang entries.
PHP Code: (Select All)
////////////////////////////
// Run first time starting map
void OnStart()
{
    
SetLocalVarInt("CellarDoorOpen"0);
    
SetLocalVarInt("FirstTimeCellar"1);
    
    
AddUseItemCallback("""Cellar_Key""ScriptArea_1""OpenCellarDoor1"true);
    
SetEntityPlayerInteractCallback("ScriptArea_1""EnterCellar"false);
    
SetEntityPlayerInteractCallback("ScriptArea_2""LeaveCellar"false);


void OpenCellarDoor1(string &in asItemstring &in asEntity)
{
    
SetLocalVarInt("CellarDoorOpen"1);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem);
}

void EnterCellar(string &in asEntity)
{
    if(
GetLocalVarInt("CellarDoorOpen") != 1) {
        
SetMessage("Messages""DoorLocked"0);
        return;
    }
    
    
TeleportPlayer("InsideCellar");
    
    if(
GetLocalVarInt("FirstTimeCellar") == 1) {
        
SetMessage("Messages""EnteringTheCellar"0);
        
SetLocalVarInt("FirstTimeCellar"0);
    }
}

void LeaveCellar(string &in asEntity)
{
    
TeleportPlayer("OutsideCellar");
}

////////////////////////////
// Run when entering map
void OnEnter()
{    
    
AutoSave();
}

////////////////////////////
// Run when leaving map
void OnLeave()
{



In Ruins [WIP]
04-13-2013, 10:44 PM
Find
VeNoMzTeamHysterical Offline
Member

Posts: 240
Threads: 36
Joined: Dec 2012
Reputation: 3
#7
RE: Need help on a script ;) [not solved!]

(04-13-2013, 10:44 PM)NaxEla Wrote: That's strange :\ When I tested it, it worked perfectly

Here's the exact script I used to test it. I also made it so that the text will only show up the first time the player enters the cellar. You'll need to change the names teleport areas and .lang entries.
PHP Code: (Select All)
////////////////////////////
// Run first time starting map
void OnStart()
{
    
SetLocalVarInt("CellarDoorOpen"0);
    
SetLocalVarInt("FirstTimeCellar"1);
    
    
AddUseItemCallback("""Cellar_Key""ScriptArea_1""OpenCellarDoor1"true);
    
SetEntityPlayerInteractCallback("ScriptArea_1""EnterCellar"false);
    
SetEntityPlayerInteractCallback("ScriptArea_2""LeaveCellar"false);


void OpenCellarDoor1(string &in asItemstring &in asEntity)
{
    
SetLocalVarInt("CellarDoorOpen"1);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem);
}

void EnterCellar(string &in asEntity)
{
    if(
GetLocalVarInt("CellarDoorOpen") != 1) {
        
SetMessage("Messages""DoorLocked"0);
        return;
    }
    
    
TeleportPlayer("InsideCellar");
    
    if(
GetLocalVarInt("FirstTimeCellar") == 1) {
        
SetMessage("Messages""EnteringTheCellar"0);
        
SetLocalVarInt("FirstTimeCellar"0);
    }
}

void LeaveCellar(string &in asEntity)
{
    
TeleportPlayer("OutsideCellar");
}

////////////////////////////
// Run when entering map
void OnEnter()
{    
    
AutoSave();
}

////////////////////////////
// Run when leaving map
void OnLeave()
{


I have to add the script area at the door right or hatched whatever its called ;D
Well it works almost the only thing is i cant use the key on it.

Never mind working you just got + repp'd thanks allot Wink

http://www.frictionalgames.com/forum/thread-21719.html
Evil Awaking Work In Progress!
Hours Spend 472.
(This post was last modified: 04-13-2013, 11:23 PM by VeNoMzTeamHysterical.)
04-13-2013, 10:51 PM
Website Find




Users browsing this thread: 1 Guest(s)