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

Wysłany: 2014-09-19, 17:03


teusz11







Wiek: 29
Na forum: 4793 dni
Posty: 191
Nick w MP: Matevsz

Piwa: 4

Respekt: 50

Witam, jak da? jaki? tekst tu? nad g?ow? peda? oraz jak zrobi? takie co?, ?e je?li stoimy samochodem przed barierk? zabierze nam 50$ i barierka si? otwiera

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-19, 17:37


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4535 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

Napis nad g?ow? Sobie nie poradzisz dlatego ?ap m?j kod. U?ycie - nadane setElementData u?ytkownikowi o nazwie "message" z wartoscia tekstu w "".

font = dxCreateFont ( "zachary.ttf", 20 )

function renderIng( )
    local x, y, z = getCameraMatrix( )
    local dimension = getElementDimension( localPlayer )
    for key, pickup in ipairs ( getElementsByType( "pickup" ) ) do
        if getElementDimension( pickup ) == dimension then
            local px, py, pz = getElementPosition( pickup )
            local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z )
            if distance <= 20 then
                local text = getElementData( pickup, "message" )    
                if text and ( distance < 2 or isLineOfSightClear( x, y, z, px, py, pz + 0.7, true, true, true, true, false, false, true, localPlayer ) ) then
                    local sx, sy = getScreenFromWorldPosition( px, py, pz + 0.7 )
                    if sx and sy then
                        local w = dxGetTextWidth( tostring( text ) )
                        local h = ( text and 2 or 1 ) * dxGetFontHeight( )
                        dxDrawRectangle( sx - w / 2 - 5, sy - h / 2 - 5, w + 10, h + 10, tocolor( 0, 0, 0, 200 ) )
                        dxDrawText( tostring( text ), sx, sy, sx, sy, tocolor( 255, 255, 255, 255 ), 1, "default", "center", "center" )
                    end
                end
            end
        end
    end
    for key, marker in ipairs ( getElementsByType( "marker" ) ) do
        if getElementDimension( marker ) == dimension then
            local px, py, pz = getElementPosition( marker )
            local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z )
            if distance <= 20 then
                local text = getElementData( marker, "message" )    
                if text and ( distance < 2 or isLineOfSightClear( x, y, z, px, py, pz + 1.7, true, true, true, true, false, false, true, localPlayer ) ) then
                    local sx, sy = getScreenFromWorldPosition( px, py, pz + 1.7 )
                    if sx and sy then
                        local w = dxGetTextWidth( tostring( text ) )
                        local h = ( text and 2 or 1 ) * dxGetFontHeight( )
                        dxDrawRectangle( sx - w / 2 - 5, sy - h / 2 - 5, w + 10, h + 10, tocolor( 0, 0, 0, 200 ) )
                        dxDrawText( tostring( text ), sx, sy, sx, sy, tocolor( 255, 255, 255, 255 ), 1, "default", "center", "center" )
                    end
                end
            end
        end
    end
    for key, player in ipairs ( getElementsByType( "player" ) ) do
        if getElementDimension( player ) == dimension then
            local px, py, pz = getElementPosition( player )
            local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z )
            if distance <= 20 then
                local text = getElementData( player, "message" )    
                if text and ( distance < 2 or isLineOfSightClear( x, y, z, px, py, pz + 1.1, true, true, true, true, false, false, true, localPlayer ) ) then
                    local sx, sy = getScreenFromWorldPosition( px, py, pz + 0.2)
                    if sx and sy then
                        local w = dxGetTextWidth( tostring( text ) )
                        local h = ( text and 2 or 1 ) * dxGetFontHeight( )
                        -- dxDrawRectangle( sx - w / 2 - 5, sy - h / 2 - 5, w + 10, h + 10, tocolor( 0, 0, 0, 200 ) )
                         dxDrawText( tostring( text ), sx, sy, sx, sy, tocolor( 255, 255, 255, 255 ), 1.2, "default", "center", "center" )
                    end
                end
            end
        end
    end        
    for key, ped in ipairs ( getElementsByType( "ped" ) ) do
        if getElementDimension( ped ) == dimension then
            local px, py, pz = getElementPosition( ped )
            local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z )
            if distance <= 20 then
                local text = getElementData( ped, "message" )    
                if text and ( distance < 2 or isLineOfSightClear( x, y, z, px, py, pz + 0, true, true, true, true, false, false, true, localPlayer ) ) then
                    local sx, sy = getScreenFromWorldPosition( px, py, pz + 0.1)
                    if sx and sy then
                        local w = dxGetTextWidth( tostring( text ) )
                        local h = ( text and 2 or 1 ) * dxGetFontHeight( )
                        dxDrawRectangle( sx - w / 2 - 5, sy - h / 2 - 1, w + 10, h, tocolor( 0, 0, 0, 200 ) )
                        dxDrawText( tostring( text ), sx, sy, sx, sy, tocolor( 255, 255, 255, 255 ), 1, "default", "center", "center" )
                    end
                end
            end
        end
    end    
    for key, vehicle in ipairs ( getElementsByType( "vehicle" ) ) do
        if getElementDimension( vehicle ) == dimension then
            local px, py, pz = getElementPosition( vehicle )
            local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z )
            if distance <= 20 then
                local text = getElementData( vehicle, "message" )    
                if text and ( distance < 2 or isLineOfSightClear( x, y, z, px, py, pz + 1.1, true, true, true, true, false, false, true ) ) then
                    local sx, sy = getScreenFromWorldPosition( px, py, pz+0.2 )
                    if sx and sy then
                        local w = dxGetTextWidth( tostring( text ) )
                        local h = ( text and 2 or 1 ) * dxGetFontHeight( )
                        --dxDrawRectangle( sx - w / 2 - 25, sy - h / 2 - 1, w +50, h, tocolor( 0, 0, 0, 200 ) )
                        dxDrawText( "Na kartce napisane:", sx, sy, sx, sy-30, tocolor( 255, 255, 255, 255 ), 0.8, "bankgothic", "center", "center" )
                        --dxDrawRectangle( sx - w / 2 - 25, sy - h / 2 - 30, 300, 30, tocolor( 0, 0, 0, 200 ) )
                        dxDrawText( tostring( text ), sx, sy+30, sx, sy, tocolor( 255, 255, 255, 255 ), 0.7, "bankgothic", "center", "center" )
                    end
                end
            end
        end
    end    
    for key, object in ipairs ( getElementsByType( "object" ) ) do
        if getElementDimension( object ) == dimension then
            local px, py, pz = getElementPosition( object )
            local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z )
            if distance <= 20 then
                local text = getElementData( object, "message" )    
                if text and ( distance < 2 or isLineOfSightClear( x, y, z, px, py, pz + 1.1, true, true, true, true, false, false, true, localPlayer ) ) then
                    local sx, sy = getScreenFromWorldPosition( px, py, pz + 1.1 )
                    if sx and sy then
                        local w = dxGetTextWidth( tostring( text ) )
                        local h = ( text and 2 or 1 ) * dxGetFontHeight( )
                         dxDrawRectangle( sx - w / 2 - 5, sy - h / 2 - 1, w + 10, h, tocolor( 0, 0, 0, 200 ) )
                        dxDrawText( tostring( text ), sx, sy, sx, sy, tocolor( 255, 255, 255, 255 ), 1, "default", "center", "center" )
                    end
                end
            end
        end
    end    
end
addEventHandler( "onClientRender", getRootElement( ),renderIng)


Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-19, 17:40


Piorun







Wiek: 33
Na forum: 6853 dni
Posty: 1837
Nick w MP: Piorun

Piwa: 516

Respekt: 480,7
Respekt: 480,7

Funkcje do utworzenia tekstu nad g?ow?:


Więcej informacji znajdziesz w Wikipedii MTA:

dxDrawText



Więcej informacji znajdziesz w Wikipedii MTA:

getScreenFromWorldPosition



Więcej informacji znajdziesz w Wikipedii MTA:

getPedBonePosition


@UP lel, par? sek. wcze?niej.

Podpis
Możesz mnie znaleźć na: Facebook
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-19, 17:54


teusz11







Wiek: 29
Na forum: 4793 dni
Posty: 191
Nick w MP: Matevsz

Piwa: 4

Respekt: 50

Dobra to teraz ostatnie, jak zrobi?em marker i je?li w niego wjedziemy odejmuje nam 50$ i otwieraj? si? barierki, z MoveObject dam rade tylko w?a?nie to pobieranie pieni?dzy :(

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-19, 18:12


luki123luki123

Place Game






Wiek: 28
Na forum: 5416 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6103

Respekt: 611
Respekt: 611Respekt: 611

teusz11,
Więcej informacji znajdziesz w Wikipedii MTA:

TakePlayerMoney


Postaw piwo autorowi tego posta
 

 
Tagi: dxdrawtext :: barierki
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » dxDrawText i barierki 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