// EventScripts corelib v0.1 by Mattie // This library is used and shared by other scripts do not remove. block load { es_setinfo es_corelib_version 0.1 } block unload { es_setinfo es_corelib_version 0 } // block to increase reference count for eventscripts_noisy (and enable it) // if all scripts use this then you can safely load/unload // noisy scripts in any order block noisy_on { if (server_var(eventscripts_noisy) > 1) do { if (server_var(noisy_refcount) > 0) do { // increase the reference count because // we're not the only one using noisy es_xmath noisy_refcount + 1 es_log Noisy already on: increased noisy_refcount to server_var(noisy_refcount) . } else do { // start the reference count at 2 // since someone else didn't increment it // but turned noisy on anyway. Bad people. es_setinfo noisy_refcount 2 es_log Noisy already on: started noisy_refcount at server_var(noisy_refcount) . } } else do { if (server_var(noisy_refcount) > 0) do { // ERROR: You should never have noisy off when // the refcount is higher than 0! Who did that? es_log Warning: eventscripts_noisy was OFF, but it's refcount was server_var(noisy_refcount) es_setinfo eventscripts_noisy 1 es_xmath noisy_refcount + 1 es_log Noisy on: increased noisy_refcount to server_var(noisy_refcount) . } else do { // no one was here before us, start the procedure es_setinfo noisy_refcount 1 es_setinfo eventscripts_noisy 1 es_log Noisy on: started noisy_refcount at server_var(noisy_refcount) . } } } // block to reduce reference count for eventscripts_noisy (and disable it if needed) // if all scripts use this then you can safely load/unload // noisy scripts in any order block noisy_off { if (server_var(noisy_refcount) > 0) do { // decrease the reference count es_xmath noisy_refcount - 1 if (server_var(noisy_refcount) > 0) do { es_log Noisy stays on: decreased noisy_refcount to server_var(noisy_refcount) . } else do { // everyone is done with noisy // we can disable it es_setinfo eventscripts_noisy 0 es_log Noisy off: noisy_refcount dropped to server_var(noisy_refcount) . } } else do { es_log Warning: eventscripts_noisy refcount has been messed-up! Bad script somewhere. } }