Jump to content

[HELP] trigger Event / giveWeapon


opnaiC

Recommended Posts

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
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?

I changed root to getLocalPlayer()

I have this error: Bad Argument: giveWeapon [Expected Argument at 1, got nil] ...

Link to comment
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

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
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
--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
--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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...