Jump to content

Kiling tank with RPG


Xwad

Recommended Posts

As i know there isn't a script like this on the community, to create a script like this is pretty easy.

Event;  
onClientVehicleDamage 
Functions: 
getElementModel 
cancelEvent() 
getElementHealth 
getElementPosition 
createExplosion 
  

When a player damage ,check the model of the vehicle,if the model is a rhino then cancel the event and create your damage system for the rhino,use getElementHealth to get his health , and use setElementHealth to make him health lower. getElementPosition and createExplosion to make the rhino explode.

Link to comment

this?

-- Only let these weapons damage a Rhino

local weaponsToDamageRhino = {

[38] = true, -- minigun

[33] = true, -- country rifle

[34] = true, -- sniper rifle

[30] = true, -- AK-47

[31] = true, -- M4

}

function handleRhinoDamage(attacker, weapon, loss, x, y, z, tyre)

if (weapon and getElementModel(source) == 432 and loss > 0) then

if (weaponsToDamageRhino[weapon]) then

setElementHealth(source, getElementHealth(source) - loss)

end

end

end

addEventHandler("onClientVehicleDamage", root, handleRhinoDamage)

Link to comment

Yes he does, to give you more inside in the code i'm going to explain it with the comments "-- text".

local weaponsToDamageRhino = { 
    [35] = true, -- basis RPG 
    [36] = true, -- Heatseaking RPG 
    -- You can add different weapons too apart from RPG, if not then a table isn't necessarily needed. 
    -- The [number] is the weapon ID, true means it's valid, every other number returns false. 
} 
  
function handleRhinoDamage(attacker, weapon, loss, x, y, z, tyre) 
    if (weapon and getElementModel(source) == 432 and loss > 0) then 
    -- if the weapon exists and the vehicle being shot is a Rhino and             
    -- the damage dealt isn't 0 but any number higher then do the following. 
        if (weaponsToDamageRhino[weapon]) then 
        -- if the weapon is one of the valid ID's above (35 'true' and 36 'true') then do the following. 
            setElementHealth(source, getElementHealth(source) - loss) 
            -- set the health (life points) of the Rhino (source is the vehicle being shot) 
            -- too the current health minus the loss. 
        end 
    end 
end 
addEventHandler("onClientVehicleDamage", root, handleRhinoDamage) 

Link to comment

what??xdSo need i write in lua this?

local weaponsToDamageRhino = {

[35] = true, -- basis RPG

[36] = true, -- Heatseaking RPG

-- You can add different weapons too apart from RPG, if not then a table isn't necessarily needed.

-- The [number] is the weapon ID, true means it's valid, every other number returns false.

}

function handleRhinoDamage(attacker, weapon, loss, x, y, z, tyre)

if (weapon and getElementModel(source) == 432 and loss > 0) then

-- if the weapon exists and the vehicle being shot is a Rhino and

-- the damage dealt isn't 0 but any number higher then do the following.

if (weaponsToDamageRhino[weapon]) then

-- if the weapon is one of the valid ID's above (35 'true' and 36 'true') then do the following.

setElementHealth(source, getElementHealth(source) - loss)

-- set the health (life points) of the Rhino (source is the vehicle being shot)

-- too the current health minus the loss.

end

end

end

addEventHandler("onClientVehicleDamage", root, handleRhinoDamage)

Link to comment

I create a folder and put 2 files meta.xml and tankkill.lua

I wrote in meta.xml the following

tankkill.lua

local weaponsToDamageRhino = {

[35] = true, -- basis RPG

[36] = true, -- Heatseaking RPG

-- You can add different weapons too apart from RPG, if not then a table isn't necessarily needed.

-- The [number] is the weapon ID, true means it's valid, every other number returns false.

}

function handleRhinoDamage(attacker, weapon, loss, x, y, z, tyre)

if (weapon and getElementModel(source) == 432 and loss > 0) then

-- if the weapon exists and the vehicle being shot is a Rhino and

-- the damage dealt isn't 0 but any number higher then do the following.

if (weaponsToDamageRhino[weapon]) then

-- if the weapon is one of the valid ID's above (35 'true' and 36 'true') then do the following.

setElementHealth(source, getElementHealth(source) - loss)

-- set the health (life points) of the Rhino (source is the vehicle being shot)

-- too the current health minus the loss.

end

end

end

addEventHandler("onClientVehicleDamage", root, handleRhinoDamage)

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