Files
LonaRPG-Online-Games/ModScripts/multiplayer/10_cleanup.rb
T
2026-10-29 21:59:06 +04:00

51 lines
1.3 KiB
Ruby

module WebSocket
# Cleanup world objects on map change/disconnect
#--------------------------------------------------------------------------
def self.cleanup_world_objects
begin
@map_drops.keys.each { |did| remove_map_drop(did) }
@map_drops.clear
clear_pickup_inflight
rescue
end
begin
@remote_events.keys.each { |seid| remove_remote_event(seid) }
@remote_events.clear
rescue
end
begin
@net_effects.clear
rescue
end
begin
@npc_owners.clear if @npc_owners
rescue
end
begin
@remote_static_npc_types.clear if @remote_static_npc_types
@static_npc_compatibility.clear if @static_npc_compatibility
rescue
end
end
#--------------------------------------------------------------------------
# Convenience: drop API
#--------------------------------------------------------------------------
def self.net_drop_item(item_type, item_id, qty, x=nil, y=nil, duration=nil)
return unless @connected && @worldsync
x ||= $game_player.x
y ||= $game_player.y
by = (@my_id || 0)
if duration
send_line("drop:#{item_type}:#{item_id.to_i}:#{x.to_i}:#{y.to_i}:#{qty.to_i}:#{by}:#{duration.to_f}")
else
send_line("drop:#{item_type}:#{item_id.to_i}:#{x.to_i}:#{y.to_i}:#{qty.to_i}:#{by}")
end
end
end