Jump to content

Trouble with onColShapeHit


xUltimate

Recommended Posts

Posted

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) 

Posted

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) 

Posted

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) 

Posted

ye

pdb1 = createObject(968, -1572.1899414063, 658.70002441406, 6.8500001907349, 0, 90, 90) 
pdb2 = createObject(968, -1701.4300537109, 687.65997314453, 24.670000076294, 0, 90, -90) 

As of now im going to sleep, got school, so ill see this tomorrow.

Posted
oh yeah, its moving but in wrong position, check again the cordinates.

Coordinates look fine to me, the object isnt even moving for me, but the cmd works.

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