Locking things at certain times of day
#1
Posté 16 octobre 2013 - 04:06
I'm trying to get doors lock at night, and open again in the morning, so far I haven't been able to however, not sure why. I tried making a heartbeat script for the doors
void main()
{
object oSelf = OBJECT_SELF;
// If it is night. if ( GetIsNight() ) { SetLocked(oSelf, TRUE); SetLockKeyRequired(oSelf); SetLockKeyTag(oSelf, "jer_masterkey"); SetLockLockable(oSelf, FALSE); } else { SetLocked(oSelf, FALSE); }}
So this doesn't work. I tried to make it so it locks at night, "OnFailedtoOpen" has a line which does work, that opens the door if it's daytime and doesn't if it's night.
Any great ideas ?
#2
Posté 16 octobre 2013 - 05:36
Modifié par HipMaestro, 16 octobre 2013 - 05:41 .
#3
Posté 16 octobre 2013 - 07:29
#4
Posté 16 octobre 2013 - 08:12
#5
Posté 16 octobre 2013 - 09:05
void main()
{
object oDoor1 = GetObjectByTag("DOOR_TAG_HERE");
if (GetIsDusk() || GetIsNight())
{
AssignCommand(oDoor1, SetLocked(oDoor1, TRUE));
}
}
The above script works when using the TAG of the particular door. Not sure what all that other stuff is with those FALSE and TRUE. Perhaps it does the same thing, but I've always liked spelling things out in a script to fully understand it since I'm not a script master myself.
Perhaps that will get you going in the direction.
Additionally, I'd rather just put everything in the ModuleHeartBeat script, and close everything at the required time all at once, rather than firing scripts for every individual door.
Another option, if you don't want to go that route, is to lock all doors OnEnter of the specified area and avoid the heartbeat altogether. Then doors only lock/open when the area is entered.
FP!
Modifié par Fester Pot, 16 octobre 2013 - 09:07 .
#6
Posté 16 octobre 2013 - 09:37
Also, I did test at dusk, at night and waited till dawn, it doesn't lock
#7
Posté 16 octobre 2013 - 10:08
This is why FP's suggestion to run that off the module heartbeat is a good idea. Instead of 100 scripts each checking the time of day every six seconds, the module can check it once and then, if it's night, update all the doors (and it's probably best to lock the doors once when the time of day changes rather than repeatedly every six seconds).
Also, while the module heartbeat should always fire, server load can cause NPC, placeable, and door heartbeats to lose priority, either firing less often or not at all.
Modifié par Squatting Monk, 16 octobre 2013 - 10:37 .
#8
Posté 16 octobre 2013 - 10:11
#9
Posté 17 octobre 2013 - 09:36
Squatting: Yep, I realized that too when I thought about it. The thing is though, that if there's many different scripts that do basicly the same thing, firstly it atleast crowds the already large list of scripts, and second it might produce other results of unwanted type. Of the latter I'm not sure.
The module scripts are unaccessible to me, otherwise it'd be a good idea. This project I'm doing now, is for another server, and the module scripts are handled by another fellow, so I'll have to work without using the module scripts.
#10
Posté 17 octobre 2013 - 08:27
Just set the door to say something like, "This door is locked for the night."JerrodAmolyan wrote...
I might just go with Kalbaern's "suggestion" it was something that I thought about already, but some players just see a locked door and think it's another key required barricade. BUT that's their loss I guess.
Absolutely. Genericize scripts wherever it's practical. It's easier on the builder, decreases module size, and can improve the performance of the built-in script caching.Squatting: Yep, I realized that too when I thought about it. The thing is though, that if there's many different scripts that do basicly the same thing, firstly it atleast crowds the already large list of scripts
#11
Posté 18 octobre 2013 - 07:57
Problem is, that usually when there's a locked door to a normal looking house, the players just ignore it because typically it's just a filler for the holes in the walls
WELL Like I said, their loss.
Now this thing works, not as I first wanted, but this solution to have the door lock and unlock on fail to open and so is maybe better, since it doesn't now have a heartbeat at all.





Retour en haut







