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

Wysłany: 2019-02-09, 17:32


sebik2303

Mapper :)






Wiek: 25
Na forum: 4301 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Witam, jak zrobi?, aby po wjechaniu autem w marker pokazywa? si? 3dtext na mapie w wyznaczonym miejscu? Najlepiej bylo by po wpisaniu komendy :)
Dzi?kuj? za pomoc :D
Daje repe i piwka ! :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-09, 18:06


BlueCry

ŚĆRIPTER LUJA






Wiek: 25
Na forum: 4147 dni
Posty: 78
Nick w MP: BlueCry

Piwa: 2178

Respekt: 110
Respekt: 110

Tutaj masz kod, po wjechaniu w marker i po wpisaniu komendy /text3 tworzy si? 3dtext w miejscu w kt?rym jeste?.
local Marker = createMarker ( -2702.90,-277.74,7.19, "cylinder", 1.5, 255, 255, 0, 170 )

function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler
    local elementType = getElementType( hitElement ) -- get the hit element's type
 setElementData(hitElement, "textgut", true)
end
addEventHandler( "onMarkerHit", Marker, MarkerHit )

function markerLeave( leaveElement, matchingDimension )
    if getElementType( leaveElement ) == "player" then
    setElementData(leaveElement, "textgut", false)
    end
end

addEventHandler( "onMarkerLeave", Marker, markerLeave )

function text ( playerSource, commandName )
    if ( playerSource ) then
    if getElementData(playerSource, "textgut") then
        local x, y, z = getElementPosition ( playerSource )
        local text=createElement('text')
        setElementPosition(text, x, y, z)
setElementData(text,"name","Text jaki chcesz")
        outputChatBox ( "Stworzy?e? 3dtext", playerSource )
    end
end
end
addCommandHandler ( "text3", text )


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
sebik2303
Wysłany: 2019-02-09, 18:35


sebik2303

Mapper :)






Wiek: 25
Na forum: 4301 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

db3 od setelementdaty jest w linijce 19

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-09, 18:43


BlueCry

ŚĆRIPTER LUJA






Wiek: 25
Na forum: 4147 dni
Posty: 78
Nick w MP: BlueCry

Piwa: 2178

Respekt: 110
Respekt: 110

"sebik2303" napisał/a:

db3 od setelementdaty jest w linijce 19

Po kt?rej stronie doda?e?? Po stronie klienta czy serwera?

[ Dodano: 2019-02-09, 18:57 ]
Tworzy?em to po stronie serwera, wi?c dodaj po stronie serwera.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-09, 23:03


sebik2303

Mapper :)






Wiek: 25
Na forum: 4301 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Dobra to dzia?a a jak zrobi? aby to sie usun??o po wyjechaniu z tego markera lub chocia? po wpisaniu komy???

[ Dodano: 2019-02-09, 23:47 ]
I r?wnie? dlaczego jak daje np local przeb=getElementData (playerSource, "vehicle:mileage") to wywala errora i nie dzia?a :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-10, 09:41


BlueCry

ŚĆRIPTER LUJA






Wiek: 25
Na forum: 4147 dni
Posty: 78
Nick w MP: BlueCry

Piwa: 2178

Respekt: 110
Respekt: 110

Tutaj masz kod kt?ry usuwa napis po wyjechaniu:
local Marker = createMarker ( -2702.90,-277.74,7.19, "cylinder", 1.5, 255, 255, 0, 170 )

function MarkerHit( hitElement, matchingDimension ) 
    local elementType = getElementType( hitElement )
 --if getElementData(hitElement, "stworzyltext") == 1 then 
 --return end
 setElementData(hitElement, "stworzyltext", 0)
end
addEventHandler( "onMarkerHit", Marker, MarkerHit )

function text3 ( playerSource, commandName )
    if ( playerSource ) then
        local x, y, z = getElementPosition ( playerSource )
        local text=createElement('text')
        setElementPosition(text, x, y, z)
setElementData(text,"name","Text jaki chcesz")
        outputChatBox ( "Stworzy?e? 3dtext", playerSource )
        setElementData(playerSource, "stworzyltext", 1)
end
end
addCommandHandler ( "text3", text3 )

function markerLeave( leaveElement, matchingDimension )
    if getElementType( leaveElement ) == "player" then
    if getElementData(leaveElement, "stworzyltext") == 1 then setElementData(playerSource, "stworzyltext", 0)
    restartResource(getThisResource())
else return
end
    end
end
addEventHandler( "onMarkerLeave", Marker, markerLeave )


A co do errora jak dodajesz local przeb to poka? kod, bo inaczej nie wiem co jest ?le.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-10, 10:13


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Restartowanie skryptu? Po co je?li mo?na po prostu usun?? ten element.

Gotowy kod:
local Marker = createMarker( -2702.90,-277.74,7.19, "cylinder", 1.5, 255, 255, 0, 170 )
local text

function MarkerHit(hitElement, matchingDimension) 
    if getElementType(hitElement) == "player" then
        setElementData(hitElement, "stworzyltext", 0)
    end    
end
addEventHandler("onMarkerHit", Marker, MarkerHit)

function text3(playerSource, commandName)
    if getElementType(playerSource) == "player" then
        if isElement(text) then
            destroyElement(text)
            text = nil
        end
        local x, y, z = getElementPosition(playerSource)
        text=createElement('text')
        setElementPosition(text, x, y, z)
        setElementData(text, "name", "Text jaki chcesz")
        outputChatBox("Stworzy?e? 3dtext", playerSource)
        setElementData(playerSource, "stworzyltext", true)
    end
end
addCommandHandler("text3", text3)

function markerLeave(leaveElement, matchingDimension)
    if getElementType(leaveElement) == "player" then
        if getElementData(leaveElement, "stworzyltext") and isElement(text) then 
            removeElementData(leaveElement, "stworzyltext")
            destroyElement(text)
        end
    end
end
addEventHandler("onMarkerLeave", Marker, markerLeave)


Kod lekko u?o?y?em estetycznie i poprawi?em jedn? zmienn? gracza w evencie onMarkerLeave.

Postaw piwo autorowi tego posta
 

 
Tagi: 3dtext :: wjechaniu :: marker
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