Frictional Games Forum (read-only)

Full Version: Scripting Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(05-20-2013, 10:01 PM)Bridge Wrote: [ -> ]Did you see what Tomato Cat said? You're calling a function that doesn't exist.

Code:
AddUseItemCallback("", "Key2", "Door2", "UsedKeyOnDoor", true);

Should be:

Code:
AddUseItemCallback("", "Key2", "Door2", "UsedKeyonDoor", true);

No, it shouldn't. Another function already exists!
Here's how it should be.
Code:
void OnStart()
{
AddUseItemCallback("", "Key", "Mansion_door", "UsedKeyonDoor", true);
AddUseItemCallback("", "Key2", "Door2", "UsedKeyOnDoor", true);
}

void UsedKeyonDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Mansion_door", false, true);
PlaySoundAtEntity("", "unlock_door", "Mansion", 0, false);
RemoveItem("Key");
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door2", false, true);
PlaySoundAtEntity("", "unlock_door", "Door2", 0, false);
RemoveItem("Key2");
}
Also are you saying that the door is NOT locked? Make sure the "Locked" Box is checked in the level editor when you select the door under the entity tab.
Thanks to all of you it got fixed after JustAnotherPlayer's script.
What was ultimately the problem?

Also, I don't recommend giving your functions names that are difficult to distinguish from one another.

Use something like "UsedKeyOnDoor" & "UsedKeyOnDoor2" rather than "UsedKeyOnDoor" and "UsedKeyonDoor".
(05-21-2013, 05:55 AM)Tomato Cat Wrote: [ -> ]Use something like "UsedKeyOnDoor" & "UsedKeyOnDoor2" rather than "UsedKeyOnDoor" and "UsedKeyonDoor".

Or he should learn about parameters and have only one function handle every key-door combination.
Thanks all about you,now i know about parameters and how to get doors locked.I am creating one now.
(05-21-2013, 11:48 AM)Your Computer Wrote: [ -> ]Or he should learn about parameters and have only one function handle every key-door combination.

True, but that might be a bit confusing for a beginner.
Pages: 1 2