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
Hi, i need help!
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#11
RE: Hi, i need help!

That is very unnecessary because you now have many duplicate functions that do the exact same.

Since your script uses asEntity and asItem, you can use the same function for all keys and doors. Just add more AddUseItemCallback lines, but point to the same UseKeyOnDoor script.

Like this:
PHP Code: (Select All)
void OnStart()
{
    
AddUseItemCallback("""key1""door1""UseKeyOnDoor"true);
    
AddUseItemCallback("""key2""door2""UseKeyOnDoor"true);
    
AddUseItemCallback("""key3""door3""UseKeyOnDoor"true);
}

void UseKeyOnDoor(string &in asEntitystring &in asItem)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door.snt"asEntity0false);
    
RemoveItem(asItem);


The way this works is that asEntity is replaced with the entity used in the callback that executes this function. If the entity the key is used on is "door1", asEntity will be the same as "door1". If the entity is "door2" instead, asEntity is now "door2" and not "door1" anymore. Same thing with asItem and the key names.

You could shorten this script even more using a for-loop, but seeing as you're a beginner, I don't recommend doing so.

(This post was last modified: 03-27-2014, 02:46 PM by Mudbill.)
03-27-2014, 02:43 PM
Find


Messages In This Thread
Hi, i need help! - by AlluNeesia - 03-27-2014, 11:45 AM
RE: Hi, i need help! - by Romulator - 03-27-2014, 11:55 AM
RE: Hi, i need help! - by AlluNeesia - 03-27-2014, 11:59 AM
RE: Hi, i need help! - by Romulator - 03-27-2014, 12:02 PM
RE: Hi, i need help! - by AlluNeesia - 03-27-2014, 12:04 PM
RE: Hi, i need help! - by Traggey - 03-27-2014, 12:07 PM
RE: Hi, i need help! - by AlluNeesia - 03-27-2014, 12:08 PM
RE: Hi, i need help! - by Traggey - 03-27-2014, 12:22 PM
RE: Hi, i need help! - by Slanderous - 03-27-2014, 01:14 PM
RE: Hi, i need help! - by AlluNeesia - 03-27-2014, 01:49 PM
RE: Hi, i need help! - by Mudbill - 03-27-2014, 02:43 PM
RE: Hi, i need help! - by Slanderous - 03-27-2014, 03:55 PM
RE: Hi, i need help! - by Mudbill - 03-27-2014, 04:05 PM



Users browsing this thread: 1 Guest(s)