Sora Posted August 2, 2012 Posted August 2, 2012 (edited) hello guys , i created an resource and i created marker and blip in a funiction with global variables and tried to destroy them with another funiction but says bad argument destroyElement(..) .. got nil addEvent("cb",true) addEventHandler("cb",getRootElement(),ct) function ct(player,x,y,z) finishblip = createBlip ( x, y, z, 42, 0, 0, 0, 255, 255,1, 99999,player) finishM = createMarker (x,y,z, "checkpoint", 3, 255, 255, 0, 170,player) addEventHandler("onMarkerHit", finishM,destroy) end function destroy(hitElement) -- some not needed codes was here destroyElement(finishblip) destroyElement(finishM) end my question is , why the script (or the funiction) can't get variables and they are global variables Edited August 2, 2012 by Guest [REL] Resource Starter System v1.3 [REL] Give Permissions Panel v1.4 [REL] Meta Creator 1.1 ( In-game MetaCreator ) [REL] ACL Permission Manager 1.0 [REL] Accounts Security Manager 1.1 Name(s) in-game : old |S.s|SoRa, current : *Sora
_Dark_ Posted August 2, 2012 Posted August 2, 2012 (edited) function ct(player,x,y,z) finishblip = createBlip(x, y, z, 42, 0, 0, 0, 255, 255, 1, 99999, player) finishM = createMarker(x, y, z, "checkpoint", 3, 255, 255, 0, 170, player) addEventHandler("onMarkerHit", finishM, destroy) end addEvent("cb",true) addEventHandler("cb", root, ct) function destroy(hitElement) -- some not needed codes was here destroyElement(finishblip) destroyElement(finishM) end Function must be before addEvent/Handler. Edited August 2, 2012 by Guest #define if while#define TRUE FALSE// problems?
myonlake Posted August 2, 2012 Posted August 2, 2012 Events must have functions, your function wasn't created when the server checked the event, so it didn't work. EDIT: _Dark_ was first, but here's a simple fix. addEvent("cb", true) addEventHandler("cb", root, function(player, x, y, z) finishM = createMarker(x, y, z, "checkpoint", 3, 255, 255, 0, 170, player) finishblip = createBlipAttachedTo(finishM, 42, 0, 0, 0, 255, 255, 1, 99999, player) addEventHandler("onMarkerHit", finishM, destroy) end ) addEvent("cb", true) addEventHandler("cb", root, function(player, x, y, z) finishM = createMarker(x, y, z, "checkpoint", 3, 255, 255, 0, 170, player) finishblip = createBlipAttachedTo(finishM, 42, 0, 0, 0, 255, 255, 1, 99999, player) addEventHandler("onMarkerHit", finishM, destroy) end ) function destroy(hitElement, matchingDimension) if matchingDimension then destroyElement(finishblip) destroyElement(finishM) end end If I helped you, please click the like button on the right Thanks!
_Dark_ Posted August 2, 2012 Posted August 2, 2012 (edited) If problem not solved try this: addEvent("cb", true) addEventHandler("cb", root, function(player, x, y, z) finishM = createMarker(x, y, z, "checkpoint", 3, 255, 255, 0, 170, player) finishblip = createBlipAttachedTo(finishM, 42, 0, 0, 0, 255, 255, 1, 99999, player) outputChatBox(getElementType(finishM), player) outputChatBox(getElementType(finishblip), player) addEventHandler("onMarkerHit", finishM, destroy) end ) function destroy(hitElement, matchingDimension) if matchingDimension then if isElement(finishM) and isElement(finishblip) then destroyElement(finishblip) destroyElement(finishM) else outputDebugString("'finishM' and/or 'finishblip' are not elements, perhaps not created?") end end end This should output in chatbox Marker and Blip. Edited August 2, 2012 by Guest #define if while#define TRUE FALSE// problems?
myonlake Posted August 2, 2012 Posted August 2, 2012 Are you sure that you called event cb?Try this: addEvent("cb", true) addEventHandler("cb", root, function(player, x, y, z) finishM = createMarker(x, y, z, "checkpoint", 3, 255, 255, 0, 170, player) finishblip = createBlipAttachedTo(finishM, 42, 0, 0, 0, 255, 255, 1, 99999, player) outputChatBox(getElementType(finishM), player) outputChatBox(getElementType(finishblip), player) addEventHandler("onMarkerHit", finishM, destroy) end ) function destroy(hitElement, matchingDimension) if matchingDimension then if isElement(finishM) and isElement(finishblip) then destroyElement(finishblip) destroyElement(finishM) else outputDebugString("'finishM' and/or 'finishblip' are not elements, perhaps not created?") end end end This should output in chatbox Marker and Blip. I am not sora, you can just delete your message because he haven't tried it yet. If I helped you, please click the like button on the right Thanks!
_Dark_ Posted August 2, 2012 Posted August 2, 2012 Oh sorry, I didn't pay attention to the nickname. #define if while#define TRUE FALSE// problems?
Sora Posted August 2, 2012 Author Posted August 2, 2012 thank you guys , problem solved ^^ [REL] Resource Starter System v1.3 [REL] Give Permissions Panel v1.4 [REL] Meta Creator 1.1 ( In-game MetaCreator ) [REL] ACL Permission Manager 1.0 [REL] Accounts Security Manager 1.1 Name(s) in-game : old |S.s|SoRa, current : *Sora
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