Jump to content

Kiling tank with RPG


Xwad

Recommended Posts

Posted

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.

A unique GangWar gamemode waiting for you!
Click here for more information.

560x95_FFFFFF_FF9900_000000_000000.png

Posted

No, you'll need to use this functions to create what you want. If you get problems,post what you tried and i'll help you.

A unique GangWar gamemode waiting for you!
Click here for more information.

560x95_FFFFFF_FF9900_000000_000000.png

Posted

Are you sure the Rhino takes damage by the RPG?

Otherwise, I assume you'll have to check whenever there is an explosion - and who the creator was. If there's a Rhino within a distance of X, either damage it or blow it up.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

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)

Posted

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) 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

Is this tested? AFAIK onClientVehicleDamage does not trigger for explosions @ Rhino, only for ramming, fire and bullets (but bullets do not make real damage, they just trigger the event)

n-560x95_FFFFFF_FFFFFF_000000_000000.png

Posted

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)

Posted

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)

Posted

[2014-12-30 15:11:20] ERROR: Couldn't parse meta file for resource 'tankkill'

[2014-12-30 15:11:20] Loading of resource 'tankkill' failed

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