_Knightmare_ wrote...
Maybe run it off the area heartbeat. Have it set a variable on area when a PC enters area, check for variable on heartbeat, if none, run clean up script. Heartbeat scripts run on an area even if there is no PC located there. Might be too taxing on the system though. Maybe have it set an "Area_Cleaned" variable right after the clean-up script finishes. If either Pc is in area, or area has already been cleaned, end script. Just a thought.
Running a onServerHeartBeat would work as well.
Run Script
Loop through players,
Store a LocalObject relating to the player (the object being the area they are in) - Store this on the server
Loop through each of those locally stored objects, and if the player that the area is stored, in relation to, is not in the server, then we can assume that the area has been left, via onClientLeave.
eg
I enter an area
Heartbeat script finds me
Stores the area I am in, on the server as Baaleos_area (the value being the area object)
OnClientLeave function should be able to get your PCPlayerName, which would be enough to make this work.
Just Use the PCPlayerName to get the <PlayerName>_area object that was stored on the server, and then fire the cleanup script on that area.
Note - It might be better to make a Pseudo HB for this, instead of a Server HB,
You can Control the Rate of Fire etc, and overhead more accurately with Pseudo's.
If it were me, I would integrate nwnx_system with it, and have the Rate of Fire decrease as the cpu usage increases, and increase the rate of fire, if there is lots of cpu power to spare.
Other factors to think of are
1. Number of players. If we are talking about 4 players, then you could have this script firing every 1 second without much degradation. If however talking about 60 players, then you might want to increase the delay between beats to about 6 seconds. (More players, means more lines of code being executed, and nwserver being single threaded, a Longer Script will cause freezes and lock ups if they are not handled safely)