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

Wysłany: 2017-11-11, 21:31


Szydlo

Stance Works






Wiek: 26
Na forum: 3726 dni
Posty: 343
Nick w MP: Szydlo

Piwa: 4

Respekt: 105,3
Respekt: 105,3

Witam, chcia?bym zrobi? sw?j nametag, i mam taki problem ?e jak to zrobi? wymy?li?em co? takiego: robie dxDrawa, i b?dzie on mia? x,y,z+10. No ale chyba tak nie mo?na. Oraz chcia?bym zrobi? takiego markera w 3D: https://imgur.com/6s8KMhH

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
nagrywki12
Wysłany: 2017-11-11, 21:41


neku^







Wiek: 24
Na forum: 3662 dni
Posty: 461
Nick w MP: neku^

Piwa: 1186

Respekt: 320,5
Respekt: 320,5Respekt: 320,5Respekt: 320,5

Co do nametag'ow, najlepiej pobra? pozycj? szyji gracza i do tej warto?ci doda? w pozycji Z z 2 albo 3.

Więcej informacji znajdziesz w Wikipedii MTA:

getPedBonePosition

Co do markerow to jest to chyba

Więcej informacji znajdziesz w Wikipedii MTA:

dxDrawMaterialLine3D


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 21:43


Szydlo

Stance Works






Wiek: 26
Na forum: 3726 dni
Posty: 343
Nick w MP: Szydlo

Piwa: 4

Respekt: 105,3
Respekt: 105,3

A nametag mog? za pomoc? dxdraw?

[ Dodano: 2017-11-11, 21:44 ]
Dobra w wiki jest przyk?ad nametagu

Podpis
Aktualny najlepszy kontakt do mnie: Szydlo#8134 (Discord)
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 21:45


neku^







Wiek: 24
Na forum: 3662 dni
Posty: 461
Nick w MP: neku^

Piwa: 1186

Respekt: 320,5
Respekt: 320,5Respekt: 320,5Respekt: 320,5

Oczywi?cie ale jako x oraz y dajesz warto?? zwr?cona przez funkcje getPedBonePosition p??niej dajesz getScreenFromWorldPosition i zwr?cona warto?? dajesz do dxDrawText i podnosisz troch? ?eby nametag nie by? w szyji

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 21:47


Szydlo

Stance Works






Wiek: 26
Na forum: 3726 dni
Posty: 343
Nick w MP: Szydlo

Piwa: 4

Respekt: 105,3
Respekt: 105,3

Na wiki jest taki przyk?ad i to jest nametag:


addEventHandler( "onClientRender",root,
   function( )
      local px, py, pz, tx, ty, tz, dist
      px, py, pz = getCameraMatrix( )
      for _, v in ipairs( getElementsByType 'player' ) do
         tx, ty, tz = getElementPosition( v )
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 )
         if dist < 30.0 then
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then
               local sx, sy, sz = getPedBonePosition( v, 5 )
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 )
               if x then 
                dxDrawText( getPlayerName( v ), x, y, x, y, tocolor(150, 50, 0), 0.85 + ( 15 - dist ) * 0.02, "bankgothic" )
               end
            end
         end
      end
   end
)


Podpis
Aktualny najlepszy kontakt do mnie: Szydlo#8134 (Discord)
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 21:49


neku^







Wiek: 24
Na forum: 3662 dni
Posty: 461
Nick w MP: neku^

Piwa: 1186

Respekt: 320,5
Respekt: 320,5Respekt: 320,5Respekt: 320,5

Nom, czyli to co m?wi?em getPedBonePosition getScreenFromWorldPosition

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 21:57


Szydlo

Stance Works






Wiek: 26
Na forum: 3726 dni
Posty: 343
Nick w MP: Szydlo

Piwa: 4

Respekt: 105,3
Respekt: 105,3

Dobra a jak usun?? ten nametag co daje mta?

[ Dodano: 2017-11-11, 22:01 ]
I ten chcia?bym wykry? kiedy gracz pisze (kiedy ma w??czone T).

Podpis
Aktualny najlepszy kontakt do mnie: Szydlo#8134 (Discord)
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 22:07


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4290 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4661

Respekt: 1436,8
Respekt: 1436,8


Więcej informacji znajdziesz w Wikipedii MTA:

setPlayerNametagShowing



Więcej informacji znajdziesz w Wikipedii MTA:

isChatBoxInputActive


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 22:11


Szydlo

Stance Works






Wiek: 26
Na forum: 3726 dni
Posty: 343
Nick w MP: Szydlo

Piwa: 4

Respekt: 105,3
Respekt: 105,3

dxDrawMaterialLine3D to chyba nie jest mi si? tak zdaje. Chyba da si? jako? podmieni? tekstur? oryginalnego markera. Co? takiego by?a na Drift Paradise bo mam gamemode.

Podpis
Aktualny najlepszy kontakt do mnie: Szydlo#8134 (Discord)
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 22:14


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4290 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4661

Respekt: 1436,8
Respekt: 1436,8

Nie ma czego? takiego jak "podmiana markera", trzeba pisa? w?asny system przy pomocy tego co poda? dbn69,

Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 22:15


Szydlo

Stance Works






Wiek: 26
Na forum: 3726 dni
Posty: 343
Nick w MP: Szydlo

Piwa: 4

Respekt: 105,3
Respekt: 105,3

Dobra i mam kolejne problemy. Mam sobie nametag, i gdy si? oddalam od osoby to wtedy nametag si? zwi?ksza, a ja nie chce ?eby si? zwi?ksza?. Kolejny problem jest taki ?e chce mie? tekst zawsze po ?rodku bo gdy mam np nick "Szydlo" to jest po?rodku ale gdy mam nick "[1]Szydlo2" to wtedy ju? nie jest.

[ Dodano: 2017-11-11, 22:16 ]
I mam tutaj taki kod na marker:

-- &#1054;&#1090;&#1088;&#1080;&#1089;&#1086;&#1074;&#1082;&#1072; &#1084;&#1072;&#1088;&#1082;&#1077;&#1088;&#1086;&#1074;

local screenSize = Vector2(guiGetScreenSize())

local MARKER_ANIMATION_SPEED = 0.008

-- &#1048;&#1082;&#1086;&#1085;&#1082;&#1072; &#1085;&#1072; &#1079;&#1077;&#1084;&#1083;&#1077;
local MARKER_ICON_SIZE = 6
local MARKER_ANIMATION_SIZE = 0.3

local MARKER_TEXT_SIZE = 5
local MARKER_TEXT_ANIMATION_SIZE = 0.1
local MARKER_TEXT_OFFSET = Vector3(0, 0, 2)

local markersToDraw = {}

-- &#1058;&#1077;&#1082;&#1089;&#1090; &#1085;&#1072; &#1101;&#1082;&#1088;&#1072;&#1085;&#1077;
local screenTextFont
local screenTextBottomOffset = 60

-- &#1052;&#1072;&#1088;&#1082;&#1077;&#1088;, &#1074; &#1082;&#1086;&#1090;&#1086;&#1088;&#1086;&#1084; &#1089;&#1077;&#1081;&#1095;&#1072;&#1089; &#1085;&#1072;&#1093;&#1086;&#1076;&#1080;&#1090;&#1089;&#1103; &#1080;&#1075;&#1088;&#1086;&#1082;
local currentMarker
local markerKey = "g"

local markerTypes = {}
markerTypes.garage = {
    color = {212, 0, 40},
    icon = "assets/garage_icon.png",
    text = "assets/garage_text.png",
    string = "markers_garage_text"
}

markerTypes.city = {
    color = {212, 0, 40},
    icon = "assets/city_icon.png",
    text = "assets/city_text.png",
    string = "markers_city_text"
}

markerTypes.showroom = {
    color = {212, 0, 40},
    icon = "assets/showroom_icon.png",
    text = "assets/showroom_text.png",
    string = "markers_showroom_text"
}

markerTypes.house = {
    color = {212, 0, 40},
    icon = "assets/house_floor.png",
    iconSize = 1,
    text = "assets/house_icon.png",
    string = "markers_house_enter_text"
}

markerTypes.stripclub = {
    color = {212, 0, 40},
    icon = "assets/house_floor.png",
    iconSize = 1,
    text = "assets/strip_icon.png",
    string = "markers_strip_enter_text"
}

markerTypes.race = {
    color = {255, 255, 255},
    icon = "assets/race_icon.png",
    iconSize = 12.5,
    text = "assets/race_text.png",
    string = "markers_race_enter_text",
    noPaint = true
}

markerTypes.tofu = {
    color = {255, 255, 255},
    icon = "assets/race_icon.png",
    iconSize = 12.5,
    string = "markers_tofu_text",
    noPaint = true
}

markerTypes.exit = {
    color = {212, 0, 40},
    text = "assets/exit_icon.png",
    string = "markers_house_exit_text"
}

function getMarkerProperties(type)
    return markerTypes[type]
end

local function dxDrawShadowText(text, x1, y1, x2, y2, color, scale, font, alignX, alignY)
    dxDrawText(text, x1 - 1, y1, x2 - 1, y2, tocolor(0, 0, 0, 150), scale, font, alignX, alignY)
    dxDrawText(text, x1 + 1, y1, x2 + 1, y2, tocolor(0, 0, 0, 150), scale, font, alignX, alignY)
    dxDrawText(text, x1, y1 - 1, x2, y2 - 1, tocolor(0, 0, 0, 150), scale, font, alignX, alignY)
    dxDrawText(text, x1, y1 + 1, x2, y2 + 1, tocolor(0, 0, 0, 150), scale, font, alignX, alignY)
    dxDrawText(text, x1, y1, x2, y2, color, scale, font, alignX, alignY)
end

local function drawScreenText(text)
    text = string.format(exports.dpLang:getString(text), string.upper(markerKey))
    local yOffset = math.sin(getTickCount() * MARKER_ANIMATION_SPEED) * 5
    -- dxDrawText(
    --     text, 
    --     10, 
    --     10 + yOffset, 
    --     screenSize.x, 
    --     screenSize.y - screenTextBottomOffset + 2 + yOffset, 
    --     tocolor(0, 0, 0, 150), 
    --     1, 
    --     screenTextFont, 
    --     "center", 
    --     "bottom"
    -- )
    dxDrawShadowText(
        text, 
        0, 
        0 + yOffset, 
        screenSize.x, 
        screenSize.y - screenTextBottomOffset + yOffset, 
        tocolor(255, 255, 255), 
        1, 
        screenTextFont, 
        "center", 
        "bottom"
    )    
end

local function drawMarker(marker)
    local markerType = marker:getData("dpMarkers.type")
    local markerProperties = markerTypes[markerType]
    if not markerProperties then
        return
    end

    local t = getTickCount()

    local color = {
        markerProperties.color[1], 
        markerProperties.color[2], 
        markerProperties.color[3], 
        200 + math.sin(t * MARKER_ANIMATION_SPEED / 3) * 35
    }

    -- &#1058;&#1077;&#1082;&#1089;&#1090; &#1084;&#1072;&#1088;&#1082;&#1077;&#1088;&#1072;
    local restrictElement = marker:getData("dpMarkers.restrictElement")
    local canEnter = false
    if restrictElement then
        if restrictElement == "vehicle" and localPlayer.vehicle then
            canEnter = true
        elseif restrictElement == "player" and not localPlayer.vehicle then
            canEnter = true
        end
    else
        canEnter = true
    end
    if (localPlayer:isWithinMarker(marker) or 
        (localPlayer.vehicle and localPlayer.vehicle:isWithinMarker(marker))) and canEnter
    then
        if not markerProperties.noPaint then
            color = {
                232 + math.sin(t * MARKER_ANIMATION_SPEED) * 23, 
                20 + math.sin(t * MARKER_ANIMATION_SPEED) * 20,
                60 + math.sin(t * MARKER_ANIMATION_SPEED) * 30,
                255
            }
        end
        local markerText = marker:getData("dpMarkers.text")
        if not markerText then
            markerText = markerProperties.string
        end
        drawScreenText(markerText)
        if currentMarker ~= marker then
            triggerEvent("dpMarkers.enter", marker)
            currentMarker = marker
        end
    end    

    local mx, my, mz = getElementPosition(marker)
    -- &#1048;&#1082;&#1086;&#1085;&#1082;&#1072; &#1085;&#1072; &#1079;&#1077;&#1084;&#1083;&#1077;
    if markerProperties.icon then
        -- &#1056;&#1072;&#1079;&#1084;&#1077;&#1088;&#1099; &#1080;&#1082;&#1086;&#1085;&#1082;&#1080;
        local markerIconSize = MARKER_ICON_SIZE
        local animationSize = MARKER_ANIMATION_SIZE
        if markerProperties.iconSize then
            markerIconSize = markerProperties.iconSize
            animationSize = markerIconSize / MARKER_ICON_SIZE * MARKER_ANIMATION_SIZE
        end
        local iconSize = markerIconSize - math.sin(t * MARKER_ANIMATION_SPEED) * animationSize        

        local direction = marker:getData("dpMarkers.direction")
        local ox = math.cos(direction) * iconSize / 2
        local oy =  math.sin(direction) * iconSize / 2
        dxDrawMaterialLine3D(
            mx + ox,
            my + oy,
            mz,
            mx - ox,
            my - oy,
            mz,
            markerProperties.icon, 
            iconSize,
            tocolor(255, 255, 255, color[4]),
            mx,
            my,
            mz + 1
        )
    end

    if not markerProperties.text then
        return
    end
    local textSize = MARKER_TEXT_SIZE
    -- &#1042;&#1077;&#1088;&#1090;&#1080;&#1082;&#1072;&#1083;&#1100;&#1085;&#1072;&#1103; &#1082;&#1072;&#1088;&#1090;&#1080;&#1085;&#1082;&#1072;
    local textAnimationOffset = math.sin(t * MARKER_ANIMATION_SPEED) * MARKER_TEXT_ANIMATION_SIZE
    dxDrawMaterialLine3D(
        mx, 
        my,
        mz + textSize / 2 + MARKER_TEXT_OFFSET.z + textAnimationOffset,
        mx,
        my,
        mz - textSize / 2 + MARKER_TEXT_OFFSET.z + textAnimationOffset,
        markerProperties.text,
        textSize,
        tocolor(unpack(color))
    )
end

function addMarkerToDraw(marker)
    if isElementStreamedIn(marker) then
        markersToDraw[marker] = true
    end
end

addEventHandler("onClientRender", root, function ()
    if localPlayer:getData("dpCore.state") then
        return
    end
    for marker in pairs(markersToDraw) do
        drawMarker(marker)
    end
end)

addEventHandler("onClientElementStreamIn", root, function ()
    if source:getData("dpMarkers.type") then
        addMarkerToDraw(source)
    end
end)

addEventHandler("onClientElementStreamOut", root, function ()
    if markersToDraw[source] then
        markersToDraw[source] = nil
    end
end)

addEventHandler("onClientElementDestroy", root, function ()
    if markersToDraw[source] then
        markersToDraw[source] = nil
    end
end)

addEventHandler("onClientResourceStart", resourceRoot, function ()
    for name, markerProperties in pairs(markerTypes) do
        if markerProperties.icon then
            markerProperties.icon = dxCreateTexture(markerProperties.icon, "dxt5")
        end
        if markerProperties.text then
            markerProperties.text = dxCreateTexture(markerProperties.text, "dxt5")
        end
    end

    screenTextFont = exports.dpAssets:createFont("Roboto-Regular.ttf", 22)
end)

addEventHandler("onClientKey", root, function (key, state)
    if key == markerKey and state then
        if isMTAWindowActive() then
            return false
        end
        if not isElement(currentMarker) then
            return
        end
        if localPlayer:getData("dpCore.state") or localPlayer:getData("activeUI") then
            return
        end    
        if localPlayer:isWithinMarker(currentMarker) or 
            (localPlayer.vehicle and localPlayer.vehicle:isWithinMarker(currentMarker))
        then
            triggerEvent("dpMarkers.use", currentMarker)
            cancelEvent()
        end        
    end
end)

addEventHandler("onClientMarkerLeave", resourceRoot, function (player)
    if player ~= localPlayer then
        return
    end
    if source == currentMarker then
        currentMarker = nil
    end
end)


Podpis
Aktualny najlepszy kontakt do mnie: Szydlo#8134 (Discord)
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 22:16


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4290 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4661

Respekt: 1436,8
Respekt: 1436,8

Co do zwi?kszania si?, to poka? kod. Je?li chodzi o d?ugo?? to
Więcej informacji znajdziesz w Wikipedii MTA:

dxGetTextWidth
i wyliczenia z tym lub mo?esz bawi? si? argumentem od dxDrawText.

Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 22:17


Szydlo

Stance Works






Wiek: 26
Na forum: 3726 dni
Posty: 343
Nick w MP: Szydlo

Piwa: 4

Respekt: 105,3
Respekt: 105,3

I w tym kodzie jest

onClientMarkerLeave

A przecie? jest to w?asny marker

[ Dodano: 2017-11-11, 22:18 ]
A je?eli chodzi o kod nametaga:

local FMain = dxCreateFont( "files/font.ttf", 20)
local SMain = dxCreateFont( "files/font.ttf", 15)

addEventHandler( "onClientRender",root,
   function(player)
      local players = getElementsByType ( "player" ) 
      for key, player in ipairs ( players ) do       
        setPlayerNametagShowing ( player, false ) 
      end
      local px, py, pz, tx, ty, tz, dist
      px, py, pz = getCameraMatrix( )
      for _, v in ipairs( getElementsByType 'player' ) do
         tx, ty, tz = getElementPosition( v )
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 )
         if dist < 30.0 then
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then
               local sx, sy, sz = getPedBonePosition( v, 6 )
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 )
               if x then 
                dxDrawText( "[1]"..getPlayerName( v ), x-60, y, x, y, tocolor(255, 255, 255, 160), 0.85 + ( 15 - dist ) * 0.02, FMain )
                dxDrawText( "Adminisrator", x-55, y+30, x, y, tocolor(255, 0, 0, 255), 0.85 + ( 15 - dist ) * 0.02, SMain )
               end
            end
         end
      end
   end
)


Podpis
Aktualny najlepszy kontakt do mnie: Szydlo#8134 (Discord)
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 22:21


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4290 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4661

Respekt: 1436,8
Respekt: 1436,8

 0.85 + ( 15 - dist ) * 0.02
to odpowiada za powi?kszanie si?.

Je?li chodzi o markery to za pewne jest tam tworzony marker aby to jako? dzia?a?o, na miejscu tego jest marker i aby by?o ?atwiej to jest to po to by dzia?a?o jak marker normalny. By mo?na sprawdzi? czy gracz jest w markerze, gdy wchodzi/wychodzi pro?ciej tak ni? pisa? w?asne funkcje wywo?uj?ce takie zdarzenia.

Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-11, 22:22


Szydlo

Stance Works






Wiek: 26
Na forum: 3726 dni
Posty: 343
Nick w MP: Szydlo

Piwa: 4

Respekt: 105,3
Respekt: 105,3

A ten marker jest pewnie nie widzialny?

Podpis
Aktualny najlepszy kontakt do mnie: Szydlo#8134 (Discord)
Postaw piwo autorowi tego posta
 

 
Tagi: nametagi
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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