-misterX- Posted January 21, 2013 Share Posted January 21, 2013 the debugscript doesn't report anything wrong but the gui doesn't cloe and even trigger the event client windowjob = guiCreateWindow ( 0.2, 0.2, 0.25, 0.5, "Police job", true ) guiSetAlpha( windowjob, 1 ) button = guiCreateButton ( 0.5, 0.8, 0.45, 0.15, "Close", true, windowjob ) button1 = guiCreateButton ( 0.01, 0.8, 0.45, 0.15, "Accept", true, windowjob ) label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "Double Click Vehicle to take it.", true, windowjob ) showCursor(false) guiSetVisible( windowjob, false ) guiWindowSetSizable( windowjob, false ) guiWindowSetMovable( windowjob, false ) vehicles = { {"Officer 1", 280}, {"Officer 2", 281}, {"Traffic officer", 284}, {"Swat", 285}, } grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, windowjob) guiGridListAddColumn(grid, "Skins", 0.85) for i,veh in ipairs(vehicles) do row = guiGridListAddRow(grid) -- guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) guiGridListSetItemData(grid, row, 1, tostring(veh[2])) end function get() local row, col = guiGridListGetSelectedItem(grid) if (row and col and row ~= -1 and col ~= -1) then local model = tonumber(guiGridListGetItemData(grid, row, 1)) if model ~= "" then triggerServerEvent("setSAPD", localPlayer, model) guiSetVisible(windowjob,false) showCursor(false) end end end addEventHandler("onClientGUIClick", button1, get, false) function close() if (source == button) then guiSetVisible(windowjob,false) showCursor(false) end end addEventHandler("onClientGUIClick", button, close) function SAPDgui() guiSetVisible(windowjob,true) showCursor(true) end addEvent("SAPDgui",true) addEventHandler("SAPDgui", getRootElement(), SAPDgui) addEventHandler("onClientMarkerHit", marker, SAPDgui) addEventHandler("onClientMarkerHit", marker1, SAPDgui) addEventHandler("onClientMarkerHit", marker2, SAPDgui) function SAPDjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) addEventHandler("onClientMarkerLeave", marker1, SAPDjobleave) addEventHandler("onClientMarkerLeave", marker2, SAPDjobleave) server afText = {} myTextItem = {} function warnText ( aWText, player ) if ( myTextItem[player] ) then textDestroyTextItem ( myTextItem[player]) end afText[player] = textCreateDisplay () textDisplayAddObserver( afText[player], player ) myTextItem[player] = textCreateTextItem ( aWText, 0.22, 0.8, 2 , 255, 0, 0, 255, 3 ) textDisplayAddText ( afText[player], myTextItem[player] ) -- outputChatBox ( textA, player ) setTimer ( textDestroyTextItem, 5000, 1, myTextItem[player], player ) end createBlip ( 1552.4996337891, -1677.3264160156, 15.1953125, 30 ) createBlip ( -1604.5458984375, 712.25848388672, 12.8671875, 30 ) createBlip ( 2340.9245605469, 2456.0463867188, 13.96875, 30 ) function createSAPDTeam () SAPDteam = createTeam ("police", 100, 149, 237) end addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) function joinSAPD(source, id) setPlayerTeam(source,SAPDteam) setElementModel(source, id) giveWeapon ( source, 3 ) playeraccount = getPlayerAccount( source ) setAccountData( playeraccount, "team", "police", true ) warnText("You are now SAPD agent.",source,0,255,0) end addEvent("setSAPD", true) addEventHandler("setSAPD",root,joinSAPD) function removeSAPD() setPlayerTeam(source, 0) takeWeapon(source, 3) playeraccount = getPlayerAccount(source) if not getAccountData(playeraccount, "standardskin") then setElementModel(source, 0) else setElementModel(source,getAccountData(playeraccount,"standardskin")) end warnText("You are now an unemployed.",source,255,0,0) end addEvent("removeSAPD", true) addEventHandler("removeSAPD",root,removeSAPD) function policeJob ( attacker, attackerweapon, bodypart, loss ) if attacker and getElementType(attacker) == "player" then theTeam = getPlayerTeam ( attacker ) theWL = getPlayerWantedLevel ( source ) theSkin = getElementModel ( attacker ) if (attackerweapon == 3) and (loss > 2 ) and (theWL > 0) then if getTeamName( theTeam ) == "police" or getTeamName( theTeam ) == "SWAT" or getTeamName( theTeam ) == "FBI" then setElementPosition (source, 4076.3999023438, -1788.5, 3.511967, true) theName = getPlayerName ( source ) theCop = getPlayerName ( attacker ) warnText( "You have been jailed by "..theCop.. " for 10 seconds.", source ) warnText( "You have jailed the criminal "..theName, attacker ) local playeraccount = getPlayerAccount ( attacker ) givePlayerMoney (attacker, 100 * theWL ) setTimer ( setElementPosition, 10000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) setPlayerWantedLevel (source, 0) end end end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob) Link to comment
DNL291 Posted January 21, 2013 Share Posted January 21, 2013 You are using the 'get' function, that is a function of the MTA. Link to comment
Ab-47 Posted January 22, 2013 Share Posted January 22, 2013 I don't understand what you're doing, the best I could do is get the GUI to show and clean a few things up. Client- windowjob = guiCreateWindow ( 0.2, 0.2, 0.25, 0.5, "Police job", true ) guiSetAlpha( windowjob, 1 ) button = guiCreateButton ( 0.5, 0.8, 0.45, 0.15, "Close", true, windowjob ) button1 = guiCreateButton ( 0.01, 0.8, 0.45, 0.15, "Accept", true, windowjob ) label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "Double Click Vehicle to take it.", true, windowjob ) showCursor(false) guiSetVisible( windowjob, false ) guiWindowSetSizable( windowjob, false ) guiWindowSetMovable( windowjob, false ) vehicles = { {"Officer 1", 280}, {"Officer 2", 281}, {"Traffic officer", 284}, {"Swat", 285}, } grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, windowjob) guiGridListAddColumn(grid, "Skins", 0.85) for i,veh in ipairs(vehicles) do row = guiGridListAddRow(grid) -- guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) guiGridListSetItemData(grid, row, 1, tostring(veh[2])) end function get() local row, col = guiGridListGetSelectedItem(grid) if (row and col and row ~= -1 and col ~= -1) then local model = tonumber(guiGridListGetItemData(grid, row, 1)) if model ~= "" then triggerServerEvent("setSAPD", localPlayer, model) guiSetVisible(windowjob,false) showCursor(false) end end end addEventHandler("onClientGUIClick", button1, get, false) function close() if (source == button) then guiSetVisible(windowjob,false) showCursor(false) end end addEventHandler("onClientGUIClick", button, close) function SAPDgui() guiSetVisible(windowjob,true) showCursor(true) end addEventHandler("onClientMarkerHit", marker, SAPDgui) addEventHandler("onClientMarkerHit", marker1, SAPDgui) addEventHandler("onClientMarkerHit", marker2, SAPDgui) function SAPDjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob, true) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) addEventHandler("onClientMarkerLeave", marker1, SAPDjobleave) addEventHandler("onClientMarkerLeave", marker2, SAPDjobleave) Be aware, when you add an event, you should trigger the event in the oposing script, if you add an event client sided trigger the event server sided. With the GUI, you need markers in order to trigger the function to open your GUI, so you have to create Markers as-well. marker = createMarker ( x, y, z, 'type') marker1 = createMarker ( x, y, z, 'type') marker2 = createMarker ( x, y, z, 'type') You aren't getting anywhere with this: function get() local row, col = guiGridListGetSelectedItem(grid) if (row and col and row ~= -1 and col ~= -1) then local model = tonumber(guiGridListGetItemData(grid, row, 1)) if model ~= "" then triggerServerEvent("setSAPD", localPlayer, model) guiSetVisible(windowjob,false) showCursor(false) end end end addEventHandler("onClientGUIClick", button1, get, false) If you haven't added an event in the server side. Imo, create a new script with better understanding, or start of with something less complicated. 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