Nerses Posted June 26, 2015 Share Posted June 26, 2015 Guys. That is the problem. There is a script of a policeman. The essence of the police is that when he found the offender must press M and bring the offender to offer so surrendered or ran away. But this cursor is not displayed after you come out of the machine. I started to turn off scripts. And found a script which prevents to include the cursor after I got out of the car. This audio system. How can I fix this bug? Here's the script itself audio: server_player local root = getRootElement() --------------------------------------------------------------------------- -- -- gets -- --------------------------------------------------------------------------- -- get string or default function getString(var,default) local result = get(var) if not result then return default end return tostring(result) end -- get number or default function getNumber(var,default) local result = get(var) if not result then return default end return tonumber(result) end -- get true or false or default function getBool(var,default) local result = get(var) if not result then return default end return result == 'true' end local settings = { soundMinDistance = getNumber('radio3d.sound3d_min_distance', -- s8) -->, soundMaxDistance = getNumber('radio3d.sound3d_max_distance', 15), soundOutsideVolumeInVehicle = getNumber('radio3d.sound3d_outside_volume_vehicle', 50) / 100, soundOutsideVolumeOnFoot = getNumber('radio3d.sound3d_outside_volume_foot', 70) / 100, soundOwnVehicleVolume = getNumber('radio3d.sound3d_own_vehicle_volume', 100) / 100, soundRadioOffOnVehicleExit = getBool('radio3d.sound3d_radio_off_on_vehicle_exit', false), soundRadioOffOnBlowUp = getBool('radio3d.sound3d_radio_off_on_blow_up', true), playListTitle = getString('radio3d.playlist_title', "Choose Song"), closePlaylistDesc = getString('radio3d.close_playlist_desc', "Press 0 to close the playlist"), noMusic = getString('radio3d.no_music', "No music"), placeholder = getString('radio3d.placeholder', "Placeholder"), loop = getBool('radio3d.loop', true), closeOnSelection = getBool('radio3d.close_on_selection', true), playlistCloseDelay = getNumber('radio3d.playlist_close_delay', 500) } addEvent("onRadio3dClientScriptLoaded", true) addEventHandler("onRadio3dClientScriptLoaded", getRootElement(), function() -- outputChatBox("settings: "..tostring(settings)) triggerClientEvent(source, "onSendRadio3dSettings", getRootElement(), settings) end ) -- function removeSongOnExplode(theVehicle) -- setElementData(theVehicle, "tempdata.originalnick", sPlayerNickname) -- end -- addEventHandler("onVehicleExplode", getRootElement(), removeSongOnExplode) function removeAllSounds() local vehicles = getElementsByType("vehicle") for theKey, theVehicle in ipairs(vehicles) do -- sometimes real elements are already deleted (i.e onGamemodeMapStop), so extra check if isElement(theVehicle) then local songId = getElementData(theVehicle, "song_id") -- if song is attached to element (song_id is set, not false (or nil)) if songId then setElementData(theVehicle, "song_id", false) setElementData(theVehicle, "song_start_time", false) end end end end function onCurrentResourceStop(theResource) removeAllSounds() end function removeSongOnGamemodeMapStop(gamemode) -- outputChatBox("gamemode stopped") triggerClientEvent("onGamemodeMapStop", getRootElement()) removeAllSounds() end -- function removeSongOnGamemodeMapStart(gamemode) -- outputChatBox("gamemode started") -- end function removeSongFromElement(theElement) local songId = getElementData(theElement, "song_id") if songId then setElementData(theElement, "song_id", false) setElementData(theElement, "song_start_time", false) end end function removeSongOnExplode() removeSongFromElement(source) end if settings.soundRadioOffOnBlowUp then addEventHandler("onVehicleExplode", getRootElement(), removeSongOnExplode) end addEventHandler("onResourceStop", getResourceRootElement(), onCurrentResourceStop) addEventHandler("onGamemodeMapStop", getRootElement(), removeSongOnGamemodeMapStop) -- addEventHandler("onGamemodeMapStart", getRootElement(), removeSongOnGamemodeMapStart) -- Export function changeSetting(triggerFor, settingName, newValue) triggerClientEvent(triggerFor, "onChangeRadio3dSetting", root, settingName, newValue) end radio3d_client local localPlayer = getLocalPlayer() function constructNumbersFromLetters() playlistNumbers = {} for number, letter in ipairs (playlistLetters) do playlistNumbers[letter] = number end end function getLocalPlaylist() local theSongs = {} local xml = xmlLoadFile(":radio3d_playlist/playlist.xml") if xml then local i = 0 while (xmlFindChild(xml, "song", i)) do local filename = xmlNodeGetAttribute(xmlFindChild(xml, "song", i), "filename") table.insert(theSongs, ":radio3d_playlist/music/"..filename) i = i + 1; end xmlUnloadFile(xml) end return theSongs end function createPlaylist() playlist = {} -- 1. Fill the playlist with placeholders for number, letter in ipairs (playlistLetters) do local filePath = "music/placeholder.mp3" -- local songTitle = "Placeholder" local songTitle = settings.placeholder -- local songTitle = string.sub(filePath, 7, -5) local song = {filePath, songTitle} table.insert(playlist, song) end -- 2. Change the beginning of playlist to local playlist local localPlaylist = getLocalPlaylist() for key, filePath in pairs(localPlaylist) do local songTitle = string.sub(filePath, 25, -5) local song = {filePath, songTitle} playlist[key] = song end end function guiCreateSizedLabel(theText, parent) theLabel = guiCreateLabel(0, 0, 0, 0, theText, false, parent) guiSetLabelSize(theLabel) return theLabel end function initMusicSelectorMenu() labelSongs = {} local screenX, screenY = guiGetScreenSize() local musicSelectorMenuTitle = settings.playListTitle musicSelectorMenuX = screenX - musicSelectorMenuWidth - 20 musicSelectorMenuY = 140 musicSelectorMenu = guiCreateWindow(musicSelectorMenuX, musicSelectorMenuY, musicSelectorMenuWidth, 0, musicSelectorMenuTitle, false) guiWindowSetMovable(musicSelectorMenu, false) guiWindowSetSizable(musicSelectorMenu, false) disableLabel = guiCreateSizedLabel("x. "..settings.noMusic, musicSelectorMenu) closeLabel = guiCreateSizedLabel(settings.closePlaylistDesc) end function guiSetLabelSize(theLabel) local labelHeight = guiLabelGetFontHeight(theLabel) local labelWidth = guiLabelGetTextExtent(theLabel) guiSetSize(theLabel, labelWidth, labelHeight, false) end function populateMusicSelectorMenu() local y = 20 local x_offset = 10 for number, song in ipairs (playlist) do local songTitle = song[2] local labelLetter = playlistLetters[number] local label = guiCreateLabel(x_offset, y, 0, 0, labelLetter..". "..songTitle, false, musicSelectorMenu) local labelHeight = guiLabelGetFontHeight(label) guiSetLabelSize(label) y = y + labelHeight guiLabelSetColor(label, 255, 255, 255) labelSongs[number] = label end guiSetPosition(disableLabel, x_offset, y, false) local windowHeight = 40+y guiSetSize(musicSelectorMenu, musicSelectorMenuWidth, windowHeight, false) guiSetPosition(closeLabel, musicSelectorMenuX+x_offset, musicSelectorMenuY+windowHeight, false) end function drawMusicSelectorMenu() initMusicSelectorMenu() populateMusicSelectorMenu() guiSetVisible(musicSelectorMenu, false) guiSetVisible(closeLabel, false) bindKey("0", "down", musicSelector) end function resetLabels() for number, label in ipairs (labelSongs) do guiSetVisible(label, false) label = nil end labelSongs = {} end function updateMusicSelectorMenu() resetLabels() populateMusicSelectorMenu() end function updatePlaylist() createPlaylist() updateMusicSelectorMenu() end function bindAPlaylistKey(letter) bindKey(letter, "down", switchSong) end function unbindAPlaylistKey(letter) unbindKey(letter, "down", switchSong) end function bindPlaylistKeys() toggleAllControls(false) for number, letter in ipairs (playlistLetters) do bindAPlaylistKey(letter) end bindKey("x", "down", stopSong) end function unbindPlaylistKeys() toggleAllControls(true) for number, letter in ipairs (playlistLetters) do unbindAPlaylistKey(letter) end unbindKey("x", "down", stopSong) end function showMusicSelectorMenu() lastVehicle = getPedOccupiedVehicle(getLocalPlayer()) local selectedSongID = getElementData(lastVehicle, "song_id") if selectedSongID ~= false then guiLabelSetColor(labelSongs[selectedSongID], 255, 255, 0) activeSongCache = selectedSongID end guiSetVisible(musicSelectorMenu, true) guiSetVisible(closeLabel, true) bindPlaylistKeys() end function hideMusicSelectorMenu() guiSetVisible(musicSelectorMenu, false) guiSetVisible(closeLabel, false) if activeSongCache then guiLabelSetColor(labelSongs[activeSongCache], 255, 255, 255) end unbindPlaylistKeys() end function getIDFromLetter(letter) return playlistNumbers[letter] end -- set current song to selected one (and switch the coloured label if needed) function switchSong(newLetter, keyState) local newSongID = getIDFromLetter(newLetter) if playlist[newSongID] ~= nil then selectorStopSong() guiLabelSetColor(labelSongs[newSongID], 255, 255, 0) activeSongCache = newSongID PlayerStartSong(newSongID) if settings.closeOnSelection then -- if hideMusicSelectorMenu() is called too early some letters might be turned to mta controls too early (i.e exit vehicle F) setTimer(hideMusicSelectorMenu, settings.playlistCloseDelay, 1) end end end function selectorStopSong() if lastVehicle ~= nil then local selectedSongID = getElementData(lastVehicle, "song_id") if selectedSongID ~= false then guiLabelSetColor(labelSongs[selectedSongID], 255, 255, 255) PlayerStopSong(lastVehicle) end end end function stopSong(letter, keyState) selectorStopSong() hideMusicSelectorMenu() end -- does player drive the vehicle (s)he is in at the time function isPlayerVehicleDriver() local playerVehicle = getPedOccupiedVehicle(localPlayer) local playerVehicleDriver = getVehicleOccupant(playerVehicle) return (localPlayer == playerVehicleDriver) end -- toggle dialog with 0 function musicSelector() if Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now