Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-12-08, 11:03


Haverrak12







Wiek: 32
Na forum: 2161 dni
Posty: 8
Nick w MP: hahaha



Respekt: 50

Ostrzeżeń: 60%
Witam zrobi?em sobie ostatnio chat g?osowy i od kilku dni staram si? zrobi? co? takiego ?eby nie s?ysza? kto? kogo? na ca?ym serwerze tylko na dan? odleg?o?? jak by to zrobi?? (u?ywam standardowego skryptu voice co jest w mta)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-08, 11:13


TheSebaPL

Mod-team






Wiek: 21
Na forum: 3098 dni
Posty: 964

Piwa: 3101

Respekt: 640,5
Respekt: 640,5Respekt: 640,5

Haverrak12,



-- variables
local voicePlayers = {}

-- draw (voice reosource)
local g_screenX,g_screenY guiGetScreenSize()
local BONE_ID 8
local WORLD_OFFSET 0.4
local ICON_PATH "images/voice.png"
local ICON_WIDTH 0.15*g_screenX
--
local font dxCreateFont("font.ttf"12)
local iconHalfWidth ICON_WIDTH/2

local ICON_DIMENSIONS 12
local ICON_LINE 20
local ICON_TEXT_SHADOW tocolor 000255 )
local range 15

--Draw the voice image
addEventHandler "onClientRender"root,
    function()
        local index 0
        local sXsYsZ getElementPosition(localPlayer) 
        for player in pairs(voicePlayers) do

            local rXrYrZ getElementPosition(player)
            local distance getDistanceBetweenPoints3D(sXsYsZrXrYrZ) 
            setSoundVolumeplayer30-distance )

            local color tocolor(255255255255)
            if distance <= range then
            dxDrawVoiceLabel playerindexcolor )
            end
            index index 1
            while true do
                --is he streamed in?
                if not isElementStreamedIn(playerthen
                    break
                end
                --is he on screen?
                if not isElementOnScreen(playerthen 
                    break
                end
                local headX,headY,headZ getPedBonePosition(player,BONE_ID)
                headZ headZ WORLD_OFFSET
                --is the head position on screen?
                local absX,absY getScreenFromWorldPosition headX,headY,headZ )
                if not absX or not absY then
                    break
                end
                local camX,camY,camZ getCameraMatrix()
                --is there anything obstructing the icon?
                if not isLineOfSightClear camXcamYcamZheadXheadYheadZtruefalsefalsetruefalsetruefalseplayer then
                    break
                end
                dxDrawVoice absXabsYcolorgetDistanceBetweenPoints3D(camXcamYcamZheadXheadYheadZ) )
                break
            end
        end
    end
)

function dxDrawVoice posXposYcolordistance )
    if distance <= range then
    distance 1/distance
    dxDrawImage posX iconHalfWidth*distanceposY iconHalfWidth*distance-75ICON_WIDTH*distanceICON_WIDTH*distanceICON_PATH000colorfalse )
end
end

function dxDrawVoiceLabel playerindexcolor )
    local sxsy guiGetScreenSize ()
    local scale = (sy 800)
    local spacing = ( ICON_LINE scale )
    local icon ICON_DIMENSIONS scale
    local pxpy sx-icon, (sy 0.6 spacing index)

    if getPedOccupiedVehiclelocalPlayer then
        py = (sy 0.6 spacing index)
    end
    dxDrawImage px-iconpyicon*1.2icon*1.2ICON_PATH000colorfalse )

    px px spacing
 
    local name getPlayerName player ):gsub("#%x%x%x%x%x%x","")
    local textWidth dxGetTextWidth(name1.2"default-bold")
    dxDrawText namepx textWidthpy 1px textWidthpyICON_TEXT_SHADOW1font )
    dxDrawText namepx textWidthpypx textWidthpycolor1font )
end


-- events
addEventHandler("onClientPlayerVoiceStart",getRootElement(),function()
    if getElementData (localPlayer"player:mute" then
        cancelEvent()
        return 
    end
    if getElementData (source"mute:player" then
        cancelEvent()
        return
    end
    if getElementData (source"voice:off" then
        cancelEvent()
        return
    end
    local localDimension getElementDimensionlocalPlayer )
    local localInterior getElementInteriorlocalPlayer )
    if source == localPlayer then
        setElementData(source"voice:mowi"true)

        -- draw
        voicePlayers[source] = true

        -- data to server
        local posXposYposZ getElementPosition(source)
        local nearbyPlayers getElementsWithinRange(posXposYposZ30"player")
        -- senc data
        --triggerServerEvent"voicechat:setDestination"resourceRootnearbyPlayers )
    else
        local sourceDimension getElementDimensionsource )
        local sourceInterior getElementInteriorsource )
        if tonumber(localDimension) ~= tonumber(sourceDimension) or tonumber(localInterior) ~= tonumber(sourceInteriorthen
            cancelEvent()
            return
        end

        local sXsYsZ getElementPosition(localPlayer) 
        local rXrYrZ getElementPosition(source)
        local distance getDistanceBetweenPoints3D(sXsYsZrXrYrZ) 
        if distance <= range then
            voicePlayers[source] = true
        else 
            cancelEvent()
        end 
    end
end)

addEventHandler("onClientPlayerVoiceStop",getRootElement(),function()
    if source == localPlayer then
        setElementData(source"voice:mowi"false)
    end
    voicePlayers[source] = nil
end)

addEventHandler("onClientPlayerQuit",getRootElement(),function()
    voicePlayers[source] = nil
end)


Podmie? ca?e client.lua

Nie jestem pewny czy na 100% b?dzie dzia?a?o.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Haverrak12
Wysłany: 2020-12-09, 15:58


Haverrak12







Wiek: 32
Na forum: 2161 dni
Posty: 8
Nick w MP: hahaha



Respekt: 50

Ostrzeżeń: 60%
TheSebaPL, Dzi?ki! dzia?a bardzo dobrze wr?cz idealnie ale jest jeden ma?y problem gdy kto? co? m?wi i kto? inny si? loguje to wszystko s?ycha? w panelu logowania da rade to jako? w skrypcie panelu logowania zrobi? tak jak np z myszk?? co? tkaiego showCursor(false) tylko z voice ?eby ne by?o w panelu logowania s?ycha? jak kto? inny s? loguje

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-09, 16:17


_jvneczek







Wiek: 22
Na forum: 4326 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

Wystarczy zrobi? ?e osoby kt?re nie s? zalogowane - nie s?ysz? voice chatu, wystarczy zwyk?y if z sprawdzaniem czy gracz jest zalogowany.

Postaw piwo autorowi tego posta
 

 
Tagi: voice :: chat
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku