Jump to content

Bad argument @ attachElements


Tunner

Recommended Posts

After succeeding to create working weapons yesterday, im now in trouble again. When I try to attach weapons to player, it doesnt work. Tried making it local/global, clientside/clientside + serverside, but still nothing.

function weaponAttach ( commandName ) 
      weapon3 = createWeapon ( "M4",0,0,0 ) 
      weapon4 = createWeapon ( "M4",0,0,0 ) 
      attachElements ( weapon3, source, 5, 0, 0 ) 
      attachElements ( weapon4, source, 0, 5, 0 ) 
end 
addCommandHandler( "attachweapons", weaponAttach ) 

Link to comment

Try:

  
function weaponAttach ( commandName ) 
      weapon3 = createWeapon ( "M4",0,0,0 ) 
      weapon4 = createWeapon ( "M4",0,0,0 ) 
      attachElements ( weapon3, localPlayer, 5, 0, 0 ) 
      attachElements ( weapon4, localPlayer, 0, 5, 0 ) 
end 
addCommandHandler( "attachweapons", weaponAttach ) 
  

Use [lua] tags

Link to comment
  
  
function weaponAttach (source, commandName ) 
  
      weapon3 = createWeapon ( "M4",0,0,0 ) 
  
      weapon4 = createWeapon ( "M4",0,0,0 ) 
  
      attachElements ( weapon3, source, 5, 0, 0 ) 
  
      attachElements ( weapon4, source, 0, 5, 0 ) 
  
end 
  
addCommandHandler( "attachweapons", weaponAttach ) 

Link to comment
Try:
  
function weaponAttach ( commandName ) 
      weapon3 = createWeapon ( "M4",0,0,0 ) 
      weapon4 = createWeapon ( "M4",0,0,0 ) 
      attachElements ( weapon3, localPlayer, 5, 0, 0 ) 
      attachElements ( weapon4, localPlayer, 0, 5, 0 ) 
end 
addCommandHandler( "attachweapons", weaponAttach ) 
  

It's only gonna work client-side. To do it server-side use playerSource argument instead of commanName. That will be your player for attaching weapon.

Link to comment
Try:
  
function weaponAttach ( commandName ) 
      weapon3 = createWeapon ( "M4",0,0,0 ) 
      weapon4 = createWeapon ( "M4",0,0,0 ) 
      attachElements ( weapon3, localPlayer, 5, 0, 0 ) 
      attachElements ( weapon4, localPlayer, 0, 5, 0 ) 
end 
addCommandHandler( "attachweapons", weaponAttach ) 
  

Use [lua] tags

This one works great. I would swear that I also tried localPlayer before, but well, at least it works this time. Dunno what I did wrong the last time I used it. Anyway, thanks man.

BTW, how come that source of command isnt player? It works like that in my other resources.

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