SetChopperWidth = {};
SetChopperWidth_mt = Class(SetChopperWidth, Event);

InitEventClass(SetChopperWidth, "SetChopperWidth");

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

function SetChopperWidth:new(vehicle, state)
    local self = SetChopperWidth:emptyNew()
    self.vehicle = vehicle;
	self.state = state;
	return self;
end;

function SetChopperWidth:readStream(streamId, connection)
    local id = streamReadInt32(streamId);
	self.state = streamReadString(streamId);
    self.vehicle = networkGetObject(id);
    self:run(connection);
end;

function SetChopperWidth:writeStream(streamId, connection)
    streamWriteInt32(streamId, networkGetObjectId(self.vehicle));	
	streamWriteString(streamId, self.state);
end;

function SetChopperWidth:run(connection)
	--self.vehicle:setdoManualUnload(self.state, true);
	--self.vehicle:changeChopperWidth(self.state, noEventSend)
	if not connection:getIsServer() then
		g_server:broadcastEvent(SetChopperWidth:new(self.vehicle, self.state), nil, connection, self.object);
	end;
end;

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