XaskeL Posted July 12, 2015 Share Posted July 12, 2015 Пробовал сделать ограничение в "voice" не получилось, слышно на всю карту либо через раз. И расскажите о мифической нагрузке на сервер из-за "voice" local nearbyPlayers = {} addEventHandler( 'onPlayerVoiceStart', root, function() local posX, posY, posZ = getElementPosition( source ) local chatSphere = createColSphere( posX, posY, posZ, 10) nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) destroyElement( chatSphere ) local empty = exports.ls_voice:getNextEmptyChannel ( ) exports.ls_voice:setPlayerChannel(source, empty) for index, player in ipairs (nearbyPlayers) do exports.ls_voice:setPlayerChannel(player, empty) end end) addEventHandler("onPlayerVoiceStop",root, function() exports.ls_voice:setPlayerChannel(source) for index, player in ipairs (nearbyPlayers) do exports.ls_voice:setPlayerChannel(player) end nearbyPlayers = {} end) Link to comment
Other Languages Moderators Disinterpreter Posted July 14, 2015 Other Languages Moderators Share Posted July 14, 2015 Кто нибудь поможет? Могут помочь только те, кто делал это. А я даже не пытался D: Link to comment
JHarmon Posted July 14, 2015 Share Posted July 14, 2015 Не знаю, будет ли работать, надо тестировать... Вроде то, что ты хотел... Про "мифическую нагрузку" не в курсе, не интересовался... local voiceCols = {} local broadcoastTo = {} addEventHandler("onPlayerVoiceStart", root, function() local voiceSource = source local sx, sy, sz = getElementPosition(voiceSource) -- Создаем колшейп для игрока, который говорит voiceCols[voiceSource] = createColSphere(sx, sy, sz, 10) -- Привязываем его к игроку, думаю, что это необходимо тут... attachElements(voiceCols[voiceSource], voiceSource) -- Те, кто слышат в данный момент broadcoastTo[voiceSource] = getElementsWithinColShape(voiceCols[voiceSource], "player") setPlayerVoiceBroadcastTo(voiceSource, broadcoastTo[voiceSource]) -- Вход/выход с колшейпа, необходимо обновить данные... addEventHandler("onColshapeHit", voiceCols[voiceSource], function(element) if (getElementType(element) == "player") then table.insert(broadcoastTo[voiceSource], element) setPlayerVoiceBroadcastTo(voiceSource, broadcoastTo[voiceSource]) end end ) addEventHandler("onColshapeLeave", voiceCols[voiceSource], function(element) if (getElementType(element) == "player") then -- Ищем и выпиливаем того, кто вышел из колшейпа for key, player in pairs(broadcoastTo[voiceSource]) do if (element == player) then table.remove(broadcoastTo[voiceSource], key) break end end setPlayerVoiceBroadcastTo(voiceSource, broadcoastTo[voiceSource]) end end ) end ) addEventHandler("onPlayerVoiceStop", root, function() if isElement(voiceCols[source]) then destroyElement(voiceCols[source]) end if (broadcoastTo[source]) then table.remove(broadcoastTo, source) end setPlayerVoiceBroadcastTo(source) end ) 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