Jump to content

Extra Ammo kill


Wisam

Recommended Posts

Hello..

Im just starting to learn lua and i wanted to make a small script its when you kill a player you get extra amount of ammo for the weapon that killed him and each weapon get different amount of ammo (e.g M4 50 rounds for a kill, Sniper 10 rounds for a kill)

I tryed to make it that each weapon gives different amount but i failed and made that it gives a random amount whatever the weapon was please help me

Here's the script: Thanks to Mr.Miracle :D

  
addEventHandler("onPlayerWasted",root,function(ammo,killer,wep) 
    if getElementType(killer) == "player" and killer ~= source and wep > 9 then 
        setWeaponAmmo(killer,wep,ammo+math.random(10,30)) 
    end 
end)  

Link to comment
  • Other Languages Moderators
local weaponA = { 
    [31] = 50, -- M4 
    [34] = 10 -- Sniper 
     
} 
  
function playerWasted(_, attacker, weapon) 
    if attacker and attacker ~= source and getElementType(attacker) == "player" then 
        if weaponA[weapon] then 
            giveWeapon(attacker, weapon, weaponA[weapon]) 
        end 
    end 
end 
addEventHandler("onPlayerWasted", root, playerWasted) 

Link to comment
  • Other Languages Moderators
.. and i forgot to mention somthing.. when the player kills and gets the ammo a small dxdrawtext above his head will appear writing (ammo+) that would be great

We're here to help only, try to make it yourself.

Things you'll need:

-- server side 
triggerClientEvent 
  
-- client side 
addEvent 
addEventHandler 
getPedBonePosition 
dxDrawText 
isTimer 
setTimer 
killTimer 
removeEventHandler 

Link to comment
.. and i forgot to mention somthing.. when the player kills and gets the ammo a small dxdrawtext above his head will appear writing (ammo+) that would be great

We're here to help only, try to make it yourself.

Things you'll need:

-- server side 
triggerClientEvent 
  
-- client side 
addEvent 
addEventHandler 
getPedBonePosition 
dxDrawText 
isTimer 
setTimer 
killTimer 
removeEventHandler 

I tryed everything and nothing worked :/ im dont know alot about lua!

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