Jump to content

Ped error


Recommended Posts

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

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 by Guest
Link to comment
 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
 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
 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" . :roll::roll:

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