Chaos Posted September 3, 2013 Share Posted September 3, 2013 function gui() triggerServerEvent ("checkforadmins", getLocalPlayer()) end bindKey ("F2", "down", gui) addEvent ( "ok", true ) addEventHandler ( "ok", getRootElement(), function () if (guiGetVisible (okno) == false) then guiSetVisible(okno, true) showCursor(true) else guiSetVisible(okno, false) showCursor(false) end end ) why the window will show for all players when some one press f2 i need it appear for one player only Link to comment
Castillo Posted September 3, 2013 Share Posted September 3, 2013 Post the server side part too, the problem is obviously there. Link to comment
Chaos Posted September 3, 2013 Author Share Posted September 3, 2013 addEvent ( "checkforadmins", true ) addEventHandler ( "checkforadmins", getRootElement(), function () local accName = getAccountName ( getPlayerAccount ( source ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then triggerClientEvent ("ok", source) end end ) Link to comment
Castillo Posted September 3, 2013 Share Posted September 3, 2013 triggerClientEvent ("ok", source) Change that to: triggerClientEvent ( source, "ok", source ) Link to comment
Chaos Posted September 3, 2013 Author Share Posted September 3, 2013 it's ok now but i have more questions why when i click on window some buttons will pressed and another question is that correct ? triggerServerEvent ("minigun", getLocalPlayer()) Link to comment
Castillo Posted September 3, 2013 Share Posted September 3, 2013 Post the code. Yes, that's correct. Link to comment
Chaos Posted September 3, 2013 Author Share Posted September 3, 2013 GUIEditor = { button = {}, window = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() okno = guiCreateWindow(553, 303, 494, 466, "Admin Panel by Chaos", false) guiWindowSetSizable(okno, false) guiWindowSetMovable(okno, false) guiSetVisible(okno, false) szeryf = guiCreateButton(181, 109, 126, 65, "Give Me Minigun", false, okno) guiSetProperty(szeryf, "NormalTextColour", "FFAAAAAA") lekarz = guiCreateButton(180, 199, 127, 68, "Full Health", false, okno) guiSetProperty(lekarz, "NormalTextColour", "FFAAAAAA") robotnik = guiCreateButton(182, 293, 125, 67, "Clear The Main Chat", false, okno) guiSetProperty(robotnik, "NormalTextColour", "FFAAAAAA") strazak = guiCreateButton(325, 109, 133, 65, "Give me infernus", false, okno) guiSetProperty(strazak, "NormalTextColour", "FFAAAAAA") mechanik = guiCreateButton(326, 201, 132, 66, "Nitro", false, okno) guiSetProperty(mechanik, "NormalTextColour", "FFAAAAAA") pilot = guiCreateButton(325, 293, 133, 67, "Fix My Vehicle", false, okno) guiSetProperty(pilot, "NormalTextColour", "FFAAAAAA") addEventHandler ( "onClientGUIClick", lekarz, lekarzz) addEventHandler ( "onClientGUIClick", strazak, strazakk) addEventHandler ( "onClientGUIClick", szeryf, szeryff) addEventHandler ( "onClientGUIClick", pilot, pilott) addEventHandler ( "onClientGUIClick", mechanik, mechanikk) addEventHandler ( "onClientGUIClick", robotnik, robotnikk) end ) function gui() triggerServerEvent ("checkforadmins", getLocalPlayer()) end bindKey ("F2", "down", gui) addEvent ( "ok", true ) addEventHandler ( "ok", getRootElement(), function () if (guiGetVisible (okno) == false) then guiSetVisible(okno, true) showCursor(true) else guiSetVisible(okno, false) showCursor(false) end end ) Link to comment
Castillo Posted September 3, 2013 Share Posted September 3, 2013 addEventHandler ( "onClientGUIClick", lekarz, lekarzz) addEventHandler ( "onClientGUIClick", strazak, strazakk) addEventHandler ( "onClientGUIClick", szeryf, szeryff) addEventHandler ( "onClientGUIClick", pilot, pilott) addEventHandler ( "onClientGUIClick", mechanik, mechanikk) addEventHandler ( "onClientGUIClick", robotnik, robotnikk) You forgot about the "getPropagated" argument. addEventHandler ( "onClientGUIClick", lekarz, lekarzz, false) addEventHandler ( "onClientGUIClick", strazak, strazakk, false) addEventHandler ( "onClientGUIClick", szeryf, szeryff, false) addEventHandler ( "onClientGUIClick", pilot, pilott, false) addEventHandler ( "onClientGUIClick", mechanik, mechanikk, false) addEventHandler ( "onClientGUIClick", robotnik, robotnikk, false) Link to comment
Chaos Posted September 3, 2013 Author Share Posted September 3, 2013 Thanks mate I want to add another button called unlimited health but the problem is when I press it all will have unlimited health function stopMinigunDamage ( ) cancelEvent() --cancel the event end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopMinigunDamage ) Link to comment
Castillo Posted September 3, 2013 Share Posted September 3, 2013 Well, that's because you put the event just when script starts, is not inside a function which is triggered when click a GUI element. Link to comment
Chaos Posted September 3, 2013 Author Share Posted September 3, 2013 addEventHandler ( "onClientGUIClick", unlimited,stopMinigunDamage, false) already did that but when I press the button all wont die Link to comment
Castillo Posted September 3, 2013 Share Posted September 3, 2013 Because that's wrong. You must do something like this: function stopDamage ( ) addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopMinigunDamage ) end Then: addEventHandler ( "onClientGUIClick", unlimited, stopDamage, false ) Link to comment
Chaos Posted September 3, 2013 Author Share Posted September 3, 2013 Where is the cancelevent ()? Link to comment
Castillo Posted September 4, 2013 Share Posted September 4, 2013 It's on the "stopMinigunDamage" function which you should also add of course, or you can also do this: function stopDamage ( ) addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), cancelEvent ) end Link to comment
Chaos Posted September 4, 2013 Author Share Posted September 4, 2013 it's not working WARNING: adminpanel\c.lua:125: Bad argument @ 'addEventHandler' [Expected function at argument 3,got nil] Link to comment
Castillo Posted September 4, 2013 Share Posted September 4, 2013 Post the whole code. Link to comment
GamerDeMTA Posted September 4, 2013 Share Posted September 4, 2013 try function stopDamage ( ) addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), cancelEvent() ) end Link to comment
Castillo Posted September 5, 2013 Share Posted September 5, 2013 My script would work perfectly fine, he obviously forgot to add something. Link to comment
Chaos Posted September 5, 2013 Author Share Posted September 5, 2013 well it's working but there is something wrong Link to comment
GamerDeMTA Posted September 5, 2013 Share Posted September 5, 2013 did you add the addeventhandler 2 times? Link to comment
Chaos Posted September 5, 2013 Author Share Posted September 5, 2013 addEventHandler ( "onClientGUIClick", pilot, pilott,false) addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), cancelEvent ) it's just 2 only Link to comment
Castillo Posted September 5, 2013 Share Posted September 5, 2013 That happens when you click it more than once, right? Link to comment
Chaos Posted September 5, 2013 Author Share Posted September 5, 2013 yes that's right Link to comment
Castillo Posted September 5, 2013 Share Posted September 5, 2013 You can do this: removeEventHandler ( "onClientPlayerDamage", getLocalPlayer(), cancelEvent ) addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), cancelEvent ) Link to comment
Chaos Posted September 5, 2013 Author Share Posted September 5, 2013 yh it's working if i want to add button to disable that removeEventHandler ( "onClientPlayerDamage", getLocalPlayer(), cancelEvent ) ? and why when the zombies attacking me i will die? 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