Jump to content

rocket launcher damage


Recommended Posts

I have a problem with rocket damage. The damage is absolutely unchanged. There is no problem with weapons such as M4, sniper. I can change their damage.

What should I do to increase rocket damage?

addEventHandler("onPlayerDamage", getRootElement(),
	function (attacker, weapon, bodypart, loss)
		if bodypart == 9 then
			local result = triggerEvent("", source, attacker, weapon, loss)
			if result == true then
				killPed(source, attacker, weapon, bodypart)
			end
		end
	end
)

local weapons = {20, 19, 40, 31, 30, 29, 24, 25, 34, 35, 36, 22, 27}

function onClientPedDamage(_, weapon)
    if(getElementType(source) == "player") then
       if(weapons[weapon]) then
           return killPed(source)
       end
    end
end
addEventHandler("onClientPedDamage", getRootElement(), onClientPedDamage)

for _, v in ipairs ( { "pro", "std", "poor" } ) do
    setWeaponProperty ( "m4", v, "damage", 150 ) -- 20 Yazan kısım silahın vereceği hasar.
    setWeaponProperty ( "ak47", v, "damage", 200 )
    setWeaponProperty ( "mp5", v, "damage", 95 )
    setWeaponProperty ( "deagle", v, "damage", 50 )
    setWeaponProperty ( "uzi", v, "damage", 0 )
    setWeaponProperty ( "tec-9", v, "damage", 15 )
    setWeaponProperty ( "rocket launcher", v, "damage", 1000 )
    setWeaponProperty ( "rocket launcher hs", v, "damage", 1000 )
    setWeaponProperty ( "sniper", v, "damage", 1000 )
    setWeaponProperty ( "rocket", v, "damage", 2000 )

end

 

Link to comment
7 hours ago, #nofear said:

I have a problem with rocket damage. The damage is absolutely unchanged. There is no problem with weapons such as M4, sniper. I can change their damage.

What should I do to increase rocket damage?

addEventHandler("onPlayerDamage", getRootElement(),
	function (attacker, weapon, bodypart, loss)
		if bodypart == 9 then
			local result = triggerEvent("", source, attacker, weapon, loss)
			if result == true then
				killPed(source, attacker, weapon, bodypart)
			end
		end
	end
)

local weapons = {20, 19, 40, 31, 30, 29, 24, 25, 34, 35, 36, 22, 27}

function onClientPedDamage(_, weapon)
    if(getElementType(source) == "player") then
       if(weapons[weapon]) then
           return killPed(source)
       end
    end
end
addEventHandler("onClientPedDamage", getRootElement(), onClientPedDamage)

for _, v in ipairs ( { "pro", "std", "poor" } ) do
    setWeaponProperty ( "m4", v, "damage", 150 ) -- 20 Yazan kısım silahın vereceği hasar.
    setWeaponProperty ( "ak47", v, "damage", 200 )
    setWeaponProperty ( "mp5", v, "damage", 95 )
    setWeaponProperty ( "deagle", v, "damage", 50 )
    setWeaponProperty ( "uzi", v, "damage", 0 )
    setWeaponProperty ( "tec-9", v, "damage", 15 )
    setWeaponProperty ( "rocket launcher", v, "damage", 1000 )
    setWeaponProperty ( "rocket launcher hs", v, "damage", 1000 )
    setWeaponProperty ( "sniper", v, "damage", 1000 )
    setWeaponProperty ( "rocket", v, "damage", 2000 )

end

 

Hi @#nofear Welcome to the forum!, you can tell me or other community your new questions and requests as you wish, I will help you with your problem,

server-side :
 

local rocketDamage = 50 --Fixed amount of damage for rocket damage
addEvent("handleDamage",true)
addEventHandler("handleDamage", root,
  function(attacker, damage_causing, bodypart, loss)
     if(getElementHealth(client) - rocketDamage <= 0) then --if the damage done leaves the player's hp at or below 0 then kill him directly
        killPed(client, attacker, damage_causing, bodypart)
     else
        setElementHealth(client, getElementHealth(client) - rocketDamage) --if it doesn't kill then reduce health
     end
  end
)

client-side :
 

function damageHandler(attacker, damage_causing, bodypart, loss)
   if(damage_causing == 19) then
      cancelEvent() --cancel current damage because we will give
      triggerServerEvent("handleDamage", source, attacker, damage_causing, bodypart, loss) --Send the information to the server side, here we will process the damage
   end
end
addEventHandler("onClientPlayerDamage", root, damageHandler)

As an example, I can recommend these codes to you, I tested them and they are working, you can develop them through these codes.

Edited by Shady1
notes.
Link to comment

 

Thank you @Shady1, but even though I shoot from a distance, I am dying too and the damage to the vehicles does not increase. they don't explode with 1 or 2 rockets because I increased the durability of the vehicles on my server.

I take no damage when shooting at a far wall, but I also take damage when shooting at a far player.

Edited by #nofear
Link to comment
2 minutes ago, #nofear said:

 

Thank you @Shady1, but even though I shoot from a distance, I am dying too and the damage to the vehicles does not increase. they don't explode with 1 or 2 rockets because I increased the durability of the vehicles on my server.

there was no problem when i tested it

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