Jump to content

[HELP] bindKey if in group


Recommended Posts

Hey guys,

I have this in my script no errors no debug but it doesn't work.

        function () 
            local playerTeam = getPlayerTeam ( source ) == getTeamFromName ( "Police" )  
            if ( playerTeam ) then     
            bindKey("F2", "down", showPolicePanel) 
            end 
        end 
        ) 

Link to comment

Still don't work; Full script >>

GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {} 
} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        --WINDOW 
        policeWindow = guiCreateWindow (375, 125, 500, 500, "Police Panel", false) 
        guiWindowSetSizable (policeWindow, false) 
        guiWindowSetMovable (policeWindow, false) 
        guiSetVisible (policeWindow, false) 
         
        -- GRIDLIST 
        policeGridList = guiCreateGridList (16, 35, 240, 444, false, policeWindow) 
        policeNameList = guiGridListAddColumn (policeGridList, "Name", 0.4) 
            local row = guiGridListAddRow(policeGridList) 
                for _, player in ipairs ( getElementsByType ( "player" ) ) do 
                    guiGridListSetItemText ( policeGridList, row, policeNameList, (string.gsub ( getPlayerName ( player ), '#%x%x%x%x%x%x', '' ) or getPlayerName(player)), false, false) 
                    guiGridListSetItemData ( policeGridList, row, policeNameList, getPlayerName(player)) 
                end 
            policeWantedLevelList = guiGridListAddColumn (policeGridList, "Wanted", 0.4) 
                for _, player in ipairs ( getElementsByType ( "player" ) ) do 
                    guiGridListSetItemText ( policeGridList, row, policeWantedLevelList, (string.gsub ( getPlayerWantedLevel ( player ), '#%x%x%x%x%x%x', '' ) or getPlayerWantedLevel(player)), false, false) 
                    guiGridListSetItemData ( policeGridList, row, policeWantedLevelList, getPlayerWantedLevel(player)) 
                end 
         
        --BUTTONS 
            -- Close Button 
        policeCloseButton = guiCreateButton (272, 430, 218, 39, "Close", false, policeWindow) 
            -- Track Player 
        policeTrackPlayerButton = guiCreateButton (272, 378, 218, 39, "Track Player", false, policeWindow)     
        addEventHandler("onClientGUIClick", policeTrackPlayerButton,  
        function () 
            local playerName = guiGridListGetItemText ( policeGridList, guiGridListGetSelectedItem ( policeGridList ), 1 ) 
            createBlip (playerName, 58) 
        end 
        ) 
            -- Bind Key F2 
        addEventHandler("onClientResourceStart", resourceRoot, 
        function () 
            local playerTeam = getPlayerTeam ( localPlayer ) == getTeamFromName ( "Police" )  
            if ( playerTeam ) then     
            bindKey("F2", "down", showPolicePanel) 
            end 
        end 
        ) 
        addEventHandler("onClientGUIClick", policeCloseButton, hidePolicePanel) 
    end 
) 
  
function showPolicePanel () 
    guiSetVisible (policeWindow, true) 
    showCursor (true) 
end 
  
function hidePolicePanel () 
    guiSetVisible (policeWindow, false) 
    showCursor (false) 
end 

Link to comment

Try this:

addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        --WINDOW 
        policeWindow = guiCreateWindow (375, 125, 500, 500, "Police Panel", false) 
        guiWindowSetSizable (policeWindow, false) 
        guiWindowSetMovable (policeWindow, false) 
        guiSetVisible (policeWindow, false) 
        
        -- GRIDLIST 
        policeGridList = guiCreateGridList (16, 35, 240, 444, false, policeWindow) 
        policeNameList = guiGridListAddColumn (policeGridList, "Name", 0.4) 
            local row = guiGridListAddRow(policeGridList) 
                for _, player in ipairs ( getElementsByType ( "player" ) ) do 
                    guiGridListSetItemText ( policeGridList, row, policeNameList, (string.gsub ( getPlayerName ( player ), '#%x%x%x%x%x%x', '' ) or getPlayerName(player)), false, false) 
                    guiGridListSetItemData ( policeGridList, row, policeNameList, getPlayerName(player)) 
                end 
            policeWantedLevelList = guiGridListAddColumn (policeGridList, "Wanted", 0.4) 
                for _, player in ipairs ( getElementsByType ( "player" ) ) do 
                    guiGridListSetItemText ( policeGridList, row, policeWantedLevelList, (string.gsub ( getPlayerWantedLevel ( player ), '#%x%x%x%x%x%x', '' ) or getPlayerWantedLevel(player)), false, false) 
                    guiGridListSetItemData ( policeGridList, row, policeWantedLevelList, getPlayerWantedLevel(player)) 
                end 
        
        --BUTTONS 
            -- Close Button 
        policeCloseButton = guiCreateButton (272, 430, 218, 39, "Close", false, policeWindow) 
            -- Track Player 
        policeTrackPlayerButton = guiCreateButton (272, 378, 218, 39, "Track Player", false, policeWindow)     
        addEventHandler("onClientGUIClick", policeTrackPlayerButton, 
        function () 
            local playerName = guiGridListGetItemText ( policeGridList, guiGridListGetSelectedItem ( policeGridList ), 1 ) 
            createBlip (playerName, 58) 
        end 
        ) 
        -- Bind Key F2   
        bindKey("F2", "down", showPolicePanel) 
         
        addEventHandler("onClientGUIClick", policeCloseButton, hidePolicePanel) 
    end 
) 
  
function showPolicePanel () 
    local playerTeam = getPlayerTeam ( localPlayer ) 
    if (playerTeam) and (playerTeam == getTeamFromName("Police")) then 
        guiSetVisible (policeWindow, true) 
        showCursor (true) 
    end 
end 
  
function hidePolicePanel () 
    guiSetVisible (policeWindow, false) 
    showCursor (false) 
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...