EmptyFendt12130NEvent = {};
EmptyFendt12130NEvent_mt = Class(EmptyFendt12130NEvent, Event);

InitEventClass(EmptyFendt12130NEvent, "EmptyFendt12130NEvent");

function EmptyFendt12130NEvent:emptyNew()
    local self = Event:new(EmptyFendt12130NEvent_mt);
    self.className="EmptyFendt12130NEvent";
    return self;
end;

function EmptyFendt12130NEvent:new(vehicle, mode)
    local self = EmptyFendt12130NEvent:emptyNew()
    self.vehicle = vehicle;
	self.mode = mode;
    return self;
end;

function EmptyFendt12130NEvent:readStream(streamId, connection)
    local id = streamReadInt32(streamId);
	self.mode = streamReadBool(streamId);
    self.vehicle = networkGetObject(id);
    self:run(connection);
end;

function EmptyFendt12130NEvent:writeStream(streamId, connection)
    streamWriteInt32(streamId, networkGetObjectId(self.vehicle));
	streamWriteBool(streamId, self.mode);
end;

function EmptyFendt12130NEvent:run(connection)
	self.vehicle:EmptyFendt12130N(self.mode, true);
    if not connection:getIsServer() then
        g_server:broadcastEvent(EmptyFendt12130NEvent:new(self.vehicle, self.mode), nil, connection, self.vehicle);
    end;
end;

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