Jump to content

Trouble with onColShapeHit


xUltimate

Recommended Posts

I have a small problem, I am trying to make it so when someone in faction 1 (SFPD) hits a area it opens the barrier, but I get this error on load:

sfpd/map-outside.lua:17: Bad argument @ 'addEventHandler' 

The code:

function policeDoor(thePlayer) 
    pdb1s = createColRectangle( -1566.64, 665.95, 7.03, 10, 7) 
    if exports.factions:isPlayerInFaction( thePlayer, 1 ) then 
        moveObject(pdd1, 3000, -1620.6579589844, 688.30285644531, 10.809907913208) 
        setTimer(policeDoorClose, 4000, 1) 
    end 
end 
addEventHandler ( "onColShapeHit", pdb1s, policeDoor )--Line 17 
addCommandHandler("pdd", policeDoor) 

Link to comment

of course won't work, you are creating the shape when you enter on it if i'm right can't work like this, try

  
pdb1s = createColRectangle( -1566.64, 665.95, 7.03, 10, 7) 
  
function policeDoor(thePlayer) 
    if exports.factions:isPlayerInFaction( thePlayer, 1 ) then 
        moveObject(pdd1, 3000, -1620.6579589844, 688.30285644531, 10.809907913208) 
        setTimer(policeDoorClose, 4000, 1) 
    end 
end 
addEventHandler ( "onColShapeHit", pdb1s, policeDoor )--Line 17 
addCommandHandler("pdd", policeDoor) 

Link to comment

Haha I fixed that problem but it was in the wrong thing, now I have this problem:

The barrier will not open

pdb1s = createColRectangle( -1566.64, 665.95, 7.03, 10, 7) 
  
function policeBarrier() 
    local allPlayers = getElementsByType("player") 
    for index,val in ipairs(allPlayers) do 
        if exports.factions:isPlayerInFaction(val, 1 ) then 
            moveObject(pdb1, 3000, -1572.1899414063, 658.65002441406, 6.8000001907349, 90, 0, 0) 
            setTimer ( policeBarrierClose, 5000, 1) 
        end 
    end 
end 
addEventHandler ( "onColShapeHit", pdb1s, policeBarrier ) 
addCommandHandler("pdb", policeBarrier) 

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