Wysłany: 2014-05-24, 09:09
xBolekk
Wiek: 24 Na forum: 4474 dni Posty: 113
Nick w MP: Bolek.
Piwa : 190
Witam,
mam kod na tekst 3d, wszystko ?adnie dzia?a, tylko nie wiem jak zrobi?, aby tekst by? widoczny w maksymalnej odleg?o?ci 20m. W tym kodzie tekst wida? na ca?ej mapie
Bardzo prosz? o pomoc. Browce czekaj? .
Cytat: addEventHandler("onClientRender", getRootElement(),
function()
cx, cy, cz = getCameraMatrix()
px, py, pz = 1487.6473388672, 661.15960693359, 10.812507629395
if isLineOfSightClear( cx, cy, cz, px, py, pz, true, false, false, true, false, false, false, getLocalPlayer()) then
local x, y = getScreenFromWorldPosition(px, py, pz)
dxDrawText("WITAJ NA SPAWNIE", x, y, x, y, tocolor(131, 255, 255), 1, "pricedown")
end
end)
Wysłany: 2014-05-24, 11:25
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Cze??
Przyk?ad kodu :
Kod: local fonts = { [ "default" ] = true, [ "default-bold" ] = true,[ "clear" ] = true,[ "arial" ] = true,[ "sans" ] = true,
[ "pricedown" ] = true, [ "bankgothic" ] = true,[ "diploma" ] = true,[ "beckett" ] = true
};
function dxDraw3DText( text, x, y, z, scale, font, r, g, b, maxDistance )
assert( type( text ) == "string", "Bad argument @ dxDraw3DText" );
assert( type( x ) == "number", "Bad argument @ dxDraw3DText" );
assert( type( y ) == "number", "Bad argument @ dxDraw3DText" );
assert( type( z ) == "number", "Bad argument @ dxDraw3DText" );
if not scale or type( scale ) ~= "number" or scale <= 0 then
scale = 2
end
if not font or type( font ) ~= "string" or not fonts[ font ] then
font = "default"
end
if not r or type( r ) ~= "number" or r < 0 or r > 255 then
r = 255
end
if not g or type( g ) ~= "number" or g < 0 or g > 255 then
g = 255
end
if not b or type( b ) ~= "number" or b < 0 or b > 255 then
b = 255
end
if not maxDistance or type( maxDistance ) ~= "number" or maxDistance <= 1 then
maxDistance = 20
end
local textElement = createElement( "text" );
if textElement then
setElementData( textElement, "text", text );
setElementData( textElement, "x", x );
setElementData( textElement, "y", y );
setElementData( textElement, "z", z );
setElementData( textElement, "scale", scale );
setElementData( textElement, "font", font );
setElementData( textElement, "rgba", { r, g, b, 255 } );
setElementData( textElement, "maxDistance", maxDistance );
return textElement
end
return false
end
addEventHandler( "onClientRender", root,
function( )
local texts = getElementsByType( "text" );
if #texts > 0 then
local pX, pY, pZ = getElementPosition( localPlayer );
for i = 1, #texts do
local text = getElementData( texts[i], "text" );
local tX, tY, tZ = getElementData( texts[i], "x" ), getElementData( texts[i], "y" ), getElementData( texts[i], "z" );
local font = getElementData( texts[i], "font" );
local scale = getElementData( texts[i], "scale" );
local color = getElementData( texts[i], "rgba" );
local maxDistance = getElementData( texts[i], "maxDistance" );
if not text or not tX or not tY or not tZ then
return
end
if not font then font = "default" end
if not scale then scale = 2 end
if not color or type( color ) ~= "table" then
color = { 255, 255, 255, 255 };
end
if not maxDistance then maxDistance = 20 end
local distance = getDistanceBetweenPoints3D( pX, pY, pZ, tX, tY, tZ );
if distance <= maxDistance then
local x, y = getScreenFromWorldPosition( tX, tY, tZ );
if x and y then
dxDrawText( text, x, y, _, _, tocolor( color[1], color[2], color[3], color[4] ), scale, font, "center", "center" );
end
end
end
end
end
);
potem tylko nadajesz :
dxDraw3DText( "Tre??", x, y, z,wielko??,"default",255,255,255, 25)
Pozdrawiam
Wysłany: 2014-05-24, 11:55
xBolekk
Wiek: 24 Na forum: 4474 dni Posty: 113
Nick w MP: Bolek.
Piwa : 190
Zrobi?em tak jak mi poda?e? jednak nie dzia?a.
Je?li mo?esz wype?nij mi ten kod, oto kordy napisu:
1487.6473388672, 661.15960693359, 10.812507629395
Napis niech b?dzie: Witaj na spawnie. Czcionka Pricedown.
Piwko czeka
Wysłany: 2014-05-24, 11:56
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Wklej kod wy?ej a pod nim
Kod: tekst = dxDraw3DText( "Witaj na spawnie", 1487.6473388672, 661.15960693359, 10.812507629395,2,"pricedown",255,255,255, 25)
Prosze bardzo.
@edit
U mnie ?miga
Wysłany: 2014-05-24, 12:14
xBolekk
Wiek: 24 Na forum: 4474 dni Posty: 113
Nick w MP: Bolek.
Piwa : 190
Niestety co? mi nie wchodzi, wkleisz ca?y gotowy kod?
Wysłany: 2014-05-24, 12:24
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Wysłany: 2014-05-24, 12:34
xBolekk
Wiek: 24 Na forum: 4474 dni Posty: 113
Nick w MP: Bolek.
Piwa : 190
Nie rozumiem, mo?esz mi da? ten wype?niony kod?
Wysłany: 2014-05-24, 12:35
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
To jest kod na client side. Daj swoj? meta.xml
Wysłany: 2014-05-24, 12:39
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Nie wiesz to nie m?w To co jest w ".." nie ma znaczenia jak wpiszesz. LUA czyta to jako ca?? zawarto?? i pobiera j? z wbudowanym table.concat.
@edit
a je?li ci chodzi?o o zmienn?, ona te? nie ma nic do rzeczy. Ch?opak nie prze?o?y? pliku na c-side.
Ostatnio zmieniony przez MeeShuffle 2014-05-24, 12:41, w całości zmieniany 1 raz
Wysłany: 2014-05-24, 12:39
Zgredek666
LUA
Wiek: 27 Na forum: 4722 dni Posty: 251
Nick w MP: Zgredek
Piwa : 442
Meta ma wygl?da? tak
Kod:
<srcipt src="nazwa.lua" type="client" />
Wysłany: 2014-05-24, 12:40
xBolekk
Wiek: 24 Na forum: 4474 dni Posty: 113
Nick w MP: Bolek.
Piwa : 190
S?uchaj, to m?j kod:
Kod:
local fonts = { [ "default" ] = true, [ "default-bold" ] = true,[ "clear" ] = true,[ "arial" ] = true,[ "sans" ] = true,
[ "pricedown" ] = true, [ "bankgothic" ] = true,[ "diploma" ] = true,[ "beckett" ] = true
};
function dxDraw3DText( text, x, y, z, scale, font, r, g, b, maxDistance )
assert( type( text ) == "string", "Bad argument @ dxDraw3DText" );
assert( type( x ) == "number", "Bad argument @ dxDraw3DText" );
assert( type( y ) == "number", "Bad argument @ dxDraw3DText" );
assert( type( z ) == "number", "Bad argument @ dxDraw3DText" );
if not scale or type( scale ) ~= "number" or scale <= 0 then
scale = 2
end
if not font or type( font ) ~= "string" or not fonts[ font ] then
font = "default"
end
if not r or type( r ) ~= "number" or r < 0 or r > 255 then
r = 255
end
if not g or type( g ) ~= "number" or g < 0 or g > 255 then
g = 255
end
if not b or type( b ) ~= "number" or b < 0 or b > 255 then
b = 255
end
if not maxDistance or type( maxDistance ) ~= "number" or maxDistance <= 1 then
maxDistance = 20
end
local textElement = createElement( "text" );
if textElement then
setElementData( textElement, "text", text );
setElementData( textElement, "x", x );
setElementData( textElement, "y", y );
setElementData( textElement, "z", z );
setElementData( textElement, "scale", scale );
setElementData( textElement, "font", font );
setElementData( textElement, "rgba", { r, g, b, 255 } );
setElementData( textElement, "maxDistance", maxDistance );
return textElement
end
return false
end
addEventHandler( "onClientRender", root,
function( )
local texts = getElementsByType( "text" );
if #texts > 0 then
local pX, pY, pZ = getElementPosition( localPlayer );
for i = 1, #texts do
local text = getElementData( texts[i], "text" );
local tX, tY, tZ = getElementData( texts[i], "x" ), getElementData( texts[i], "y" ), getElementData( texts[i], "z" );
local font = getElementData( texts[i], "font" );
local scale = getElementData( texts[i], "scale" );
local color = getElementData( texts[i], "rgba" );
local maxDistance = getElementData( texts[i], "maxDistance" );
if not text or not tX or not tY or not tZ then
return
end
if not font then font = "default" end
if not scale then scale = 2 end
if not color or type( color ) ~= "table" then
color = { 255, 255, 255, 255 };
end
if not maxDistance then maxDistance = 20 end
local distance = getDistanceBetweenPoints3D( pX, pY, pZ, tX, tY, tZ );
if distance <= maxDistance then
local x, y = getScreenFromWorldPosition( tX, tY, tZ );
if x and y then
dxDrawText( text, x, y, _, _, tocolor( color[1], color[2], color[3], color[4] ), scale, font, "center", "center" );
end
end
end
end
end
);
tekst = dxDraw3DText( "Witaj na spawnie", 1487.6473388672, 661.15960693359, 10.812507629395,2,"pricedown",255,255,255, 25)
Meta:
Kod: <meta>
<info name="3d" author"bolek" type="script" version"1.0.0" />
<script src="napis3d.lua" type="client" />
</meta>
Wysłany: 2014-05-24, 12:42
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Gdzie znajduj? si? te kordy ? Sprawdz? u Siebie.
Tagi: text :: jak :: zrobić :: aby :: było :: widać :: max :: metrów?
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: