Wysłany: 2014-07-26, 00:57
Maciąg
Wiek: 26 Na forum: 4376 dni Posty: 211
Nick w MP: Dawirzo
Piwa : 149
Wysłany: 2014-07-26, 01:00
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Kod i jego zastosowanie podaje ju? 6 raz na tym forum :
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
);
local napis = dxDraw3DText ( "Magazyn ( Aby wej?? wci?nij E )" , 2376.228515625 , - 81.091796875 , 27.567346572876 , 2.3 , "clear" , 255 , 255 , 255 , 25 )
Wysłany: 2014-07-26, 01:11
Maciąg
Wiek: 26 Na forum: 4376 dni Posty: 211
Nick w MP: Dawirzo
Piwa : 149
Ale to jest po prostu na te napisy w powietrzu tak? A masz mo?e na autach te? ?
Podpis
Status prac nad Time to play RPG 25%
Wysłany: 2014-07-26, 01:27
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
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 )
Do tego wgraj swoj? czcionk? o nazwie zachary.ttf
Wysłany: 2014-07-26, 01:32
Maciąg
Wiek: 26 Na forum: 4376 dni Posty: 211
Nick w MP: Dawirzo
Piwa : 149
Dzi?ki, +10 repy dosta?e?, teraz dostaniesz kolejne piwo
Podpis
Status prac nad Time to play RPG 25%
Wysłany: 2014-07-26, 15:07
Mizy1999
I <3 Mta
Wiek: 28 Na forum: 4995 dni Posty: 157
Nick w MP: xxx
Piwa : 154
Maci?g, pom?g? by? z tymi 3d textami, nigdy nie chc? mi dzia?a?, podpinam to pod c-side, na dole edytuje napis, by by? na kordach 0,0,3 a i tak wywala mi error na linijce 55:
Kod: '<name>' expected near '1'
Wysłany: 2014-07-26, 17:32
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Wysłany: 2014-07-26, 20:52
Mizy1999
I <3 Mta
Wiek: 28 Na forum: 4995 dni Posty: 157
Nick w MP: xxx
Piwa : 154
Kod: local text = getElementData( texts[i], "text" );
Prosz?
Wysłany: 2014-07-26, 21:05
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Na pewno w tej jest b??d ? Nikomu innemu nie pokazuje sie on.
Wysłany: 2014-07-26, 21:12
Mizy1999
I <3 Mta
Wiek: 28 Na forum: 4995 dni Posty: 157
Nick w MP: xxx
Piwa : 154
100% P??niej si? zajm? tym skryptem, obecnie bawi? si? z grupami.
Tagi: napisy
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: