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
Request How to make several keys in on map
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#6
RE: How to make several keys in on map

////////////////////////////
// Run when entering map
void OnEnter()
{
   AddUseItemCallback("", "chamberkey", "chamberdoor", "FUNCTION1", true);
   AddUseItemCallback("", "cellarkey", "cellerdoor", "FUNCTION2", true);
   AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
   AddEntityCollideCallback("Player" , "doorbreak" , "MonsterFunc1" , true , 1);    
   AddEntityCollideCallback("Player", "doorslamtrigger1", "Func01", true, 1);    
}
void FUNCTION1(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("chamberdoor", false, true);
    PlaySoundAtEntity("", "unlock_door", "chamberdoor", 0, false);
    RemoveItem("chamberkey");
    SetSwingDoorClosed("doorslam", true, true);
    SetSwingDoorClosed("doorslam2", true, true);
}
void FUNCTION2(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("cellerdoor", false, true);
    PlaySoundAtEntity("", "unlock_door", "cellerdoor", 0, false);
    RemoveItem("cellarkey");
}

void OnEnter()
{
}

void OnLeave
{
}
Right, so this code should work for you. I'll let you know what you missed
1) Your syntax was incorrect for your functions. For AddUseItemCallback, you need to end your callback function with (string &in asItem, string &in asEntity). The wikipage shows the correct syntax for callback functions, as well as timers and the like. They're bolded underneath the function.
2) If you want two separate doors to unlock, you need to name the unlock functions accordingly. I changed it up to Function1 and Function2. Of course, you could also use a subroutine, but I left it simple.
3) You forgot to put closing quotation marks around cellarkey in Function2, as well as spelling it differently.
4) All .hps files need to have a OnEnter and OnLeave function. You can leave these empty if you wish, as they only perform functions when the player enters or leaves the map


08-17-2011, 06:49 PM
Find


Messages In This Thread
How to make several keys in on map - by Khan - 08-17-2011, 03:51 AM
RE: How to make several keys in on map - by Khan - 08-17-2011, 04:27 AM
RE: How to make several keys in on map - by Khan - 08-17-2011, 01:16 PM
RE: How to make several keys in on map - by Obliviator27 - 08-17-2011, 06:49 PM
RE: How to make several keys in on map - by Khan - 08-17-2011, 09:01 PM



Users browsing this thread: 1 Guest(s)