opnaiC Posted June 24, 2016 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
Bean666 Posted June 25, 2016 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?
Tox Posted June 25, 2016 Posted June 25, 2016 check out the https://wiki.multitheftauto.com/wiki/TriggerServerEvent function again and fully understand how it works.
opnaiC Posted June 25, 2016 Author 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] ...
opnaiC Posted June 25, 2016 Author 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((
Bean666 Posted June 25, 2016 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)
opnaiC Posted June 25, 2016 Author 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
opnaiC Posted June 25, 2016 Author Posted June 25, 2016 maybe is givePedWeapon givePedWeapon is client sided, I allready tried it but it didnt worked ..
Dimos7 Posted June 25, 2016 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)
roaddog Posted June 26, 2016 Posted June 26, 2016 Try changin your line triggerServerEvent("m4", root) to triggerServerEvent("m4", localPlayer, localPlayer) And dont change anything on serverside code
Ahmed Ly Posted June 26, 2016 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 )
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