SHC//Sniper Posted June 25, 2010 Share Posted June 25, 2010 Dear forum members, I'm scripting for weeks and I was always successful but now I have a problem. A very stupid problem. I tried to make a function with a Collision shape to open a gate/fence but somehow it's not working. Debugscript 3 says: WARNING: Bad argument @ 'addEventHandler' (string-defined function)! It's hard to say which EventHandler it is but I found it by disabling all other handlers. I already tried to seperate the small function in one resource (normally it's in my RPG script with about 20 files) but I have the same error. ALWAYS. When I use a commandhandler instead of the eventhandler it's working perfect! And I checked if the collisions shapes were create correctly, and they are. The only problem is the 'onColShapeHit' at line 17. Here is the code: function createVehsAndObjects() elec1 = createObject(969, -2602.3239746094, 585.18743896484, 13.603122711182, 0, 0, 90) elec2 = createObject(969, -2566.568359375, 577.69165039063, 13.609375, 0, 0, 180) elec3 = createObject(969, -2566.333984375, 577.68243408203, 13.609375, 0, 0, 0) end addEventHandler("onResourceStart", getRootElement(), createVehsAndObjects) local medicsphere1 local medicsphere2 function createAllCols() medicsphere1 = createColSphere(-2601.9345703125, 590.7041015625, 14.453125, 10) medicsphere2 = createColSphere(-2566.6650390625, 578.083984375, 14.459202766418, 15) end addEventHandler("onResourceStart", getRootElement(), createAllCols) addEventHandler("onColShapeHit", medicsphere1, openMedicGate1) --the event that causes the problem --addEventHandler("onColShapeHit", medicsphere2, openMedicGate2) local openFence = false local openFence2 = false function openMedicGate1 (element, dimension) outputChatBox("HIT HIT HIT") local account = getPlayerAccount(element) --if (getElementType(element) == "player") and (getAccountData(account, "job") == "medic") then (you don't need it this is just for me to check whether the player is a medic!) if (openFence == false) then moveObject(elec1, 5000, -2602.3181152344, 594.03961181641, 13.603122711182, 0, 0, 0) openFence = true outputChatBox("SHOULD BE OPEN") if (openFence == true) then setTimer(moveObject, 9000, 1, elec1, 7000, -2602.3239746094, 585.18743896484, 13.603122711182, 0, 0, 0) setTimer(setOpenFenceToFalse, 16000, 1) end end --end end function setOpenFenceToFalse() openFence = false end Link to comment
Castillo Posted June 25, 2010 Share Posted June 25, 2010 function createAllCols() medicsphere1 = createColSphere(-2601.9345703125, 590.7041015625, 14.453125, 10) medicsphere2 = createColSphere(-2566.6650390625, 578.083984375, 14.459202766418, 15) addEventHandler("onColShapeHit", medicsphere1, openMedicGate1) end addEventHandler("onResourceStart", getRootElement(), createAllCols) --addEventHandler("onColShapeHit", medicsphere2, openMedicGate2) local openFence = false local openFence2 = false function openMedicGate1 (element, dimension) outputChatBox("HIT HIT HIT") local account = getPlayerAccount(element) --if (getElementType(element) == "player") and (getAccountData(account, "job") == "medic") then (you don't need it this is just for me to check whether the player is a medic!) if (openFence == false) then moveObject(elec1, 5000, -2602.3181152344, 594.03961181641, 13.603122711182, 0, 0, 0) openFence = true outputChatBox("SHOULD BE OPEN") if (openFence == true) then setTimer(moveObject, 9000, 1, elec1, 7000, -2602.3239746094, 585.18743896484, 13.603122711182, 0, 0, 0) setTimer(setOpenFenceToFalse, 16000, 1) end end --end end function setOpenFenceToFalse() openFence = false end Link to comment
SHC//Sniper Posted June 25, 2010 Author Share Posted June 25, 2010 Thank you very much! It's working! I can't believe that this was my fail. Thanks again. Greets Sniper 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