Jump to content

[HELP] Destroy vehicle (or exploded veh) with gun shot


SinaAmp

Recommended Posts

Posted

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) 

  • Scripting Moderators
Posted (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 by xLive
  • Like 1
Posted

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 )

 

Posted

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.

Posted

@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); 

 

 

Posted (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 by SpecT
Posted

@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

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