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
Silly scripting
GoDl1Kelol Offline
Member

Posts: 51
Threads: 7
Joined: Sep 2010
Reputation: 0
#1
Sad  Silly scripting

Okay, I've been trying to get a key to open a door for a century, here's my script


void OnStart()
{
AddUseItemCallback("", "keyfordoor", "mansion_2", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("keyfordoor", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_2", 0, false);
RemoveItem("keyfordoor");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster", true);
ShowEnemyPlayerPosition("monster");
}

I entered it many times and it didn't work and now all of a sudden it shows up with an error 12:13 ERR: keyfordoor not declared
I could really use some help for this
08-19-2011, 04:38 PM
Find
Rapture Offline
Posting Freak

Posts: 1,078
Threads: 79
Joined: May 2011
Reputation: 30
#2
RE: Silly scripting

Is "keyfordoor" the name of the key? I would normally leave it its default name.

void OnStart()
{
AddUseItemCallback("", "keyfordoor", "mansion_2", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("keyfordoor", "OnPickup");
}
Get rid of SetEntityCallbackFunc("keyfordoor", "OnPickup"); "keyfordoor" should go into the Key's Callbackfunc in the level editor.

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_2", 0, false);
RemoveItem("keyfordoor");
}
Replace string &in asItem, string &in asEntity with string &in entity, string &in type

void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster", true);
ShowEnemyPlayerPosition("monster");
}
Replace string &in asEntity, string &in type with string &in entity, string &in type


That should make it work.

08-19-2011, 06:08 PM
Find
GoDl1Kelol Offline
Member

Posts: 51
Threads: 7
Joined: Sep 2010
Reputation: 0
#3
RE: Silly scripting

That's weird, I changed the name of the key everywhere and I still get the same error Can't load script file...: Keyfordoor not declared

EDIT:
I removed the script file too and tried running it like that and it still says it...wat
EDIT:
Okay now it's normal, and the door just opened but the monster didn't spawn, lemme see my stuff
EDIT:
I just moved these: up with the other ones and it worked Big Grin
SetEntityActive("monster", true);
ShowEnemyPlayerPosition("monster");
(This post was last modified: 08-19-2011, 07:43 PM by GoDl1Kelol.)
08-19-2011, 07:24 PM
Find




Users browsing this thread: 1 Guest(s)