Jump to content

Script - Não ouvir musica em moto


Recommended Posts

8 hours ago, gabrielcosta said:

aonde posso coloca-lo?


function toggleRadio(player)
	local veh = getPedOccupiedVehicle(player)
	if veh then
		local occupants = getVehicleOccupants(veh)
		local seats = getVehicleMaxPassengers(veh)
		if getVehicleType(veh) == "Bike" or getVehicleType(veh) == "BMX" then return end 
		local playerSeat = getPedOccupiedVehicleSeat(player)
		if playerSeat ~= 0 and playerSeat ~= 1 then
			outputChatBox("You can't switch the radio.", player, 255, 255, 255)
			return
		end

		if g_VehicleList[veh] == nil then
			g_VehicleList[veh] = { }
			g_VehicleList[veh].radio = false
			g_VehicleList[veh].radioStation = defaultRadio
			g_VehicleList[veh].volume = 1.0
		end
		
		if g_VehicleList[veh].radio == false then
			if not get("toggleAntifloodTick") or not get("streamLimit") or not get("radioEnabledIdleTime") then return end

			local settingToggleAntifloodTick = get("toggleAntifloodTick")
			local settingStreamLimit = get("streamLimit")
			local idleTime = get("radioEnabledIdleTime")
			
			if g_VehicleList[veh].lastTick and (getTickCount() - g_VehicleList[veh].lastTick) <= settingToggleAntifloodTick then return end

			if radioStreams >= settingStreamLimit then
				outputChatBox("The limit of streams has reached (" .. settingStreamLimit .. ")", player, 255, 255, 255)
				return
			end
			
			local x, y, z = getElementPosition(veh)
			g_VehicleList[veh].radio = true
			g_VehicleList[veh].lastTick = getTickCount()
			g_VehicleList[veh].turnedOnBy = getPlayerName(player)
			g_VehicleList[veh].radioMarker = createMarker(x, y, z, "corona", 0.05, 255, 0, 0)
			attachElements(g_VehicleList[veh].radioMarker, veh)
			g_VehicleList[veh].idleTimer = setTimer(radioIdleTimer, idleTime, 0, veh)
			
			radioStreams = radioStreams + 1
			outputServerLog(getPlayerName(player) .. " has turned the radio on in his vehicle (streams: " .. radioStreams .. ")")

			for seat = 0, seats do
				local occupant = occupants[seat]
				if occupant and getElementType(occupant) == "player" then
					triggerClientEvent("onServerToggleRadio", root, true, g_VehicleList[veh].radioStation, veh, g_VehicleList[veh].volume)
					
					local r, g, b = getPlayerNametagColor(player)
					colorHex = string.format("%02X%02X%02X", r, g, b)
					outputChatBox("#" .. colorHex .. "" .. getPlayerName(player) .. " #696969Rádio: [#00ff00ON#696969]", occupant, 0, 0, 0, true)
				end
			end
		else		
			g_VehicleList[veh].radio = false
			destroyElement(g_VehicleList[veh].radioMarker)
			killTimer(g_VehicleList[veh].idleTimer)
			
			radioStreams = radioStreams - 1
			outputServerLog(getPlayerName(player) .. " has turned the radio off in his vehicle (streams: " .. radioStreams .. ")")
			
			for seat = 0, seats do
				local occupant = occupants[seat]
				if occupant and getElementType(occupant) == "player" then
					triggerClientEvent("onServerToggleRadio", root, false, nil, veh, g_VehicleList[veh].volume)
					
					local r, g, b = getPlayerNametagColor(player)
					colorHex = string.format("%02X%02X%02X", r, g, b)
					outputChatBox("#" .. colorHex .. "" .. getPlayerName(player) .. " #696969Rádio: [#ff0000OFF#696969]", occupant, 0, 0, 0, true)
				end
			end
		end
	end
end

 

 

Peguei a função de um script de rádio na internet, mas creio que o seu deve ser parecido... 

Coloque esta verificação na função onde liga a rádio...

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...