Wysłany: 2021-01-15, 18:24
xyzzz^
A nic
Wiek: 18 Na forum: 1993 dni Posty: 319
Nick w MP: Aspyk21
Piwa : 308
Mam problem, chce aby mie? komende np.
/info <moja wiadomosc>
lecz nie dzia?a
kod:
function informacja ( ps , cmd )
if not getPlayerFromSerial ( serials ) then
return
end
triggerClientEvent ( root , "dxPickupsText" , root , cmd , 255 , 255 , 255 )
end
addCommandHandler ( "info" , informacja )
Wysłany: 2021-01-15, 18:28
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Przeczytaj co dok?adnie robi ta funkcja:
Musisz j? zdefiniowa? w kodzie. masz zak?adk? "CODE".
No i pytanie czy event masz dodany, wklej jego kod...
Wysłany: 2021-01-15, 19:35
xyzzz^
A nic
Wiek: 18 Na forum: 1993 dni Posty: 319
Nick w MP: Aspyk21
Piwa : 308
"Wilq" napisał/a :Przeczytaj co dok?adnie robi ta funkcja:
Musisz j? zdefiniowa? w kodzie. masz zak?adk? "CODE".
No i pytanie czy event masz dodany, wklej jego kod...
funkcja dziala, uzywam jej do wiekoszci skrypt?w, co do eventu dzia?a przy innych skryptach wi?c to wina kodu, kt?ry zrobi?em
[ Dodano : 2021-01-15, 19:36 ]
server
-- HUD UP TEXT
local font = dxCreateFont ( "notification_font/font.ttf" , 20 )
local screenWidth , screenHeight = guiGetScreenSize ( )
local px , py = 1600 , 900
local x , y = ( screenWidth / px ), ( screenHeight / py )
function dxPickupsText ( szText , r , g , b )
if notifyDataText then
removeEventHandler ( "onClientRender" , root , dxPickupsTextRender )
notifyDataText = nil
end
notifyDataText = { szText , r , g , b }
addEventHandler ( "onClientRender" , root , dxPickupsTextRender )
end
addEvent ( "dxPickupsText" , true )
addEventHandler ( "dxPickupsText" , root , dxPickupsText )
function dxPickupsTextRender ( )
if not notifyDataText then
return
end
local text , r , g , b = notifyDataText [ 1 ], notifyDataText [ 2 ], notifyDataText [ 3 ], notifyDataText [ 4 ]
local foto = dxCreateTexture ( "foto.png" )
dxDrawImage ( screenWidth * 0.30 , screenHeight * 0.005 , screenWidth * 0.40 , screenHeight * 0.04 , foto , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 230 ), false )
dxDrawText ( text , 0 , screenHeight * 0.015 , screenWidth , screenHeight * 0.5 , tocolor ( 255 , 255 , 255 , 255 ), y * 0.50 , font , "center" )
setTimer ( function( )
removeEventHandler ( "onClientRender" , root , dxPickupsTextRender )
end , 10000 , 1 )
end
client
-- EFFECT NOTIFICATION
sx , sy = guiGetScreenSize ()
x , y = ( sx / 1366 ), ( sy / 768 )
font = dxCreateFont ( "notification_font/font.ttf" , 16 )-- "clear-normal"
function Notification ( result , text )
if result == "sucess" then
addNotification ( text , 46 , 204 , 113 )
elseif result == "error" then
addNotification ( text , 231 , 76 , 60 )
end
end
addEvent ( "frag_notification_text" , true )
addEventHandler ( "frag_notification_text" , root , Notification )
function addNotification ( text , r , g , b )
if notifyData then
removeEventHandler ( "onClientRender" , root , renderNotification )
notifyData = nil
end
notifyData = { text , r , g , b , getTickCount (), getTickCount () + 4000 , false }
addEventHandler ( "onClientRender" , root , renderNotification )
end
function renderNotification ( )
if not notifyData then
return
end
local now = getTickCount ()
local text , r , g , b = notifyData [ 1 ], notifyData [ 2 ], notifyData [ 3 ], notifyData [ 4 ]
local notifyStart , notifyEnd = notifyData [ 5 ], notifyData [ 6 ]
local progress = ( now - notifyStart ) / (( notifyEnd - 3000 ) - notifyStart )
if now > notifyEnd and not notifyData [ 7 ] then
notifyData [ 5 ] = now
notifyData [ 6 ] = getTickCount ()+ 1000
notifyData [ 7 ] = true -- fade
notifyStart , notifyEnd = notifyData [ 5 ], notifyData [ 6 ]
end
local interpolatedProgress = 0
if notifyData [ 7 ] then
progress = ( now - notifyStart ) / ( notifyEnd - notifyStart )
interpolatedProgress = interpolateBetween ( 1 , 0 , 0 , 0 , 0 , 0 , progress , "InOutQuad" )
if interpolatedProgress <= 0 then
notifyData = nil
removeEventHandler ( "onClientRender" , root , renderNotification )
return
end
else
interpolatedProgress = interpolateBetween ( 0 , 0 , 0 , 1 , 0 , 0 , math . min ( progress , 1 ), "InOutQuad" )
end
local offsetY = ( 20 * y ) * interpolatedProgress
local foto = dxCreateTexture ( "foto.png" )
dxDrawImage ( x * 460 , y * 20 + offsetY , x * 460 , y * 40 , foto , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 230 * interpolatedProgress ), true )
dxDrawText ( text , x * 460 , y *- 150 + offsetY ,( x * 460 )* 2 ,( y * 50 )+( y * 180 )+ offsetY , tocolor ( 255 , 255 , 255 , 255 * interpolatedProgress ), y * 0.6 , font , "center" , "center" , false , true , true , true )
end
Wysłany: 2021-01-15, 19:58
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
To gdzie jest zdefiniowana zmienna 'serials'? Komenda po stronie serwera czy klienta? Pod zmienn? "cmd" masz nazw? komendy - dobrze to przekazujesz?
Wysłany: 2021-01-15, 20:04
xyzzz^
A nic
Wiek: 18 Na forum: 1993 dni Posty: 319
Nick w MP: Aspyk21
Piwa : 308
"Wilq" napisał/a :To gdzie jest zdefiniowana zmienna 'serials'? Komenda po stronie serwera czy klienta? Pod zmienn? "cmd" masz nazw? komendy - dobrze to przekazujesz?
serials tam jest m?j serial, wpisalem serials zeby nikt go nie znal,a co do cmd wszystko co mam jest wyzej po prostu nie wyswietla informacji
Wysłany: 2021-01-15, 20:45
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Wklei?e? kod z klienta i podpisa?e? jako serwer, na pewno masz dobrze met??
Wysłany: 2021-01-15, 22:21
xyzzz^
A nic
Wiek: 18 Na forum: 1993 dni Posty: 319
Nick w MP: Aspyk21
Piwa : 308
Pomy?ka, to s? 2 client'y
Wysłany: 2021-01-16, 15:00
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Turbo idiotyczny kod, tworzysz tekstur? w evencie onClientRender - brak optymalizacji (dxCreateTexture), dalej: robisz TIMER w evencie onClientRender. 10 sekund ma min?? zanim usuniesz event, obliczamy: 10 (s) * 1000 (ms) = Stworzysz 10000 timer?w w ci?gu 10 sekund.
Nie mo?esz u?ywa? tych 2 funkcji w evencie onClientRender.
Popraw to, sprawd? kod i wtedy daj zna? o efektach - wklej poprawiony kod.
Tagi: informacja
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: