xXMADEXx Posted December 30, 2012 Share Posted December 30, 2012 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
Castillo Posted December 30, 2012 Share Posted December 30, 2012 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
xXMADEXx Posted December 30, 2012 Author Share Posted December 30, 2012 The GUI will not show. In "debugscript 3" it says: "Warning: Loading script failed. Test\client:26: unexpected symbol near ')' " Link to comment
xXMADEXx Posted December 30, 2012 Author Share Posted December 30, 2012 Oh, nevermind. Fixed that, but how do i lock the GUI to team Police? Link to comment
Castillo Posted December 30, 2012 Share Posted December 30, 2012 Check the team with: getPlayerTeam getTeamName Link to comment
xXMADEXx Posted December 30, 2012 Author Share Posted December 30, 2012 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
GhostXoP Posted December 30, 2012 Share Posted December 30, 2012 Not enough information, What is wrong. Link to comment
DNL291 Posted December 30, 2012 Share Posted December 30, 2012 --[[ 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
xXMADEXx Posted January 1, 2013 Author Share Posted January 1, 2013 --[[ 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
manve1 Posted January 1, 2013 Share Posted January 1, 2013 tells us the problem if it didn't work Link to comment
xXMADEXx Posted January 2, 2013 Author Share Posted January 2, 2013 tells us the problem if it didn't work The GUI doesn't show for anyone. Even if on the Police/SWAT/Military team Link to comment
manve1 Posted January 2, 2013 Share Posted January 2, 2013 (edited) 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 January 2, 2013 by Guest Link to comment
3NAD Posted January 2, 2013 Share Posted January 2, 2013 -- 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now