Jump to content

GUI won't open


ViRuZGamiing

Recommended Posts

Hello,

My GUI won't open when i'm in the Team called Police with F2.

No Error's or Debug,

Script:

GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {} 
} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        --WINDOW 
        policeF2Window = guiCreateWindow (375, 125, 500, 500, "Police Panel", false) 
        guiWindowSetSizable (policeF2Window, false) 
        guiWindowSetMovable (policeF2Window, false) 
        guiSetVisible (policeF2Window, false) 
         
        -- GRIDLIST 
        policeGridList = guiCreateGridList (16, 35, 240, 444, false, policeF2Window) 
        policeNameList = guiGridListAddColumn (policeGridList, "Name", 0.6) 
            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.2) 
                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 
        policeGiveWantedList = guiCreateGridList (273, 35, 217, 235, false, policeF2Window) 
        row2 = guiGridListAddRow(policeGiveWantedList) 
        policeReasonCol = guiGridListAddColumn (policeGiveWantedList, "Reason", 0.6) 
        policeStarsCol = guiGridListAddColumn (policeGiveWantedList, "Stars", 0.2) 
            guiGridListSetItemText(policeGiveWantedList,row2,policeReasonCol,"Police damage",false,false) 
            guiGridListSetItemText(policeGiveWantedList,row2,policeStarsCol,"1",false,false) 
        end 
         
        --BUTTONS 
        policeSetWantedButton = guiCreateButton (272, 280, 218, 39, "Set Wanted", false, policeF2Window) 
                addEventHandler("onClientGUIClick", policeSetWantedButton,  
        function () 
            -- Set wanted HERE 
        end)     
         
        policeRemoveWantedButton = guiCreateButton (272, 329, 218, 39, "Remove Wanted", false, policeF2Window) 
                addEventHandler("onClientGUIClick", policeRemoveWantedButton,  
        function () 
            -- Remove wanted HERE 
        end)     
         
        policeTrackPlayerButton = guiCreateButton (272, 378, 218, 39, "Track Player", false, policeF2Window)     
        addEventHandler("onClientGUIClick", policeTrackPlayerButton,  
        function () 
            -- createBlip HERE 
        end) 
         
        -- Close Button 
        policeCloseButton = guiCreateButton (272, 430, 218, 39, "Close", false, policeF2Window) 
        addEventHandler("onClientGUIClick", policeCloseButton, hidePolicePanel) 
         
            -- Bind Key F2 
        function bindKF2 () 
        bindKey("F2", "down",  
            function () 
                local playerTeam = getPlayerTeam ( getLocalPlayer ( ) ) 
                if ( playerTeam == "Police" ) then 
                    guiSetVisible (policeF2Window, true) 
                    showCursor (true) 
                else return     end 
            end) 
        end 
    end 
) 
  
function showPolicePanel () 
local playerTeam = getPlayerTeam ( getLocalPlayer ( ) ) 
    if ( playerTeam == "Police" ) then 
    guiSetVisible (policeF2Window, true) 
    showCursor (true) 
    else return end 
end 
  
function hidePolicePanel () 
    guiSetVisible (policeF2Window, false) 
    showCursor (false) 
end 

Link to comment

Also a problem here,

Console only outputs 1 and 4

outputConsole("1") 
        -- Bind Key F2 
function bindKF2 () 
    bindKey("F2", "down",  
        function () 
        outputConsole("2") 
            local playerTeam = getTeamName(getPlayerTeam ( getLocalPlayer ( ) )) 
                if ( playerTeam == "Police" ) then 
                outputConsole("3") 
                    guiSetVisible (policeF2Window, true) 
                    showCursor (true) 
                else return     end 
            end) 
        end 
outputConsole("4") 

Link to comment
Where is bindKF2 called ?

That doesn't makes sense.

delete the function bindKF2 line.

Nice works

How 'bout this:

Server side function trigger by a client side,

Error bad argument @ getTeamName

local thePlayer = source 
        police = getPlayerTeam (thePlayer) 
        if ( getTeamName ( police ) == "Police" ) then 

Link to comment
idk if this would work,
  
    local thePlayer = source 
            police = getPlayerTeam (thePlayer) 
        if getTeamName(police) == "Police" then 
        --your code 
        end 

It does work, the problem is when I start the script i'm not in a team so it gives the error can I prevent it to check if I'm in the team Police when my team is empty

Link to comment
  • Moderators
idk if this would work,
  
    local thePlayer = source 
            police = getPlayerTeam (thePlayer) 
        if getTeamName(police) == "Police" then 
        --your code 
        end 

It does work, the problem is when I start the script i'm not in a team so it gives the error can I prevent it to check if I'm in the team Police when my team is empty

Just change this:

if getTeamName(police) == "Police" then 

into this:

if police and getTeamName(police) == "Police" then 

It won't evaluate getTeamName(police) if police is equal to false (means he is not in a team yet).

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