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) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

try to give us more information please, like you getting any error at debugscript? /debugscript 3

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

can you give me the createObject function, i will try to fix it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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.

Posted

Debug?

https://wiki.multitheftauto.com/wiki/Debugging

  
local test = moveObject(......) 
outputDebugString (tostring(test)) 
  

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

You added the line varez said?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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