playSplitSoundEvent = {}
local playSplitSoundEvent_mt = Class(playSplitSoundEvent, Event)

InitEventClass(playSplitSoundEvent, "playSplitSoundEvent")

function playSplitSoundEvent.emptyNew()  
    local self = Event.new(playSplitSoundEvent_mt)

    return self
end

function playSplitSoundEvent.new(vehicle, state) 
    local self = playSplitSoundEvent.emptyNew()
    self.vehicle = vehicle
	self.state = state
	
    return self
end

function playSplitSoundEvent:readStream(streamId, connection)  
    self.vehicle = NetworkUtil.readNodeObject(streamId)
	self.state = streamReadBool(streamId) 
	
    self:run(connection)  
end

function playSplitSoundEvent:writeStream(streamId, connection)   
	NetworkUtil.writeNodeObject(streamId, self.vehicle)
	streamWriteBool(streamId, self.state )
end

function playSplitSoundEvent:run(connection) 
    self.vehicle:playSplitSound(true)
	
    if not connection:getIsServer() then  
        g_server:broadcastEvent(playSplitSoundEvent.new(self.vehicle), nil, connection, self.object)
    end
end

function playSplitSoundEvent.sendEvent(vehicle, noEventSend)  
    if noEventSend == nil or noEventSend == false then
        if g_server ~= nil then   
            g_server:broadcastEvent(playSplitSoundEvent.new(vehicle), nil, nil, vehicle)
        else 
            g_client:getServerConnection():sendEvent(playSplitSoundEvent.new(vehicle))
        end
    end
end