Kainzor
Junior Member
Posts: 6
Threads: 2
Joined: Dec 2011
Reputation:
0
|
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 |
|
flamez3
Posting Freak
Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation:
57
|
RE: 2 keys script
Im assuming that you want 2 keys to make a door unlocked? If so:
void OnStart() { SetLocalVarInt("Var1", 0); AddUseItemCallback("", "bedroomkey_1", "mansion_1", "UsedKeyOnDoor1", true); AddUseItemCallback("", "bedroomkey_2", "mansion_1", "UsedKeyOnDoor2", true); }
void UsedKeyOnDoor1(string &in asItem, string &in asEntity) { RemoveItem("bedroomkey_1"); AddLocalVarInt("Var1", 1);void func_on();} [align=-webkit-auto]void UsedKeyOnDoor2(string &in asItem, string &in asEntity) { RemoveItem("bedroomkey_1");
AddLocalVarInt("Var1", 1); void func_on(); }
void func_on() { if(GetLocalVarInt("Var1") == 2) { SetSwingDoorLocked("mansion_1", false, true); PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
} }
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 |
|
Kainzor
Junior Member
Posts: 6
Threads: 2
Joined: Dec 2011
Reputation:
0
|
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 |
|
flamez3
Posting Freak
Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation:
57
|
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:
void OnStart() { AddUseItemCallback("", "bedroomkey_1", "mansion_1", "UsedKeyOnDoor1", true); AddUseItemCallback("", "bedroomkey_2", "mansion_2", "UsedKeyOnDoor2", true); }
void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_1", false, true); PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false); RemoveItem("bedroomkey_1"); }
void UsedKeyOnDoor2(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_2", false, true); PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false); 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 |
|
Kainzor
Junior Member
Posts: 6
Threads: 2
Joined: Dec 2011
Reputation:
0
|
RE: 2 keys script
alright
that worked thanks alot
(This post was last modified: 12-06-2011, 05:22 PM by Kainzor.)
|
|
12-06-2011, 05:04 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: 2 keys script
It'd be more efficient if you had one function deal with all swing doors:
void OnStart() { AddUseItemCallback("", "bedroomkey_1", "mansion_1", "UsedKeyOnDoor", true); AddUseItemCallback("", "bedroomkey_2", "mansion_2", "UsedKeyOnDoor", true); }
void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door", asEntity, 0, false); RemoveItem(asItem); }
|
|
12-06-2011, 05:24 PM |
|
flamez3
Posting Freak
Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation:
57
|
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:
void OnStart() { AddUseItemCallback("", "bedroomkey_1", "mansion_1", "UsedKeyOnDoor", true); AddUseItemCallback("", "bedroomkey_2", "mansion_2", "UsedKeyOnDoor", true); }
void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door", asEntity, 0, false); RemoveItem(asItem); }
Wow, didn't know about that, thanks.
|
|
12-06-2011, 05:32 PM |
|
Dobbydoo
Member
Posts: 50
Threads: 6
Joined: Aug 2011
Reputation:
0
|
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:
void OnStart() { AddUseItemCallback("", "bedroomkey_1", "mansion_1", "UsedKeyOnDoor", true); AddUseItemCallback("", "bedroomkey_2", "mansion_2", "UsedKeyOnDoor", true); }
void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door", asEntity, 0, false); RemoveItem(asItem); }
But wouldn't that just make both doors unlock when using one key? :S
|
|
12-07-2011, 03:23 PM |
|
flamez3
Posting Freak
Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation:
57
|
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:
void OnStart() { AddUseItemCallback("", "bedroomkey_1", "mansion_1", "UsedKeyOnDoor", true); AddUseItemCallback("", "bedroomkey_2", "mansion_2", "UsedKeyOnDoor", true); }
void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door", asEntity, 0, false); 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 |
|
Dobbydoo
Member
Posts: 50
Threads: 6
Joined: Aug 2011
Reputation:
0
|
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:
void OnStart() { AddUseItemCallback("", "bedroomkey_1", "mansion_1", "UsedKeyOnDoor", true); AddUseItemCallback("", "bedroomkey_2", "mansion_2", "UsedKeyOnDoor", true); }
void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door", asEntity, 0, false); 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 |
|
|