opnaiC Posted June 24, 2016 Share Posted June 24, 2016 client m4 = exports.dxgui:dxCreateButton(167, 65, 113, 26, "M4", window) function m4p () triggerServerEvent ( "m4", root ) end addEventHandler ("onClientDXClick", m4, m4p) server function m4 (player) giveWeapon (player, 31, 50, true) end addEvent ("m4", true) addEventHandler("m4",getRootElement(),m4) When I click on the button nothing happens! But it should give me a weapon ... need help Link to comment
Bean666 Posted June 25, 2016 Share Posted June 25, 2016 you could have made a GUI Button in the DX Rectangle , and make the GUI Button alpha 0 anyways whats the error. and is the export in the Meta.xml? and any errors on /debugscript 3? Link to comment
DNL291 Posted June 25, 2016 Share Posted June 25, 2016 It should be cause "player" isn't a player element. Link to comment
Tox Posted June 25, 2016 Share Posted June 25, 2016 check out the https://wiki.multitheftauto.com/wiki/TriggerServerEvent function again and fully understand how it works. Link to comment
opnaiC Posted June 25, 2016 Author Share Posted June 25, 2016 you could have made a GUI Button in the DX Rectangle , and make the GUI Button alpha 0anyways whats the error. and is the export in the Meta.xml? and any errors on /debugscript 3? I changed root to getLocalPlayer() I have this error: Bad Argument: giveWeapon [Expected Argument at 1, got nil] ... Link to comment
opnaiC Posted June 25, 2016 Author Share Posted June 25, 2016 It should be cause "player" isn't a player element. function m4p () --triggerServerEvent ( "m4", getLocalPlayer() ) givePedWeapon (getLocalPlayer(), 31, 50, true) end addEventHandler ("onClientDXClick", m4, m4p) Its possible to make it working with givePedWeapon.. But my function doesnt work(( Link to comment
Bean666 Posted June 25, 2016 Share Posted June 25, 2016 try function m4p () triggerServerEvent ( "m4", getLocalPlayer(), m4 ) end addEventHandler ("onClientDXClick", m4, m4p) function m4 () giveWeapon (source, 31, 50, true) end addEvent ("m4", true) addEventHandler("m4", getRootElement() ,m4) Link to comment
opnaiC Posted June 25, 2016 Author Share Posted June 25, 2016 try function m4p () triggerServerEvent ( "m4", getLocalPlayer(), m4 ) end addEventHandler ("onClientDXClick", m4, m4p) function m4 () giveWeapon (source, 31, 50, true) end addEvent ("m4", true) addEventHandler("m4", getRootElement() ,m4) not working Link to comment
opnaiC Posted June 25, 2016 Author Share Posted June 25, 2016 maybe is givePedWeapon givePedWeapon is client sided, I allready tried it but it didnt worked .. Link to comment
Dimos7 Posted June 25, 2016 Share Posted June 25, 2016 --Server Side function m4(thePlayer) giveWeapon(thePlayer, 31, 50, true) end addEvent("m4", true) addEventHandler("m4", root, m4) --Client Side m4 = exports.dxgui:dxCreateButton(167, 65, 113, 26, "M4" window) function m4p() triggerServerEvent("m4", localPlayer) end addEventHandler("onClientDXClick", m4, m4p) Link to comment
roaddog Posted June 26, 2016 Share Posted June 26, 2016 Try changin your line triggerServerEvent("m4", root) to triggerServerEvent("m4", localPlayer, localPlayer) And dont change anything on serverside code Link to comment
Ahmed Ly Posted June 26, 2016 Share Posted June 26, 2016 --Server addEvent("m4v", true) addEventHandler("m4v", root, function() giveWeapon(source, 31, 50) end ) --Client m4 = exports.dxgui:dxCreateButton(167, 65, 113, 26, "M4" window) addEventHandler("onClientDXClick", m4, function() triggerServerEvent("m4v", localPlayer) end ) 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