Turbe$Z Posted April 22, 2017 Share Posted April 22, 2017 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] how to fix this? Link to comment
AE. Posted April 22, 2017 Share Posted April 22, 2017 player = the vehicle that the player exit from it so you need to use source if isPedInVehicle (source) then local theVehicle = getPedOccupiedVehicle(source) Link to comment
Turbe$Z Posted April 22, 2017 Author Share Posted April 22, 2017 1 minute ago, 3laa33 said: player = the vehicle that the player exit from it so you need to use source if isPedInVehicle (source) then local theVehicle = getPedOccupiedVehicle(source) i changed to source, but still not working Link to comment
Turbe$Z Posted April 22, 2017 Author Share Posted April 22, 2017 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
Mr.Loki Posted April 22, 2017 Share Posted April 22, 2017 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. Link to comment
Turbe$Z Posted April 22, 2017 Author Share Posted April 22, 2017 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
Mr.Loki Posted April 22, 2017 Share Posted April 22, 2017 Check if the train has a driver getVehicleController Link to comment
Turbe$Z Posted April 22, 2017 Author Share Posted April 22, 2017 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
Turbe$Z Posted April 22, 2017 Author Share Posted April 22, 2017 2 minutes ago, Mr.Loki said: lol dude remove line 3 now i deleted line 3, but same problem Link to comment
Mr.Loki Posted April 22, 2017 Share Posted April 22, 2017 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. 1 Link to comment
Turbe$Z Posted April 22, 2017 Author Share Posted April 22, 2017 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! Now working fine:D Link to comment
Mr.Loki Posted April 22, 2017 Share Posted April 22, 2017 No prob. It checks for a driver when someone exits. if there isn't a driver it will delete the vehicle but you need to add the getVehicleType function again so u won't delete other cars. Link to comment
Function Posted April 24, 2017 Share Posted April 24, 2017 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
Function Posted April 25, 2017 Share Posted April 25, 2017 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
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