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 Key Unlock Door script won't work :(
Rowzter Offline
Junior Member

Posts: 44
Threads: 12
Joined: Oct 2012
Reputation: 3
#1
Key Unlock Door script won't work :(

Hello everyone, i am new here on this forum an i need some help with my script.
PS: If this thread is on the wrong board then just move it and i know this is a common problem

i want my key to unlock "the door", But as everyone else i get "could't not use item this way" i think its called, I have checked many tutorials and read some threads here on the forum and tried their way, but it wont work =(

Here's my script:

void OnStart()
{
AddUseItemCallback("", "basementkey_1", "basementdoor_1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door","basementdoor_1", 0.0f, false);
RemoveItem(basementkey_1);
}


Now, if you find whats wrong or if there are some errors then please help me, That would mean alot
i have checked so the names are the same and so, and i also tried to change the names of the door and key and see if that worked, but no positive feedback i got from it Sad

sorry for my bad english, i get nervous when writing in english :O
10-08-2012, 10:00 PM
Find
craven7 Offline
Member

Posts: 50
Threads: 8
Joined: Aug 2012
Reputation: 1
#2
RE: Key Unlock Door script won't work :(

If it says "could not use item this way", then the problem is definitly in this line, otherwise you wouldn't get this message:

AddUseItemCallback("", "basementkey_1", "basementdoor_1", "UsedKeyOnDoor", true);


Also you might want to replace
PlaySoundAtEntity("", "unlock_door","basementdoor_1", 0.0f, false);
RemoveItem(basementkey_1);
with
PlaySoundAtEntity("", "unlock_door","asEntity", 0.0f, false);
RemoveItem(asItem);
. This won't solve your problem, but now you can use this method for every key-door callback.
10-08-2012, 10:16 PM
Find
4WalledKid Offline
Member

Posts: 107
Threads: 23
Joined: Oct 2012
Reputation: 1
#3
RE: Key Unlock Door script won't work :(

You didn't specify the door you want to unlock with the key in
SetSwingDoorLocked(asEntity, false, true);

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{ SetSwingDoorLocked("basementdoor_1", false, true);
   PlaySoundAtEntity("", "unlock_door","basementdoor_1", 0.0f, false);
   RemoveItem(basementkey_1);
}

Let me know if it worked!

[Image: 4walledkidbanner_zps1514b7f6.png]
(This post was last modified: 10-08-2012, 11:03 PM by 4WalledKid.)
10-08-2012, 10:55 PM
Website Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: Key Unlock Door script won't work :(

(10-08-2012, 10:55 PM)4WalledKid Wrote: You didn't specify the door you want to unlock with the key in
SetSwingDoorLocked(asEntity, false, true);

That would be how you specify it, given the parameters. craven7 pointed out one of the errors in the script, but also committed another (i.e. placing asEntity within quotation marks for PlaySoundAtEntity). However, the fact that the user is still able to load the map implies that the script is named differently than the map. The user would have received an undeclared variable error, unless the operating system is giving the game the wrong file.

Tutorials: From Noob to Pro
10-09-2012, 06:39 AM
Website Find
Rowzter Offline
Junior Member

Posts: 44
Threads: 12
Joined: Oct 2012
Reputation: 3
#5
RE: Key Unlock Door script won't work :(

Well, Thx for the help anyway, it just don't want to work Sad .

Whatever, i skip those locked doors, but are there some other alternatives instead of unlocking door with key? Tongue


And i have a new question, i want a grunt to spawn when i pick up a health potion and i added som pathnodes i think they called, But is this scriptcode right?:


void OnStart()
{
SetEntityPlayerInteractCallback("potion_health_2", "ActivateMonster", true);

}






void ActivateMonster(string &in item)
{
SetEntityActivate("basementgrunt_1", true);
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_1", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_2", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_3", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_4", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_5", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_6", 0,"idle");
}

void Onstart()
{
CallBackFunction ("Syntaxfeeble", true);



the syntaxfeeble have i never spotted before? :O
(This post was last modified: 10-09-2012, 07:26 PM by Rowzter.)
10-09-2012, 07:26 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#6
RE: Key Unlock Door script won't work :(

First, let me show you this.

(10-09-2012, 07:26 PM)Rowzter Wrote: void OnStart()
{
SetEntityPlayerInteractCallback("potion_health_2", "ActivateMonster", true);

}






void ActivateMonster(string &in item)
{
SetEntityActivate("basementgrunt_1", true);
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_1", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_2", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_3", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_4", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_5", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_6", 0,"idle");
}

void OnEnter()
{
CallBackFunction ("Syntaxfeeble", true);
}

"CallBackFunction"? Don't think something like that exists.

For scripts, go to the Script Functions Page .

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
(This post was last modified: 10-09-2012, 07:30 PM by Robby.)
10-09-2012, 07:29 PM
Website Find
Rowzter Offline
Junior Member

Posts: 44
Threads: 12
Joined: Oct 2012
Reputation: 3
#7
RE: Key Unlock Door script won't work :(

Did some changes now, but it still don't work, i checked the wiki and everything.


void OnStart()
{


SetEntityPlayerInteractCallback("potion_health_2", "ActivateMonster", true);

}



SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
}
void OnEnter()
{



}


void OnLeave()
{
10-10-2012, 07:34 AM
Find
Dutton Offline
Member

Posts: 121
Threads: 3
Joined: Apr 2012
Reputation: 2
#8
RE: Key Unlock Door script won't work :(

you forgot to start your void ActivateMonster(String &in Item)

[Image: 15isy6C]
10-10-2012, 07:51 AM
Find
Rowzter Offline
Junior Member

Posts: 44
Threads: 12
Joined: Oct 2012
Reputation: 3
#9
RE: Key Unlock Door script won't work :(

damn, if someone could correct my scripts and then post em here so i can use them, i tried all solutions here but it won't work, I doublechecked everything but nothing is working Sad
10-10-2012, 08:22 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#10
RE: Key Unlock Door script won't work :(

Errr... it think it should be:

void OnStart()

{

SetEntityPlayerInteractCallback("potion_health_2", "ActivateMonster", true);
}



void ActivateMonster (string &in asEntity);

{

SetEntityActive("servant_grunt_1", true);

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");

}

void OnEnter()

{







}





void OnLeave()

{
            

}

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
(This post was last modified: 10-10-2012, 08:34 PM by The chaser.)
10-10-2012, 08:33 PM
Find




Users browsing this thread: 1 Guest(s)