-.Paradox.- Posted April 17, 2014 Share Posted April 17, 2014 Weapons\client.lua:11: Bad argument @'addEventHandler' [Expected function at argument 3, got nil' Client: function weapons( ) local icons = getPedWeapon(localPlayer) if icons then dxDrawImage(917, 53, 243, 123, ":Weapons/images/"..icons..".png") end end addEvent("onClientWeaponSwitch", true) addEventHandler( "onClientWeaponSwitch", root, function() addEventHandler("onClientRender", root, onTest) setTimer( function () removeEventHandler ( "onClientRender", root, weapons ) end, 3000, 1) end) Server: addEvent( "onPlayerWeaponSwitch" , true) addEventHandler( "onPlayerWeaponSwitch", getRootElement(), function() triggerClientEvent(source,"onClientWeaponSwitch", source) end) I'm trying to show that image when the player switch weapons. Link to comment
Castillo Posted April 17, 2014 Share Posted April 17, 2014 Your function name at addEventHandler: "onTest", your real function name: "weapons". P.S: Why you need a server side script? there's a client side event for when player switch weapons. Link to comment
Castillo Posted April 17, 2014 Share Posted April 17, 2014 Read what I said again, the problem is that you're using a wrong function name. Link to comment
..:D&G:.. Posted April 17, 2014 Share Posted April 17, 2014 function weapons( ) local icons = getPedWeapon(localPlayer) if icons then dxDrawImage(917, 53, 243, 123, ":Weapons/images/"..icons..".png") end end addEvent("onClientWeaponSwitch", true) addEventHandler( "onClientWeaponSwitch", root, function() addEventHandler("onClientRender", root, onTest) setTimer( function () removeEventHandler ( "onClientRender", root, weapons ) end, 3000, 1) end) This is what Solidsnake ment the first time, your event addEventHandler("onClientRender", root, onTest) Is for "onTest" when it should be like this: addEventHandler("onClientRender", root, weapons) The eventhandler must be linked to your function/function name, so: function weapons( ) local icons = getPedWeapon(localPlayer) if icons then dxDrawImage(917, 53, 243, 123, ":Weapons/images/"..icons..".png") end end addEvent("onClientWeaponSwitch", true) addEventHandler( "onClientWeaponSwitch", root, function() addEventHandler("onClientRender", root, weapons) setTimer( function () removeEventHandler ( "onClientRender", root, weapons ) end, 3000, 1) end) P.S: Castillo, I checked the wiki and there is no client-side event for the weapon switch... Link to comment
-.Paradox.- Posted April 17, 2014 Author Share Posted April 17, 2014 Actually there is, And i asked Castillo to tell me what is it, and he thought i'm talking about the error but i was talking about the event. Anyway, here is the event, onClientPlayerWeaponSwitch Thanks by the way. 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