bosslorenz Posted July 30, 2016 Share Posted July 30, 2016 function movingObject ( hitElement, matchingDimension ) if ( getElementType ( hitElement ) == "vehicle" ) then hitElement = getVehicleController ( hitElement ); if ( not hitElement ) then return false; end end local gPT = getPlayerTeam ( hitElement ) local gTN = ( gPT and getTeamName ( gPT ) or "" ) if gTN =="Los Santos Civilians" then if getElementType ( hitElement ) == "player" then moveObject ( gate1, 10000, 1201, -1384.5, 9.3 ) end end end function moveObjectBack (hitElement, matchingDimension) if ( getElementType ( hitElement ) == "vehicle" ) then hitElement = getVehicleController ( hitElement ); if ( not hitElement ) then return false; end end local gPT = getPlayerTeam ( hitElement ) local gTN = ( gPT and getTeamName ( gPT ) or "" ) if gTN =="Los Santos Civilians" then if getElementType ( hitElement ) == "player" then moveObject ( gate1, 3000, 1201, -1384.5, 15.1 ) end end end addEventHandler ( "onMarkerHit", marker1 , movingObject ) addEventHandler ( "onMarkerLeave", marker1, moveObjectBack ) Problem is that when a ped enters the marker it gives error, since I am using slothman zombies. lua:21: Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got marker] lua:37: Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got marker] lua:59: Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got marker] lua:75: Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got marker] Link to comment
Hale Posted July 30, 2016 Share Posted July 30, 2016 (edited) Try this: function movingObject ( hitElement, matchingDimension ) if ( getElementType ( hitElement ) == "vehicle" ) then vehController = getVehicleController ( hitElement ) if ( not vehController ) then -- why vehController? Because 'hitElement' is already true (in the 2. line) return false; end end local gPT = getPlayerTeam ( vehController ) local gTN = ( gPT and getTeamName ( gPT ) or "" ) if gTN =="Los Santos Civilians" then if getElementType ( vehController ) == "player" then moveObject ( gate1, 10000, 1201, -1384.5, 9.3 ) end end end function moveObjectBack (hitElement, matchingDimension) if ( getElementType ( hitElement ) == "vehicle" ) then vehController = getVehicleController ( hitElement ); if ( not vehController ) then return false; end end local gPT = getPlayerTeam ( vehController ) local gTN = ( gPT and getTeamName ( gPT ) or "" ) if gTN =="Los Santos Civilians" then if getElementType ( vehController ) == "player" then moveObject ( gate1, 3000, 1201, -1384.5, 15.1 ) end end end addEventHandler ( "onMarkerHit", marker1 , movingObject ) addEventHandler ( "onMarkerLeave", marker1, moveObjectBack ) Edited July 30, 2016 by Guest Link to comment
bosslorenz Posted July 30, 2016 Author Share Posted July 30, 2016 if getElementType ( vehController ) == "player" then Why change this to vehController, then this will definitely not work on anymore when I am on feet walking into the marker. Link to comment
Hale Posted July 30, 2016 Share Posted July 30, 2016 if getElementType ( vehController ) == "player" then Why change this to vehController, then this will definitely not work on anymore when I am on feet walking into the marker. vehController is the player, it must work lol Link to comment
Hale Posted July 30, 2016 Share Posted July 30, 2016 vehController = getVehicleController ( hitElement ) getVehicleController This function is used to get the player in control of the specified vehicle which includes somebody who is trying to enter the drivers seat. Link to comment
bosslorenz Posted July 30, 2016 Author Share Posted July 30, 2016 if getElementType ( vehController ) == "player" then Why change this to vehController, then this will definitely not work on anymore when I am on feet walking into the marker. vehController is the player, it must work lol As If I didn't tried your code. Your code gives more error. The moveObject doesnt even work anymore. BTW, I just managed to make it work by putting this on first line of every function. if getElementType( hitElement ) == "ped" then return end Link to comment
bosslorenz Posted July 30, 2016 Author Share Posted July 30, 2016 if getElementType ( vehController ) == "player" then Why change this to vehController, then this will definitely not work on anymore when I am on feet walking into the marker. vehController is the player, it must work lol It must work lol? It doesnt even help me, your codes gives more error in fact, I didn't even said I had error in my line hitElement = getVehicleController ( hitElement ); What I ask is that in getElementType (hitElement) =="player" it returns error of peds so the problem is only on (hitElement)=="ped" . Link to comment
Hale Posted July 30, 2016 Share Posted July 30, 2016 Oh, my bad. Well, at least you fixed it. 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