Jump to content

[HELP]bulletproof tires but i dont want them


Recommended Posts

hello i found on internet that script that makes your vehicle more damage proof but when i start this script my tires wont pops out so how i can add or delete sth to be able to shoot and flat tire?

 


local weapon_table = {
-- model,	  id
[30] = {
	[422]=10, --Bobcat
	[596]=9,  --PoliceLS
},
}

function getElementSpeed(theElement, unit)
    -- Check arguments for errors
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
    local elementType = getElementType(theElement)
    assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

addEventHandler("onClientVehicleDamage",root,function(attacker,weapon,loss,dmgx,dmgy,dmgz,tireid)
if getElementData(source,'god-mode') then return end
if isVehicleDamageProof(source) then return end
if attacker and getElementType(attacker)=='player' then
if dmg_table[getElementModel(source)] then
cancelEvent()
setElementHealth(source,getElementHealth(source)-(dmg_table[getElementModel(source)]+weapon_table[weapon][getElementModel(source)]))
print(getElementHealth(source))
end
--elseif attacker~=('vehicle' or 'ped') then
--setElementHealth(source,getElementHealth(source)-(getElementSpeed(source,1)/30*10))
end
end)

 

Link to comment
  • Discord Moderators
local weapon_table = {
-- model,	  id
[30] = {
	[422]=10, --Bobcat
	[596]=9,  --PoliceLS
},
}

function getElementSpeed(theElement, unit)
    -- Check arguments for errors
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
    local elementType = getElementType(theElement)
    assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

addEventHandler("onClientVehicleDamage", root,
	function(attacker,weapon,loss,dmgx,dmgy,dmgz,tireid)
		if tireid then return end
		if getElementData(source,'god-mode') then return end
		if isVehicleDamageProof(source) then return end
		if attacker and getElementType(attacker)=='player' then
			if dmg_table[getElementModel(source)] then
				cancelEvent()
				setElementHealth(source,getElementHealth(source)-(dmg_table[getElementModel(source)]+weapon_table[weapon][getElementModel(source)]))
				print(getElementHealth(source))
			end
		--elseif attacker~=('vehicle' or 'ped') then
		--setElementHealth(source,getElementHealth(source)-(getElementSpeed(source,1)/30*10))
		end
end)

Try this.

I added line 25. I haven't tested it, but I assume tireid is nil if no tire was hit.

  • Thanks 1
Link to comment
  • Moderators

When you cancel the event, the tires can't be flatten.

So you probably will have to do that manually.

 

https://wiki.multitheftauto.com/wiki/OnClientVehicleDamage

element theAttacker, int theWeapon, float loss, float damagePosX, float damagePosY, float damagePosZ, int tireID

 

 

>>>

 

Set clientside (for people with high ping AND can also be used to prevent an overflow of data between client and server, since you do not have to communicate with the server when the tire is already flatten):

https://wiki.multitheftauto.com/wiki/SetVehicleWheelStates

> triggerServerEvent

Set serverside: (Now other players should be able to see it, I am not sure if this is required because I do not know if this tire state is streamed when the setVehicleWheelStates function is called on clientside.)

https://wiki.multitheftauto.com/wiki/SetVehicleWheelStates

 


 

Or do not cancel the event when a tire is hit.

Edited by IIYAMA
  • Like 1
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...