UnloadFendt12130NEvent = {};
UnloadFendt12130NEvent_mt = Class(UnloadFendt12130NEvent, Event);

InitEventClass(UnloadFendt12130NEvent, "UnloadFendt12130NEvent");

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

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

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

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

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

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