tim260 Posted January 12, 2012 Share Posted January 12, 2012 how do i let the buttons excecute the commands ( open the toll gates ) so if i press open main gate f.e. i want to excecute the command below function movingMyGateBack18 () moveObject ( myGate18, 10000, -2680.9365234375, 1243.482421875 + 0, 70.903121948242, 0, 0, 0 ) end addCommandHandler("opensfmain1",movingMyGateBack18) The GUI GUI made with Qt ! function createTheGate10 () myGate10 = createObject ( 968, -2671.4345703125, 1283.3880615234, 55.4296875, 0, 90, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate10 ) function createTheGate11 () myGate11 = createObject ( 968, -2681.1748046875, 1283.0634765625, 55.4296875, 0, 90, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate11 ) function openMyGate11 () moveObject ( myGate11, 3000, -2681.1748046875, 1283.0634765625, 55.4296875, 0, -90, 0 ) end addCommandHandler("toll2",openMyGate11) function movingMyGateBack11 () moveObject ( myGate11, 3000, -2681.1748046875, 1283.0634765625 + 0, 55.4296875, 0, 90, 0 ) end addCommandHandler("toll2c",movingMyGateBack11) function createTheGate12 () myGate12 = createObject ( 968, -2682.111328125, 1265.599609375, 55.4296875, 0, 270, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate12 ) function openMyGate12 () moveObject ( myGate12, 3000, -2682.111328125, 1265.599609375, 55.4296875, 0, 90, 0 ) end addCommandHandler("toll3",openMyGate12) function movingMyGateBack12 () moveObject ( myGate12, 3000, -2682.111328125, 1265.599609375 + 0, 55.4296875, 0, -90, 0 ) end addCommandHandler("toll3c",movingMyGateBack12) function createTheGate13 () myGate13 = createObject ( 968, -2690.875, 1265.8466796875, 55.4296875, 0, 270, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate13 ) function createTheGate14 () myGate14 = createObject ( 981, -2677.828125, 1232.9757080078, 50.118979644775, 0, 0, 17.864868164063 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate14 ) function openMyGate14 () moveObject ( myGate14, 6000, -2677.828125, 1232.9757080078, 54.918979644775, 0, 0, 0 ) end addEvent( "roadclose1", true ) addCommandHandler("roadclose1",openMyGate14) function movingMyGateBack14 () moveObject ( myGate14,6000, -2677.828125, 1232.9757080078 + 0, 50.118979644775, 0, 0, 0 ) end addCommandHandler("roadopen1",movingMyGateBack14) function createTheGate18 () myGate18 = createObject ( 10838, -2680.9365234375, 1243.482421875, 70.903121948242, 0, 0, 278.61560058594 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate18 ) function openMyGate18 () moveObject ( myGate18, 10000, -2680.9365234375, 1243.482421875, 61.903121948242, 0, 0, 0 ) end addCommandHandler("closesfmain1",openMyGate18) function movingMyGateBack18 () moveObject ( myGate18, 10000, -2680.9365234375, 1243.482421875 + 0, 70.903121948242, 0, 0, 0 ) end addCommandHandler("opensfmain1",movingMyGateBack18) function createTheGate19 () myGate19 = createObject ( 10838, -2680.9716796875, 2137.595703125, 70.66584777832, 0, 0, 93.290405273438 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate19 ) function openMyGate19 () moveObject ( myGate19, 100000, -2680.9716796875, 2137.595703125, 61.66584777832, 0, 0, 0 ) end addCommandHandler("roadclose4",openMyGate19) function movingMyGateBack19 () moveObject ( myGate19, 100000, -2680.9716796875, 2137.595703125 + 0, 70.66584777832, 0, 0, 0 ) end addCommandHandler("roadopen4",movingMyGateBack19) function bridgeclose () end addCommandHandler("bridgeclose", openMyGate14 ) addCommandHandler("bridgeclose", openMyGate18 ) addCommandHandler("bridgeclose", openMyGate19 ) function bridgeopen () end addCommandHandler("bridgeopen", movingMyGateBack14 ) addCommandHandler("bridgeopen", movingMyGateBack18 ) addCommandHandler("bridgeopen", movingMyGateBack19 ) function tollall () end addCommandHandler("tollall", openMyGate11 ) addCommandHandler("tollall", openMyGate12 ) function tollall () end addCommandHandler("tollallc", movingMyGateBack11 ) addCommandHandler("tollallc", movingMyGateBack12 ) -- start GUI local gui = {} gui._placeHolders = {} local screenWidth, screenHeight = guiGetScreenSize() local windowWidth, windowHeight = 1219, 564 local left = screenWidth/2 - windowWidth/2 local top = screenHeight/2 - windowHeight/2 gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "United States Department of Homeland Security - Toll gates Control", false) guiSetVisible(gui["_root"], false) guiWindowSetSizable(gui["_root"], false) gui["tabWidget"] = guiCreateTabPanel(10, 25, 1071, 521, false, gui["_root"]) gui["tab"] = guiCreateTab("San Fierro", gui["tabWidget"]) gui["pushButton_2"] = guiCreateButton(20, 110, 111, 41, "Close Main SF One", false, gui["tab"]) gui["pushButton_3"] = guiCreateButton(260, 60, 111, 41, "Open Toll 2", false, gui["tab"]) gui["pushButton_4"] = guiCreateButton(20, 60, 111, 41, "Open Main SF One", false, gui["tab"]) gui["pushButton_5"] = guiCreateButton(140, 60, 111, 41, "Open Toll 1", false, gui["tab"]) gui["pushButton_6"] = guiCreateButton(140, 110, 111, 41, "Close Toll 1", false, gui["tab"]) gui["pushButton_7"] = guiCreateButton(260, 110, 111, 41, "Close Toll 2", false, gui["tab"]) gui["plainTextEdit"] = guiCreateMemo(20, 160, 421, 151, "When There ar no Homeland Agents Online,\nPlease open all the gates and let everybody true.\n\nSigned,\n\nHomeland Security Leader Tim260.", false, gui["tab"]) guiMemoSetReadOnly(gui["plainTextEdit"], true) gui["commandLinkButton"] = guiCreateButton(30, 320, 401, 41, "Close All Gates ( EMERGENCY )", false, gui["tab"]) gui["commandLinkButton_2"] = guiCreateButton(30, 370, 401, 41, "Open All Gates", false, gui["tab"]) gui["tab_2"] = guiCreateTab("Graver Bridge", gui["tabWidget"]) gui["tab_3"] = guiCreateTab("Martin Bridge", gui["tabWidget"]) gui["tab_4"] = guiCreateTab("Fallow Bridge", gui["tabWidget"]) gui["tab_5"] = guiCreateTab("Montgomery intersection", gui["tabWidget"]) gui["tab_6"] = guiCreateTab("Flint Intersection", gui["tabWidget"]) gui["tab_7"] = guiCreateTab("Toll Information Page", gui["tabWidget"]) function OpenClose() if guiGetVisible(gui["_root"]) == true then guiSetVisible(gui["_root"], false) showCursor(false) elseif guiGetVisible(gui["_root"]) == false then guiSetVisible(gui["_root"], true) showCursor(true) end end addCommandHandler ( "dhstoll", OpenClose ) --return gui, windowWidth, windowHeight --end function on_pushButton_2_clicked(button, state, absoluteX, absoluteY) if button == "left" and state == "up" then triggerClientEvent ( "onroadclose1" ) end --TODO: Implement your button click handler here end function on_pushButton_3_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here end function on_pushButton_4_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here end function on_pushButton_5_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here end function on_pushButton_6_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here end function on_pushButton_7_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here Link to comment
Paper Posted January 12, 2012 Share Posted January 12, 2012 You have to use triggerServerEvent! Link to comment
tim260 Posted January 12, 2012 Author Share Posted January 12, 2012 You have to use triggerServerEvent! then to i dont understand im waiting for some experienced guy to reply Link to comment
Kenix Posted January 12, 2012 Share Posted January 12, 2012 He right You have to use triggerServerEvent! tim260:You need read it https://wiki.multitheftauto.com/wiki/Scr ... troduction Link to comment
tim260 Posted January 12, 2012 Author Share Posted January 12, 2012 He right You have to use triggerServerEvent! tim260:You need read it https://wiki.multitheftauto.com/wiki/Scr ... troduction i did -.- i just dont understand it if someone would send me an example script ( using my functions ) then i maybe would Link to comment
Paper Posted January 12, 2012 Share Posted January 12, 2012 LoL this is not request forum, we can help you... but you must make the script... Link to comment
tim260 Posted January 12, 2012 Author Share Posted January 12, 2012 LoL this is not request forum, we can help you... but you must make the script... dont you see i did i tryed pff ill wait for solid snake instead of other people flaming me -.- i tried 100 things look at the first button youll see i tried EDIT you think im stupid i use this forums alot i never reqeust things -.- Link to comment
tim260 Posted January 12, 2012 Author Share Posted January 12, 2012 He right You have to use triggerServerEvent! tim260:You need read it https://wiki.multitheftauto.com/wiki/Scr ... troduction ok i did : function on_pushButton_4_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then triggerServerEvent ( "onopenmain", getLocalPlayer(), "Hello World!" ) end --TODO: Implement your button click handler here end and function movingMyGateBack18 () moveObject ( myGate18, 10000, -2680.9365234375, 1243.482421875 + 0, 70.903121948242, 0, 0, 0 ) end addEvent( "onopenmain", true ) addEventHandler( "onopenmain", getRootElement(), movingMyGateBack18 ) addCommandHandler("opensfmain1",movingMyGateBack18) doesnt work what do i do wrong Link to comment
Paper Posted January 12, 2012 Share Posted January 12, 2012 function on_pushButton_4_clicked(button, state, absoluteX, absoluteY) triggerServerEvent ( "onopenmain", getLocalPlayer(), "Hello World!" ) end addEventHandler("onClientGUIClick", [buttonname], on_pushButton_4_clicked) try this Link to comment
tim260 Posted January 12, 2012 Author Share Posted January 12, 2012 function on_pushButton_4_clicked(button, state, absoluteX, absoluteY) triggerServerEvent ( "onopenmain", getLocalPlayer(), "Hello World!" ) end addEventHandler("onClientGUIClick", [buttonname], on_pushButton_4_clicked) try this warning : "" expected near "end" EDIT: fixed that one still doesnt work EDIT 2 : maybe thw all knowing GURU castillo knows how to fix it waiting for his reply Link to comment
Castillo Posted January 12, 2012 Share Posted January 12, 2012 Mind explaining what are you trying to do? because that's a mess. Link to comment
tim260 Posted January 12, 2012 Author Share Posted January 12, 2012 Mind explaining what are you trying to do? because that's a mess. lol IM trying to open my gates with a gui panel for people in one of my acl groups ( didnt add the getaclgroup yet either ) So people dont have to do commands all the time for openings gates. SO if people click open Sf main 1 it opens one of the gates Link to comment
Castillo Posted January 12, 2012 Share Posted January 12, 2012 First: Create all gate objects onResourceStart, but in just ONE function, no need for 1 function for each object. Second: Create all your gate commands to move them. Third: In the client side use executeCommandHandler when a button is clicked. Link to comment
tim260 Posted January 12, 2012 Author Share Posted January 12, 2012 First: Create all gate objects onResourceStart, but in just ONE function, no need for 1 function for each object.Second: Create all your gate commands to move them. Third: In the client side use executeCommandHandler when a button is clicked. cant get it to work will post things that i did tommorow 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