@Infinity#There are two flaws in your code:
If two players observe vehicle damage, then both send the attacker into the vehicle, causing unnecessary network traffic that could lag the server.
Since you can damage a vehicle with a shovel, this is an undesired effect. You should limit it to known weapon-ids only by checking the weapon parameter.
Both can be fixed by adjusting the client.lua the following way:
local function is_gun_id(id)
if (type(id) == "number") and ((id >= 22 and id <= 34) or (id == 38)) then return true end
return false
end
addEventHandler("onClientVehicleDamage", root, function(attacker, weapon, loss, x, y, z, tire)
if (is_gun_id(weapon) and getElementType(source) == "vehicle" and getElementType(attacker) == "player" and attacker == localPlayer) then
triggerServerEvent("mtasa.warpPed", attacker, source)
end
end)
If you want to make it somewhat more secure you would use the "client" event variable on the serverside.