Jump to content

Exploding bullets.


DoubleMTA

Recommended Posts

Heres the simplest example of an exploding bullet script

CLIENT STUFF

function weaponfired (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
    if source == getLocalPlayer () then 
        triggerServerEvent ("bulletboom", getLocalPlayer (), hitX, hitY, hitZ ) 
    end 
end 
  
addEventHandler ( "onClientPlayerWeaponFire", getRootElement(), weaponfired ) 

SERVER STUFF

addEvent ("bulletboom", true ) 
  
function bulletexplosion (hitX, hitY, hitZ) 
    createExplosion ( hitX, hitY, hitZ, 2 ) 
end 
  
addEventHandler("bulletboom",getRootElement(),bulletexplosion) 

play with it if you want to check which weapon is fired, credit the player with the kill, or generally improve it

Link to comment

It's neater to do the client handler like:

function weaponfired (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
        triggerServerEvent ("bulletboom", source, hitX, hitY, hitZ ) 
end 
  
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer (), weaponfired ) 

or even like:

 addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer (),  
        function (weapon, ammo, ammoInClip, hitX, hitY, hitZ) 
                triggerServerEvent ("bulletboom", source, hitX, hitY, hitZ ) 
        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...