Jump to content

Respawn vehicle by weapon fire


xXGhostXx

Recommended Posts

Posted

Hi guys !

What is problem in my code ?!

Code for respawn vehicle with weapon fire !

Client :

local gundv = nil
function gunDVFunction(_, _, _, _, _, _, car)
outputDebugString("1")
if gundv then
outputDebugString("2")
	if car then
	outputDebugString("3")
		if getElementType(car) == "vehicle" then
		triggerServerEvent("gundv:respawnVehicle", localPlayer, car)
		outputChatBox("[Done] Vehicle Respawned!", 25,255,25)
		end
	end
end
end
addEventHandler ("onClientPlayerWeaponFire", localPlayer, gunDVFunction)

addEvent("gundv:enableOrDisable", true)
addEventHandler("gundv:enableOrDisable", localPlayer, function(bool)
if bool then
gundv = true
else
gundv = nil
end
end )

Server :

function gunDVFunction ( thePlayer, command )
	if not ( isPlayerOnGroup ( thePlayer ) ) then
		outputChatBox("#ff0000Permission Denied!", thePlayer, 255, 255, 255, true)
		return false
	end
	
respawnVehicle(thePlayer,gundv)

end
addCommandHandler("gundv", gunDVFunction)

 

Posted
1 hour ago, xXGhostXx said:

What ?!

Please give me fix code !

No.

This section is not intended for code requests. You're supposed to post a snippet, tell us what's wrong, any debug info and we will try to help you.
I'm saying that you are triggering a server side event 'gundv:respawnVehicle' but that event is never handled on the server side (at least not in the snippet you provided).

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