Jump to content

Панель разговоров


Recommended Posts

У меня тут какой-то капец вышел конкретный..

Идея такова, при нажатии F2 вывести окно на экран игрока в котором будут кнопки нажимая которые закрывалось окно, в чат выводилось сообщение и вокруг игрока НАЖАВШЕГО кнопку звучал звук, и по завершению он не повторялся.

 

Вот вам эта тупая куча и прошу не совмещать мою тему т.к по ситуации что-то искал и не мог найти...

 

  
addEventHandler( "onClientResourceStart", resourceRoot ) 
    function() 
        bindKey ( "F2", "down", showGUI) 
    end 
) 
  
GUIEditor_Window = {} 
GUIEditor_Button = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0.3,0.2,0.4,0.5,"Панель разговоров",true) 
guiSetAlpha(GUIEditor_Window[1],225) 
guiSetVisible(GUIEditor_Window[1],true) 
GUIEditor_Button[1] = guiCreateButton(0.52,0.55,0.45,0.1,"Молодец",true,GUIEditor_Window[1]) 
addEventHandler("onClientGUIClick",getRootElement(), 
  
function (player) 
   if (source == GUIEditor_Button[1]) then 
   player = getLocalPlayer() 
   outputChatBox ( ..getPlayerName(source).."сказал: Молодец", getRootElement(), 255, 0, 0, true ) 
   guiSetVisible (GUIEditor_Window[1],false) 
   showCursor (false) 
   end 
  end 
end) 
  
addEvent( "molodca", true ) 
function molodec ( player ) 
    if (source == GUIEditor_Button[1]) then 
        elseif (isElement(player)) then 
            local Zx,Zy,Zz = getElementPosition( ped ) 
            local sound = playSound3D("molodca.ogg", Zx, Zy, Zz, true) 
            setSoundMaxDistance(sound, 20) 
    end 
end 
addEventHandler( "molodca", getRootElement(), molodec ) 
  
function showGUI()  
    if ( guiGetVisible ( GUIEditor_Window[1] ) == false ) then        
        guiSetVisible ( GUIEditor_Window[1], true ) 
        showCursor(true) 
    elseif ( guiGetVisible ( GUIEditor_Window[1]) == true ) then 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        showCursor(false) 
    end 
end 

Link to comment
bindKey( "F2", "down", showGUI ); 
  
GUIEditor_Window = {} 
GUIEditor_Button = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0.3,0.2,0.4,0.5,"Панель разговоров",true) 
guiSetAlpha( GUIEditor_Window[1],225) -- Альфа GUI указывается в процентах, т.е. от 0,0 до 1,0 
guiSetVisible( GUIEditor_Window[1],true) 
GUIEditor_Button[ 1 ] = guiCreateButton(0.52,0.55,0.45,0.1,"Молодец",true,GUIEditor_Window[1]) 
  
addEventHandler( "onClientGUIClick", GUIEditor_Button[1], -- достаточно повесить событие сразу на елемент и ... 
    function ( player ) 
        -- if (source == GUIEditor_Button[1]) then -- ... и убрать вот эту проверку (меньше нагрузки на CPU) 
            -- player = getLocalPlayer() -- Зачем это? 
            outputChatBox ( --[[ .. это зачем? ]]getPlayerName(source).."сказал: Молодец", --[[ getRootElement(), зачем это? ]]255, 0, 0, true ) 
            -- getPlayerName(source) вы пытаетесь получить имя игрока, а в аргумент даёте GUI-кнопку.. 
            guiSetVisible (GUIEditor_Window[1],false) 
            showCursor (false) 
        -- end 
    end, 
    false -- это нужно чтобы событие не срабатывало на другие елементы. 
); 
  
addEvent( "molodca", true ) 
function molodec ( player ) 
    if (source == GUIEditor_Button[1]) then -- тоже не понятно зачем это. 
    elseif (isElement(player)) then 
        local Zx,Zy,Zz = getElementPosition( ped ) -- откуда появилась переменная ped? 
        local sound = playSound3D("molodca.ogg", Zx, Zy, Zz, true) -- true указывает на loop, Т.е. будет бесконечно повторяться. 
        setSoundMaxDistance(sound, 20) 
    end 
end 
addEventHandler( "molodca", getRootElement(), molodec ) 
  
function showGUI() -- немного переделал 
    local visible = not guiGetVisible( GUIEditor_Window[1] ); 
     
    guiSetVisible( GUIEditor_Window[1], visible ); 
    showCursor( visible ); 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...