/* * Author: Needles * https://steamcommunity.com/profiles/76561198026257137/ */ printl("*** CURRENCY"); ::Currency <- {}; ::Currency.currencyMap <- {}; function Currency::ConfiscateCurrency(player) { local userid = ::Players.GetPlayerUserID(player); ::Currency.currencyMap[userid] <- player.GetCurrency(); player.RemoveCurrency(player.GetCurrency()); } function Currency::RestoreCurrency(player) { local userid = ::Players.GetPlayerUserID(player); if (userid in ::Currency.currencyMap) { player.AddCurrency(::Currency.currencyMap[userid]); ::Currency.currencyMap[userid] = 0; } } function Currency::ConfiscateAll() { for (local i = 1; i <= ::Players.Max(); i++) { local player = PlayerInstanceFromIndex(i); if (player == null) continue; ::Currency.ConfiscateCurrency(player); } } function Currency::RestoreAll() { for (local i = 1; i <= ::Players.Max(); i++) { local player = PlayerInstanceFromIndex(i); if (player == null) continue; ::Currency.RestoreCurrency(player); } } ::Events.GetGlobalEvent(EVENT.WAVE_START).AddListener( function(params) { ::Currency.ConfiscateAll(); } ) ::Events.GetGlobalEvent(EVENT.WAVE_END).AddListener( function(params) { ::Currency.RestoreAll(); } )