Monty Posted December 18, 2012 Share Posted December 18, 2012 what's wrong? why doesnt shoot? -- This function gets triggered everytime player shoots. function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) if weapon == 31 then -- if source is a local player and he uses minigun... x,y,z = getElementPosition(getLocalPlayer()) if not createProjectile(getLocalPlayer(),16,x,y,z,200) then -- then we either create a projectile... outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message end end end -- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire. addCommandHandler( "grenade", getLocalPlayer(), onClientPlayerWeaponFireFunc ) Link to comment
Castillo Posted December 18, 2012 Share Posted December 18, 2012 The second argument of addCommandHandler is the function, not a player element. Link to comment
manve1 Posted December 18, 2012 Share Posted December 18, 2012 1. You need m4 2. U are creating air bomb o_O 3. The command handler is wrong 4. add this line at the bottom: addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc) 5. Change: addCommandHandler("grenade", getLocalPlayer(), onClientPlayerWeaponFireFunc) to: addCommandHandler("grenade", onClientPlayerWeaponFireFunc) Link to comment
Monty Posted December 18, 2012 Author Share Posted December 18, 2012 still not working function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) if weapon == 31 then -- if source is a local player and he uses minigun... x,y,z = getElementPosition(getLocalPlayer()) if not createProjectile(getLocalPlayer(),16,x,y,z,200) then -- then we either create a projectile... outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message end end end -- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire. addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc) addCommandHandler("grenade", onClientPlayerWeaponFireFunc) Link to comment
Castillo Posted December 18, 2012 Share Posted December 18, 2012 Errors or anything? is the script set as client side? Link to comment
abu5lf Posted December 18, 2012 Share Posted December 18, 2012 function onClientPlayerWeaponFireFunc( aWeapon ) if ( aWeapon == 31 ) then createProjectile( localPlayer, 16, getElementPosition( localPlayer ), 200 ) end end addCommandHandler( 'grenade', function( ) if not( i ) then addEventHandler( 'onClientPlayerWeaponFire', localPlayer, onClientPlayerWeaponFireFunc ) else removeEventHandler( 'onClientPlayerWeaponFire', localPlayer, onClientPlayerWeaponFireFunc ) end i = not i end ) 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