LiOneLMeSsIShoT Posted December 13, 2013 Share Posted December 13, 2013 (edited) in this script i got errors. please help: function mission1 (hitElement) local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) addEventHandler ("onMarkerHit", mission1Marker, mission1) function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got "..money.."$ Good Job!", source, 0, 255, 0, false) destroyElement (mission1Marker) end addEvent ("GetRewards", true) addEventHandler ("GetRewards", getRootElement(), onLeave) Bad argument @ 'addEventHandler [Expected element at argument 2, got nil' Edited December 13, 2013 by Guest Link to comment
manve1 Posted December 13, 2013 Share Posted December 13, 2013 local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) function mission1 () addEventHandler ("onMarkerHit", mission1Marker, onHit) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) addEventHandler ("onMarkerHit", mission1Marker, mission1) function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got 2000$ Good Job!", source, 0, 255, 0, false) Link to comment
LiOneLMeSsIShoT Posted December 13, 2013 Author Share Posted December 13, 2013 local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) function mission1 () addEventHandler ("onMarkerHit", mission1Marker, onHit) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) addEventHandler ("onMarkerHit", mission1Marker, mission1) function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got 2000$ Good Job!", source, 0, 255, 0, false) alright i've tried it: fixed things here but still there's problem this make the marker spawn already. whatever i want the marker spawn when the player click on the gui button. thats why i have triggerd and putted marker on function. so ? local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) function mission1 (hitElement) addEventHandler ("onMarkerHit", mission1Marker, onHit) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) addEventHandler ("onMarkerHit", mission1Marker, mission1) function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got "..money.."$ Good Job!", source, 0, 255, 0, false) end addEvent ("GetRewards", true) addEventHandler ("GetRewards", getRootElement(), onLeave) Link to comment
LiOneLMeSsIShoT Posted December 13, 2013 Author Share Posted December 13, 2013 ok i have tried it: function mission1 (hitElement) local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) addEventHandler ("onMarkerHit", mission1Marker, mission1) function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got "..money.."$ Good Job!", source, 0, 255, 0, false) end addEvent ("GetRewards", true) addEventHandler ("GetRewards", getRootElement(), onLeave) Still error: :31: addEventHandler argument 2 got nil Link to comment
LiOneLMeSsIShoT Posted December 13, 2013 Author Share Posted December 13, 2013 ok i have tried it: function mission1 (hitElement) local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) addEventHandler ("onMarkerHit", mission1Marker, mission1) function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got "..money.."$ Good Job!", source, 0, 255, 0, false) end addEvent ("GetRewards", true) addEventHandler ("GetRewards", getRootElement(), onLeave) Still error: :31: addEventHandler argument 2 got nil Client side too: function missionClick (button, state) if (button == "left" and state == "up") then guiSetVisible (GUIEditor.window[1], false) showCursor ( false ) triggerServerEvent ("missionStarts", localPlayer) end end Link to comment
LiOneLMeSsIShoT Posted December 13, 2013 Author Share Posted December 13, 2013 the script'd be now: function mission1 () local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) function onHit (hitElement) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end addEventHandler ("onMarkerHit", mission1Marker, onHit) function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got "..money.."$ Good Job!", source, 0, 255, 0, false) end addEvent ("GetRewards", true) addEventHandler ("GetRewards", getRootElement(), onLeave) but i got error: :34:bad argument 'addEventHandler' element at argument 2, got nil Link to comment
LiOneLMeSsIShoT Posted December 13, 2013 Author Share Posted December 13, 2013 the script'd be now: function mission1 () local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) function onHit (hitElement) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end addEventHandler ("onMarkerHit", mission1Marker, onHit) function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got "..money.."$ Good Job!", source, 0, 255, 0, false) end addEvent ("GetRewards", true) addEventHandler ("GetRewards", getRootElement(), onLeave) but i got error: :34:bad argument 'addEventHandler' element at argument 2, got nil i've made it. but still the same error: function mission1 () local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) if getElementType ( source ) == "player" and not isPedInVehicle(source) then triggerClientEvent ("ShowWinWindow", source) end end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) addEventHandler ("onMarkerHit", mission1Marker, mission1) Link to comment
DNL291 Posted December 13, 2013 Share Posted December 13, 2013 function mission1 () local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) addEventHandler ("onMarkerHit", mission1Marker, onHit) end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) function onHit (hitElement) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got "..money.."$ Good Job!", source, 0, 255, 0, false) end addEvent ("GetRewards", true) addEventHandler ("GetRewards", getRootElement(), onLeave) Link to comment
LiOneLMeSsIShoT Posted December 13, 2013 Author Share Posted December 13, 2013 function mission1 () local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) addEventHandler ("onMarkerHit", mission1Marker, onHit) end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) function onHit (hitElement) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end function onLeave () local money = math.random(2000, 2500) givePlayerMoney (source, money) outputChatBox ("You have got "..money.."$ Good Job!", source, 0, 255, 0, false) end addEvent ("GetRewards", true) addEventHandler ("GetRewards", getRootElement(), onLeave) Yeah works with that: but function mission1 () local mission1Marker = createMarker (2000.58984375, -1733.0361328125, 13.3828125, 'cylinder', 2.0, 255, 0, 0, 150) addEventHandler ("onMarkerHit", mission1Marker, onHit) end addEvent ("missionStarts", true) addEventHandler ("missionStarts", getRootElement(), mission1) function onHit (hitElement) if getElementType ( hitElement ) == "player" and not isPedInVehicle(hitElement) then triggerClientEvent ("ShowWinWindow", hitElement) end end function DAR () destroyElement (mission1Marker) end addEvent ("destroyAndReward", true) addEventHandler ("destroyAndReward", getRootElement(), DAR) client: function CloseBtn () guiSetVisible (GUIEditor.window[1], false) showCursor ( false ) triggerServerEvent ("destroyAndReward", localPlayer) end i've tried to destroy the marker when the player click on the button. but not works. please help Link to comment
DNL291 Posted December 13, 2013 Share Posted December 13, 2013 That's because you're creating the marker locally. Just remove 'local' from mission1Marker variable or store the marker in a table. Link to comment
LiOneLMeSsIShoT Posted December 13, 2013 Author Share Posted December 13, 2013 That's because you're creating the marker locally.Just remove 'local' from mission1Marker variable. Thanks a lot.... :D 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