ViRuZGamiing Posted February 21, 2014 Share Posted February 21, 2014 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
Vanlot Posted February 21, 2014 Share Posted February 21, 2014 Change line 63 with this local playerTeam = getTeamName(getPlayerTeam ( getLocalPlayer ( ) )) Link to comment
ViRuZGamiing Posted February 21, 2014 Author Share Posted February 21, 2014 Change line 63 with this local playerTeam = getTeamName(getPlayerTeam ( getLocalPlayer ( ) )) Gonna try it out Link to comment
ViRuZGamiing Posted February 21, 2014 Author Share Posted February 21, 2014 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
ViRuZGamiing Posted February 21, 2014 Author Share Posted February 21, 2014 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
Karuzo Posted February 21, 2014 Share Posted February 21, 2014 Where is bindKF2 called ? That doesn't makes sense. delete the function bindKF2 line. Link to comment
ViRuZGamiing Posted February 21, 2014 Author Share Posted February 21, 2014 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
Karuzo Posted February 21, 2014 Share Posted February 21, 2014 idk if this would work, local thePlayer = source police = getPlayerTeam (thePlayer) if getTeamName(police) == "Police" then --your code end Link to comment
Vanlot Posted February 21, 2014 Share Posted February 21, 2014 police = getPlayerTeam (localPlayer) if getTeamName(police) == "Police" then Link to comment
ViRuZGamiing Posted February 21, 2014 Author Share Posted February 21, 2014 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
Karuzo Posted February 21, 2014 Share Posted February 21, 2014 What? I don't understand you. Link to comment
ViRuZGamiing Posted February 21, 2014 Author Share Posted February 21, 2014 Basicly when you enter the game you're not assigned to a team, But the script searches for the team "Police" and doesn't find one because i'm not in it. It only needs to check if i'm in team "Police" when i'm actually in a team. Link to comment
Karuzo Posted February 21, 2014 Share Posted February 21, 2014 Ah ok. I just found an useful function which could help you with that. https://wiki.multitheftauto.com/wiki/IsPlayerInTeam Link to comment
ViRuZGamiing Posted February 21, 2014 Author Share Posted February 21, 2014 Ah ok.I just found an useful function which could help you with that. https://wiki.multitheftauto.com/wiki/IsPlayerInTeam could I change; if getTeamName(police) == "Police" then into if isPlayerInTeam( police, 'Police' ) then Link to comment
Karuzo Posted February 21, 2014 Share Posted February 21, 2014 Yeah, if the script is server-sided and you copy&pasted the serverside script of isPlayerInTeam then it should work. But you should change police into the player element, cause the first parameter is the player. Link to comment
ViRuZGamiing Posted February 21, 2014 Author Share Posted February 21, 2014 Yeah, if the script is server-sided and you copy&pasted the serverside script of isPlayerInTeam then it should work. But you should change police into the player element, cause the first parameter is the player. Okay works fine! Thanks Link to comment
Moderators Citizen Posted February 21, 2014 Moderators Share Posted February 21, 2014 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
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