Jump to content

Why not working destroyElement?


Turbe$Z

Recommended Posts

addEventHandler ( "onPlayerVehicleExit", getRootElement(),
function(player)
	if isPedInVehicle (player) then
		local theVehicle = getPedOccupiedVehicle(player)
		if getVehicleType(theVehicle) == "Train" then
			destroyElement(trailer)
			destroyElement(trailer2)
			destroyElement(trailer3)
			outputChatBox("#FFffFFElhagytad a mozdonyt. A vagonok törlődtek!", player, r,g,b, true)
		end
	end
end
)

Warning: Bad argument @ 'isPedInVehicle' [Expected ped at argument 1, got vehicle]

O.o how to fix this? :| 

Link to comment
1 minute ago, 3laa33 said:

post the new code

 

addEventHandler ( "onPlayerVehicleExit", getRootElement(),
function()
	if isPedInVehicle (source) then
		local theVehicle = getPedOccupiedVehicle(source)
		if getVehicleType(theVehicle) == "Train" then
			destroyElement(trailer)
			destroyElement(trailer2)
			destroyElement(trailer3)
			outputChatBox("#0088FF[SuperFun] #FFffFFElhagytad a mozdonyt. A vagonok törlődtek!", source, r,g,b, true)
		end
	end
end
)

 

Link to comment
1 minute ago, Mr.Loki said:

You can't check if the player is in a vehicle if he has just exited it.

Change player in line 2 to theVehicle and remove isPedInVehicle and getPedOccupiedVehicle.

It will also be deleted when a other player exit from other vehicle?

Link to comment
3 minutes ago, Mr.Loki said:

Check if the train has a driver getVehicleController

addEventHandler ( "onPlayerVehicleExit", getRootElement(),
function(theVehicle, towedBy)
	local theVehicle = getPedOccupiedVehicle(source)
	thePlayer = getVehicleController(source) 
		if ( thePlayer ) then
			destroyElement(trailer)
			destroyElement(trailer2)
			destroyElement(trailer3)
			outputChatBox("#FFffFFElhagytad a mozdonyt. A vagonok törlődtek!", source, r,g,b, true)
		end
	end
)

now i got this warning: bad argument @ 'getVehicleController' [Expected vehicle at argument 1, got player]

Link to comment
addEventHandler ( "onPlayerVehicleExit", getRootElement(),
  function(theVehicle, towedBy)
    local thePlayer = getVehicleController(source) 
    if not thePlayer then
      destroyElement(trailer)
      destroyElement(trailer2)
      destroyElement(trailer3)
      outputChatBox("#FFffFFElhagytad a mozdonyt. A vagonok törlődtek!", source, r,g,b, true)
    end
  end
)

Try this.

  • Like 1
Link to comment
1 minute ago, Mr.Loki said:

addEventHandler ( "onPlayerVehicleExit", getRootElement(),
  function(theVehicle, towedBy)
    local thePlayer = getVehicleController(source) 
    if not thePlayer then
      destroyElement(trailer)
      destroyElement(trailer2)
      destroyElement(trailer3)
      outputChatBox("#FFffFFElhagytad a mozdonyt. A vagonok törlődtek!", source, r,g,b, true)
    end
  end
)

Try this.

Oh, thanks! :D Now working fine:D

Link to comment
function destroyTrailers(player,seat,jacked)
  if seat == 0 and getVehicleType(source) == "Train" then
    destroyElement(trailer)
    destroyElement(trailer2)
    destroyElement(trailer3)
    outputChatBox("Elhagytad a mozdonyt. A vagonok törlődtek!",player,255,255,255)
  end
end
addEventHandler("onVehicleExit",root,destroyTrailers)

 

Link to comment
20 hours ago, Function said:

function destroyTrailers(player,seat,jacked)
  if seat == 0 and getVehicleType(source) == "Train" and isElement(trailer) and isElement(trailer2) and isElement(trailer3) then
    destroyElement(trailer)
    destroyElement(trailer2)
    destroyElement(trailer3)
    outputChatBox("Elhagytad a mozdonyt. A vagonok törlődtek!",player,255,255,255)
  end
end
addEventHandler("onVehicleExit",root,destroyTrailers)

 

 

Link to comment

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