Jump to content

Help With GUI


xXMADEXx

Recommended Posts

How can i make it so that when someone presses "F5" the GUI becomes visible, but if the GUI is visible it will close if you press F5 again. And, when someone closes then opens the GUI again all the names are in there twice. Any way to fix that?

police_window = guiCreateWindow(350,205,728,380,"RoG Police Window",false) 
guiSetVisible(police_window, false) 
guiSetAlpha(police_window,1) 
guiWindowSetSizable(police_window,false) 
  
playerList = guiCreateGridList(14,34,699,272,false,police_window) 
column = guiGridListAddColumn(playerList,"Name",0.2) 
  
police_closeBTN = guiCreateButton(163,325,416,36,"Close",false,police_window) 
  
bindKey("F5", "down",  
  
function ( ) 
    if ( guiGetVisible ( police_window ) == false ) then  
        showCursor(true) 
        guiSetVisible(police_window,true) 
        guiSetVisible(playerList, true) 
        guiSetVisible(column, true) 
        if ( column ) then 
            for id, player in ipairs ( getElementsByType ( "player" ) ) do 
                local row = guiGridListAddRow ( playerList ) 
                local r, g, b = getPlayerNametagColor ( player ) 
                guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) 
                guiGridListSetItemColor ( playerList, row, column, r, g, b ) 
            end 
        end 
    else 
        if ( guiGetVisible ( police_window ) == false ) then  
            guiSetVisible(police_window, true) 
            guiSetVisible(playerList, true) 
            guiSetVisible(column, true) 
            showCursor(true) 
        end 
    end 
end 
) 
  
-- Close the window 
function close() 
    guiSetVisible(police_window, false) 
    guiSetVisible(playerList, false) 
    guiSetVisible(column, false) 
    showCursor(false,false) 
end 
addEventHandler("onClientGUIClick", police_closeBTN, close) 
  

Link to comment
police_window = guiCreateWindow(350,205,728,380,"RoG Police Window",false) 
guiSetVisible(police_window, false) 
guiSetAlpha(police_window,1) 
guiWindowSetSizable(police_window,false) 
  
playerList = guiCreateGridList(14,34,699,272,false,police_window) 
column = guiGridListAddColumn(playerList,"Name",0.2) 
  
police_closeBTN = guiCreateButton(163,325,416,36,"Close",false,police_window) 
  
bindKey("F5", "down", 
function ( ) 
    guiSetVisible(police_window, not guiGetVisible ( police_window )) 
    showCursor(guiGetVisible ( police_window )) 
    if ( guiGetVisible ( police_window ) ) then 
        guiGridListClear ( playerList ) 
        if ( column ) then 
            for id, player in ipairs ( getElementsByType ( "player" ) ) do 
                local row = guiGridListAddRow ( playerList ) 
                local r, g, b = getPlayerNametagColor ( player ) 
                guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) 
                guiGridListSetItemColor ( playerList, row, column, r, g, b ) 
            end 
        end 
    end 
) 
  
-- Close the window 
function close() 
    guiSetVisible(police_window, false) 
    guiSetVisible(playerList, false) 
    guiSetVisible(column, false) 
    showCursor(false,false) 
end 
addEventHandler("onClientGUIClick", police_closeBTN, close) 

Link to comment
Check the team with:
getPlayerTeam 
getTeamName 

okey, i read those, now i have this code, but it dosn't work.

--[[ 
Author: xXMADEXx, with Castillo's Help 
File: client.lua 
type: client 
Copyright 2012 (c) xXMADEXx 
--]] 
  
function cancelPedDamage ( attacker ) 
    cancelEvent() 
end 
addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage ) 
  
    police_window = guiCreateWindow(350,205,728,380,"RoG Police Window",false) 
    guiSetVisible(police_window, false) 
    guiSetAlpha(police_window,1) 
    guiWindowSetSizable(police_window,false) 
      
    playerList = guiCreateGridList(14,34,699,272,false,police_window) 
    column = guiGridListAddColumn(playerList,"Name",0.2) 
      
    police_closeBTN = guiCreateButton(163,325,416,36,"Close",false,police_window) 
      
    bindKey("F4", "down", 
    function ( ) 
        name = getTeamName(getPlayerTeam(player)) 
        if ( name == "Police" ) or ( name == "Military" ) or  ( name == "FBI" ) or ( name == "Swat" ) then 
            guiSetVisible(police_window, not guiGetVisible ( police_window )) 
            showCursor(guiGetVisible ( police_window )) 
            if ( guiGetVisible ( police_window ) ) then 
                guiGridListClear ( playerList ) 
                if ( column ) then 
                    for id, player in ipairs ( getElementsByType ( "player" ) ) do 
                        local row = guiGridListAddRow ( playerList ) 
                        local r, g, b = getPlayerNametagColor ( player ) 
                        guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) 
                        guiGridListSetItemColor ( playerList, row, column, r, g, b ) 
                    end 
                end 
            end  
        end 
    end 
    ) 
      
    -- Close Button 
    function close() 
        guiSetVisible(police_window, false) 
        guiSetVisible(playerList, false) 
        guiSetVisible(column, false) 
        showCursor(false,false) 
    end 
    addEventHandler("onClientGUIClick", police_closeBTN, close) 

Link to comment
--[[ 
Author: xXMADEXx, with Castillo's Help 
File: client.lua 
type: client 
Copyright 2012 (c) xXMADEXx 
--]] 
  
function cancelPedDamage ( attacker ) 
    cancelEvent() 
end 
addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage ) 
  
    police_window = guiCreateWindow(350,205,728,380,"RoG Police Window",false) 
    guiSetVisible(police_window, false) 
    guiSetAlpha(police_window,1) 
    guiWindowSetSizable(police_window,false) 
      
    playerList = guiCreateGridList(14,34,699,272,false,police_window) 
    column = guiGridListAddColumn(playerList,"Name",0.2) 
      
    police_closeBTN = guiCreateButton(163,325,416,36,"Close",false,police_window) 
      
    bindKey("F4", "down", 
    function ( ) 
        name = getTeamName(getPlayerTeam(player)) 
        if ( name == "Police" ) or ( name == "Military" ) or  ( name == "FBI" ) or ( name == "Swat" ) then 
            guiSetVisible(police_window, false) 
        end 
            guiSetVisible(police_window, not guiGetVisible ( police_window )) 
            showCursor(guiGetVisible ( police_window )) 
            if ( guiGetVisible ( police_window ) ) then 
                guiGridListClear ( playerList ) 
                if ( column ) then 
                    for id, player in ipairs ( getElementsByType ( "player" ) ) do 
                        local row = guiGridListAddRow ( playerList ) 
                        local r, g, b = getPlayerNametagColor ( player ) 
                        guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) 
                        guiGridListSetItemColor ( playerList, row, column, r, g, b ) 
                    end 
                end 
            end 
        end 
    end 
    ) 
      
    -- Close Button 
    function close() 
        guiSetVisible(police_window, false) 
        guiSetVisible(playerList, false) 
        guiSetVisible(column, false) 
        showCursor(false,false) 
    end 
    addEventHandler("onClientGUIClick", police_closeBTN, close) 

Link to comment
--[[ 
Author: xXMADEXx, with Castillo's Help 
File: client.lua 
type: client 
Copyright 2012 (c) xXMADEXx 
--]] 
  
function cancelPedDamage ( attacker ) 
    cancelEvent() 
end 
addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage ) 
  
    police_window = guiCreateWindow(350,205,728,380,"RoG Police Window",false) 
    guiSetVisible(police_window, false) 
    guiSetAlpha(police_window,1) 
    guiWindowSetSizable(police_window,false) 
      
    playerList = guiCreateGridList(14,34,699,272,false,police_window) 
    column = guiGridListAddColumn(playerList,"Name",0.2) 
      
    police_closeBTN = guiCreateButton(163,325,416,36,"Close",false,police_window) 
      
    bindKey("F4", "down", 
    function ( ) 
        name = getTeamName(getPlayerTeam(player)) 
        if ( name == "Police" ) or ( name == "Military" ) or  ( name == "FBI" ) or ( name == "Swat" ) then 
            guiSetVisible(police_window, false) 
        end 
            guiSetVisible(police_window, not guiGetVisible ( police_window )) 
            showCursor(guiGetVisible ( police_window )) 
            if ( guiGetVisible ( police_window ) ) then 
                guiGridListClear ( playerList ) 
                if ( column ) then 
                    for id, player in ipairs ( getElementsByType ( "player" ) ) do 
                        local row = guiGridListAddRow ( playerList ) 
                        local r, g, b = getPlayerNametagColor ( player ) 
                        guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) 
                        guiGridListSetItemColor ( playerList, row, column, r, g, b ) 
                    end 
                end 
            end 
        end 
    end 
    ) 
      
    -- Close Button 
    function close() 
        guiSetVisible(police_window, false) 
        guiSetVisible(playerList, false) 
        guiSetVisible(column, false) 
        showCursor(false,false) 
    end 
    addEventHandler("onClientGUIClick", police_closeBTN, close) 

Thanks, but it didn't work.

Link to comment

try this:

--[[ 
Author: xXMADEXx, with Castillo's Help 
File: client.lua 
type: client 
Copyright 2012 (c) xXMADEXx 
--]] 
  
function cancelPedDamage ( ) 
    cancelEvent() 
end 
addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage ) 
  
    local police_window = guiCreateWindow(350,205,728,380,"RoG Police Window",false) 
    guiSetVisible(police_window, false) 
    guiSetAlpha(police_window,1) 
    guiWindowSetSizable(police_window,false) 
      
    local playerList = guiCreateGridList(14,34,699,272,false,police_window) 
    local column = guiGridListAddColumn(playerList,"Name",0.2) 
      
    local police_closeBTN = guiCreateButton(163,325,416,36,"Close",false,police_window) 
      
    bindKey("F4", "down", 
    function ( ) 
        name = getTeamName(getPlayerTeam(localPlayer)) 
        if ( name == "Police" ) or ( name == "Military" ) or  ( name == "FBI" ) or ( name == "Swat" ) then 
        guiSetVisible(police_window, not guiGetVisible ( police_window )) 
            showCursor(guiGetVisible ( police_window )) 
            if ( guiGetVisible ( police_window ) ) then 
                guiGridListClear ( playerList ) 
                if ( column ) then 
                    for id, player in ipairs ( getElementsByType ( "player" ) ) do 
                        local row = guiGridListAddRow ( playerList ) 
                        local r, g, b = getPlayerNametagColor ( player ) 
                        guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) 
                        guiGridListSetItemColor ( playerList, row, column, r, g, b ) 
                    end 
                end 
            end 
        else 
            guiSetVisible(police_window, false) 
        end 
        end 
    end 
    ) 
      
    -- Close Button 
    function close() 
        guiSetVisible(police_window, false) 
        showCursor(false) 
    end 
    addEventHandler("onClientGUIClick", police_closeBTN, close) 

Edited by Guest
Link to comment
-- Try this 
function cancelPedDamage ( ) 
    cancelEvent ( ) 
end 
addEventHandler ( "onClientPedDamage", root, cancelPedDamage ) 
  
police_window = guiCreateWindow(350,205,728,380,"RoG Police Window",false) 
guiSetVisible(police_window, false) 
guiSetAlpha(police_window,1) 
guiWindowSetSizable(police_window,false) 
  
playerList = guiCreateGridList(14,34,699,272,false,police_window) 
column = guiGridListAddColumn(playerList,"Name",0.2) 
  
police_closeBTN = guiCreateButton(163,325,416,36,"Close",false,police_window) 
  
Teams = { 
    ["Police"] = true, 
    ["Military"] = true, 
    ["FBI"] = true, 
    ["Swat"] = true, 
} 
     
bindKey ( "F4", "down", 
    function ( ) 
        if getPlayerTeam ( localPlayer ) then 
            if Teams [ getTeamName ( getPlayerTeam ( localPlayer  ) ) ] then 
                if not guiGetVisible ( police_window ) then  
                    showCursor ( true ) 
                    guiSetVisible ( police_window, true ) 
                    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
                        local row = guiGridListAddRow ( playerList ) 
                        local r, g, b = getPlayerNametagColor ( player ) 
                        local playerName = getPlayerName ( player ) 
                        guiGridListSetItemText ( playerList, row, column, playerName, false, false ) 
                        guiGridListSetItemColor ( playerList, row, column, r, g, b ) 
                    end 
                else 
                    guiSetVisible ( police_window, false ) 
                    showCursor ( false ) 
                    guiGridListClear ( playerList ) 
                end 
            end 
        end 
    end 
) 
      
-- Close Button 
function close ( ) 
    guiSetVisible ( police_window, false ) 
    showCursor ( false ) 
    guiGridListClear ( playerList ) 
end 
addEventHandler ( "onClientGUIClick", police_closeBTN, close ) 

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...