Shagwrath Posted September 12, 2015 Share Posted September 12, 2015 I'd like to make a script which detects if a player has shot a car's gas tank with a sniper rifle, and then blows it up if so. I've been searching for a way to detect if a specific component of the car was shot, but I haven't been able to find anything useful, any thoughts on how to do this? I could finish the script from there, but this part has baffled me for awhile. Thanks, any help will be greatly appreciated Link to comment
Shagwrath Posted September 16, 2015 Author Share Posted September 16, 2015 (edited) local allowedWeapons = { [33] = true, [34] = true, }; addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), function() for i,v in ipairs(getElementsByType("vehicle")) do setVehicleFuelTankExplodable(v,false); end end ); addEventHandler("onClientPlayerWeaponFire",getLocalPlayer(), function(weapon,ammo,ammoInClip,hX,hY,hZ,hitElement) if hX and hY and hZ then if hitElement then if getElementType(hitElement) == "vehicle" then if allowedWeapons[weapon] == true then setVehicleFuelTankExplodable(hitElement,true); else setVehicleFuelTankExplodable(hitElement,false); end end end end end ); I tried some things and finally got it to work, so yah, now I feel dumb. I wouldn't have thought that setting the fuel tank explodable after it was shot would work, but now I know. So if anyone else has wondered this, or wants the code, here's the solution. Edited September 16, 2015 by Guest Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now