Wysłany: 2020-06-19, 01:12
Matikmontana
Modern Stories
Wiek: 22 Na forum: 2473 dni Posty: 423
Nick w MP: Mazeusz*
Piwa : 1015
Dobry, mam problem dotycz?cy renderu gui pod przycisk. Chcia?bym zrobi? ?e po trzymaniu lalt pokazuje si? gui zawieszenia. Zrobi?em tak ale jest b?ad w db3 https://imgur.com/a/hzt728h
local sX , sY = guiGetScreenSize ()
local screenW , screenH = guiGetScreenSize ()
local font = dxCreateFont ( ":czcionka/f.ttf" , 12 ) or "default"
zawieszienie = false
screen = Vector2 ( guiGetScreenSize ())
function scale_x ( value )
if not value then return nil end
return ( value / 1920 ) * screen [ 'x' ]
end
function scale_y ( value )
if not value then return nil end
return ( value / 1080 ) * screen [ 'y' ]
end
function isMouseIn ( psx , psy , pssx , pssy , abx , aby )
if not isCursorShowing () then return end
sx , sy = guiGetScreenSize ()
cx , cy = getCursorPosition ()
cx , cy = cx * sx , cy * sy
if cx >= psx and cx <= psx + pssx and cy >= psy and cy <= psy + pssy then
return true , cx , cy
else
return false
end
end
function zawieszonko ()
dxDrawRectangle ( scale_x ( 0 ), scale_y ( 1013 ), scale_x ( 411 ), scale_y ( 67 ), tocolor ( 1 , 0 , 0 , 189 ), false )
dxDrawRectangle ( scale_x ( 4 ), scale_y ( 1027 ), scale_x ( 156 ), scale_y ( 43 ), tocolor ( 234 , 227 , 31 , 189 ), false )
dxDrawRectangle ( scale_x ( 186 ), scale_y ( 1027 ), scale_x ( 156 ), scale_y ( 43 ), tocolor ( 234 , 227 , 31 , 189 ), false )
dxDrawText ( "NI?EJ" , scale_x ( 2 ), scale_y ( 1025 ), scale_x ( 160 ), scale_y ( 1070 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font , "center" , "center" , false , false , false , false , false )
dxDrawText ( "WY?EJ" , scale_x ( 184 ), scale_y ( 1025 ), scale_x ( 342 ), scale_y ( 1070 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font , "center" , "center" , false , false , false , false , false )
dxDrawText ( "RH1" , scale_x ( 355 ), scale_y ( 1017 ), scale_x ( 558 ), scale_y ( 1086 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font , "left" , "center" , false , false , false , false , false )
dxDrawText ( "X" , scale_x ( 378 ), scale_y ( 1014 ), scale_x ( 411 ), scale_y ( 1037 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font , "right" , "top" , false , false , false , false , false )
end
addEventHandler ( "onClientClick" , root , function( btn , state )
if zawieszenie == true and btn == "left" and state == "down" then
local veh = getPedOccupiedVehicle ( localPlayer )
if isMouseIn ( scale_x ( 186 ), scale_y ( 1027 ), scale_x ( 156 ), scale_y ( 43 )) then
triggerServerEvent ( "rh:p" , root , veh )
elseif isMouseIn ( scale_x ( 4 ), scale_y ( 1027 ), scale_x ( 156 ), scale_y ( 43 )) then
triggerServerEvent ( "rh:o" , root , veh )
elseif isMouseIn ( scale_x ( 378 ), scale_y ( 1014 ), scale_x ( 33 ), scale_y ( 23 )) then
removeEventHandler ( "onClientRender" , root , zawieszonko )
triggerEvent ( "createNotif" , localPlayer , "Wy??czono panel RH1\nW??czysz go wchodz?c ponownie do pojazdu" , 3 )
zawieszenie = false
end
end
end )
--[[ bindKey ( "F2" , "down" ,function()
if zawieszonko == false then
showCursor ( true )
zawieszenie = true
else
zawieszenie = false
showCursor ( false )
end
end )]]
bindKey ( "lalt" , "both" ,function( patch )
local veh = getPedOccupiedVehicle ( localPlayer )
if not veh then
removeEventHandler ( "onClientRender" , root , zawieszonko )
zawieszenie = false
end
end )
addEventHandler ( "onClientRender" , root , patch )
function show ()
addEventHandler ( "onClientRender" , root , zawieszonko )
zawieszenie = true
end
addEvent ( "rhshow" , true )
addEventHandler ( "rhshow" , root , show )
fileDelete ( "c.lua" )
Wysłany: 2020-06-19, 10:57
Qwertick
Coming soon...
Wiek: 23 Na forum: 3577 dni Posty: 472
Nick w MP: Qwertick
Piwa : 2726
Wysłany: 2020-06-19, 11:26
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Więcej informacji znajdziesz w Wikipedii MTA: getKeyState
w evencie onClientRender
Wysłany: 2020-06-20, 17:36
Matikmontana
Modern Stories
Wiek: 22 Na forum: 2473 dni Posty: 423
Nick w MP: Mazeusz*
Piwa : 1015
Zrobi?em tak tylko ?e po wcisnieciu klawisza miga, oraz miga te? poza pojazdem
function patch ()
local veh = getPedOccupiedVehicle ( localPlayer )
if not veh then
removeEventHandler ( "onClientRender" , root , zawieszonko )
zawieszenie = false
end
end
-- addEventHandler ( "onClientRender" , root , patch )
bindKey ( "z" , "both" , zawieszonko , show , patch )
function show ()
zawieszenie = true
end
addEvent ( "rhshow" , true )
addEventHandler ( "rhshow" , root , show )
fileDelete ( "c.lua" )
Wysłany: 2020-06-20, 19:11
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
addEventHandler ( "onClientRender" , root , function()
if getKeyState ( "z" ) then
-- funkcja
end
end )
Tagi: gui :: zawieszenie
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: