SinaAmp 2 Posted March 12 Share Posted March 12 hi guys how i can give function to gun shot (and preventing damage) for destroy only vehicles? (I want to make a admin tool that destroy veh and its replace with colt45) Link to post
xLive 87 Posted March 12 Share Posted March 12 You need to use this event onPlayerWeaponFire check if the parameter hitElement exists and it's a vehicle -- getElementType (element) == "vehicle" then you can use destoryElement to destroy it. Link to post
SinaAmp 2 Posted March 12 Author Share Posted March 12 thank you @xLive but every thing i tried not worked can u give me example script? Link to post
xLive 87 Posted March 12 Share Posted March 12 (edited) 6 hours ago, SinaAmp said: thank you @xLive but every thing i tried not worked can u give me example script? Oh its my fault sorry! Quote hitElement: an element which was hit by a shot. Currently this can be only another player. it doesn't work with vehicles i don't know if there's another event to use. Edited March 12 by xLive 1 Link to post
Tekken 146 Posted March 13 Share Posted March 13 (edited) You can with OnClientPlayerWeaponFire Edited March 13 by Tekken Typo 1 Link to post
SinaAmp 2 Posted March 13 Author Share Posted March 13 thank you @Tekken why my script does not destroy vehicles? -- client function DesVeh(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if weapon == 22 and getElementType(hitElement)=="vehicle" then destroyElement(hitElement) outputChatBox ( "Your vehicle has been destroyed!", 0, 255, 0 ) else outputChatBox ( "opssss !", 255, 0, 0 ) end end addEventHandler ( "onClientPlayerWeaponFire", root, DesVeh ) Link to post
SpecT 55 Posted March 13 Share Posted March 13 It doesn't work because probably the vehicle was spawned from server side. This means you should destroy the vehicle from the same side. Use triggerServerEvent, pass the hitElement in it and destroy the vehicle in server side. Link to post
SinaAmp 2 Posted March 14 Author Share Posted March 14 @SpecT whats wrong with my serverside script? i doesn't receive any error in debugscript 3 -- client function DesVeh(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if weapon == 22 and getElementType(hitElement)=="vehicle" then triggerServerEvent("onAdminShot" , hitElement) outputChatBox ( "Your vehicle has been destroyed!", 0, 255, 0 ) else outputChatBox ( "opssss !", 255, 0, 0 ) end end addEventHandler ( "onClientPlayerWeaponFire", root, DesVeh ) -- server function DesMyVeh(hitElement) if isElement(hitElement) and getElementType(hitElement) == "vehicle" then fixVehicle(hitElement) end end addEvent("onAdminShot",true); addEventHandler("onAdminShot",root,DesMyVeh); Link to post
SpecT 55 Posted March 14 Share Posted March 14 (edited) Wait.. what exactly do you want to do with the vehicle when you shoot it ? From your first post I see you want the weapon to destroy the vehicles it hits. And in the code you posted above has fixVehicle function. Is it a mistake or intentional? You can either use destroyElement or blowVehicle (for explosion effect). Edited March 14 by SpecT Link to post
SinaAmp 2 Posted March 14 Author Share Posted March 14 @SpecToh sorry i forgot to edit my code in forum that (fixvehicle(hitElement)) is my test code i replaced that with destroyElement(hitElement) but again that not worked Link to post
SpecT 55 Posted March 14 Share Posted March 14 Oh actually I didn't notice a mistake in the triggerServerEvent. Now this should work: triggerServerEvent("onAdminShot", resourceRoot, hitElement) 1 Link to post
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