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!
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#12
RE: Hi, i need help!

(03-27-2014, 02:43 PM)Mudbill Wrote: 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.

I know, but since he is a beginner I wanted to give him the scipt in easiest form Tongue
03-27-2014, 03:55 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)