Tunner Posted September 2, 2012 Share Posted September 2, 2012 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
gokalpfirat Posted September 2, 2012 Share Posted September 2, 2012 Isn't' createWeapon function in MTA 1.4? Link to comment
AMARANT Posted September 2, 2012 Share Posted September 2, 2012 Because in your code there's no any 'source'. Link to comment
MIKI785 Posted September 2, 2012 Share Posted September 2, 2012 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
gokalpfirat Posted September 2, 2012 Share Posted September 2, 2012 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
AMARANT Posted September 2, 2012 Share Posted September 2, 2012 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
MIKI785 Posted September 2, 2012 Share Posted September 2, 2012 it's Client-only function.... Link to comment
AMARANT Posted September 2, 2012 Share Posted September 2, 2012 it's Client-only function.... Actually yes... My bad. I forgot that it's a new function for MTA. Link to comment
Tunner Posted September 2, 2012 Author Share Posted September 2, 2012 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
AMARANT Posted September 2, 2012 Share Posted September 2, 2012 BTW, how come that source of command isnt player? It works like that in my other resources. Because client-side version of handler function doesn't need player source argument but server-side does. 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