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
2 keys script
Kainzor Offline
Junior Member

Posts: 6
Threads: 2
Joined: Dec 2011
Reputation: 0
#1
2 keys script

hey im havin some problem with doin 2 keys script i know im doin somthing wrong but this is the first key script that worked fine
---------

void OnStart()
{
AddUseItemCallback("", "bedroomkey_1", "mansion_1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("bedroomkey_1");
------
but where do i put the 2nd key script and how do i script it..... any info can help me
thank you for reading this
12-06-2011, 03:56 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#2
RE: 2 keys script

Im assuming that you want 2 keys to make a door unlocked? If so:

PHP Code: (Select All)
void OnStart()
{
    
SetLocalVarInt("Var1"0);
    
AddUseItemCallback("""bedroomkey_1""mansion_1""UsedKeyOnDoor1"true);
    
AddUseItemCallback("""bedroomkey_2""mansion_1""UsedKeyOnDoor2"true);
}

void UsedKeyOnDoor1(string &in asItemstring &in asEntity)
{
RemoveItem("bedroomkey_1");
AddLocalVarInt("Var1"1);void func_on();}
[
align=-webkit-auto]void UsedKeyOnDoor2(string &in asItemstring &in asEntity)
{
RemoveItem("bedroomkey_1");

AddLocalVarInt("Var1"1);
void func_on();
}


void func_on()
{
if(
GetLocalVarInt("Var1") == 2)
{
SetSwingDoorLocked("mansion_1"falsetrue);
PlaySoundAtEntity("""unlock_door""mansion_1"0false);

}



If you need me to explain what that script is and why it works just ask ^^

(This post was last modified: 12-06-2011, 04:06 PM by flamez3.)
12-06-2011, 04:04 PM
Find
Kainzor Offline
Junior Member

Posts: 6
Threads: 2
Joined: Dec 2011
Reputation: 0
#3
RE: 2 keys script

no i mean....not same door.... how do you script with 1 key ea door by havin 2 keys like.... i got mansion_1 and mansion_2, i got key_1 and key_2, i know how to script the first key but there's always and error whn i do the 2nd 1 ..... i know my scripting must be wrong but i cant find it.... so i deleted it and tried have help on this website
12-06-2011, 04:33 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#4
RE: 2 keys script

(12-06-2011, 04:33 PM)Kainzor Wrote: no i mean....not same door.... how do you script with 1 key ea door by havin 2 keys like.... i got mansion_1 and mansion_2, i got key_1 and key_2, i know how to script the first key but there's always and error whn i do the 2nd 1 ..... i know my scripting must be wrong but i cant find it.... so i deleted it and tried have help on this website
Okay do this:

PHP Code: (Select All)
void OnStart()
{
AddUseItemCallback("""bedroomkey_1""mansion_1""UsedKeyOnDoor1"true);
AddUseItemCallback("""bedroomkey_2""mansion_2""UsedKeyOnDoor2"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked("mansion_1"falsetrue);
PlaySoundAtEntity("""unlock_door""mansion_1"0false);
RemoveItem("bedroomkey_1");
}

void UsedKeyOnDoor2(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked("mansion_2"falsetrue);
PlaySoundAtEntity("""unlock_door""mansion_1"0false);
RemoveItem("bedroomkey_2");



Also rename the doors and keys to the right names. And you can always post your script int the forums to get some insight on how to correct the problem. :3

(This post was last modified: 12-06-2011, 04:41 PM by flamez3.)
12-06-2011, 04:39 PM
Find
Kainzor Offline
Junior Member

Posts: 6
Threads: 2
Joined: Dec 2011
Reputation: 0
#5
RE: 2 keys script

alright

that worked thanks alot Big Grin
(This post was last modified: 12-06-2011, 05:22 PM by Kainzor.)
12-06-2011, 05:04 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#6
RE: 2 keys script

It'd be more efficient if you had one function deal with all swing doors:

PHP Code: (Select All)
void OnStart()
{
    
AddUseItemCallback("""bedroomkey_1""mansion_1""UsedKeyOnDoor"true);
    
AddUseItemCallback("""bedroomkey_2""mansion_2""UsedKeyOnDoor"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem);


Tutorials: From Noob to Pro
12-06-2011, 05:24 PM
Website Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#7
RE: 2 keys script

(12-06-2011, 05:24 PM)Your Computer Wrote: It'd be more efficient if you had one function deal with all swing doors:

PHP Code: (Select All)
void OnStart()
{
    
AddUseItemCallback("""bedroomkey_1""mansion_1""UsedKeyOnDoor"true);
    
AddUseItemCallback("""bedroomkey_2""mansion_2""UsedKeyOnDoor"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem);

Wow, didn't know about that, thanks.

12-06-2011, 05:32 PM
Find
Dobbydoo Offline
Member

Posts: 50
Threads: 6
Joined: Aug 2011
Reputation: 0
#8
RE: 2 keys script

(12-06-2011, 05:24 PM)Your Computer Wrote: It'd be more efficient if you had one function deal with all swing doors:

PHP Code: (Select All)
void OnStart()
{
    
AddUseItemCallback("""bedroomkey_1""mansion_1""UsedKeyOnDoor"true);
    
AddUseItemCallback("""bedroomkey_2""mansion_2""UsedKeyOnDoor"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem);

But wouldn't that just make both doors unlock when using one key? :S

12-07-2011, 03:23 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#9
RE: 2 keys script

(12-07-2011, 03:23 PM)Dobbydoo Wrote:
(12-06-2011, 05:24 PM)Your Computer Wrote: It'd be more efficient if you had one function deal with all swing doors:

PHP Code: (Select All)
void OnStart()
{
    
AddUseItemCallback("""bedroomkey_1""mansion_1""UsedKeyOnDoor"true);
    
AddUseItemCallback("""bedroomkey_2""mansion_2""UsedKeyOnDoor"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem);

But wouldn't that just make both doors unlock when using one key? :S
The asEntity makes it so whichever entity it's linked in the void OnStart block will be the one being unlocked.

12-07-2011, 03:25 PM
Find
Dobbydoo Offline
Member

Posts: 50
Threads: 6
Joined: Aug 2011
Reputation: 0
#10
RE: 2 keys script

(12-07-2011, 03:25 PM)flamez3 Wrote:
(12-07-2011, 03:23 PM)Dobbydoo Wrote:
(12-06-2011, 05:24 PM)Your Computer Wrote: It'd be more efficient if you had one function deal with all swing doors:

PHP Code: (Select All)
void OnStart()
{
    
AddUseItemCallback("""bedroomkey_1""mansion_1""UsedKeyOnDoor"true);
    
AddUseItemCallback("""bedroomkey_2""mansion_2""UsedKeyOnDoor"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem);

But wouldn't that just make both doors unlock when using one key? :S
The asEntity makes it so whichever entity it's linked in the void OnStart block will be the one being unlocked.
Oh, of course! Stupid me *facepalm*

12-07-2011, 03:32 PM
Find




Users browsing this thread: 1 Guest(s)