Jump to content

help! miner job


scolen

Recommended Posts

I created a Miner Job but there is a problem. When I hit the plant command several times, I could mine only the 5 stones in this script, but the other stones are not destroyed. What is the reason for this? Please help? 

addEvent("startMinerJob", true)


function startJob(thePlayer)

  if not (getElementData(thePlayer, "Jobs") == "miner") then 
     setElementData(thePlayer, "Jobs", "miner")
  end

    function plant(thePlayer)



        if (getElementData(thePlayer, "Jobs") == "miner") then 
            x, y, z = getElementPosition(thePlayer)

            disx = 611.54028
            disy = 878.61017
            disz = -42.9609

            if (getDistanceBetweenPoints3D(x, y, z, disx, disy, disz) < 90) then 

                outputChatBox("Bomb Planted!", thePlayer, 255, 0, 0)

           setTimer(function()

               createExplosion(x, y, z, 10)
        
   
               stone1 = createObject(3930, x+0,   y+1, z-0.5)
               stone2 = createObject(3930, x+1*2, y+3, z-0.5)
               stone3 = createObject(3930, x+2*2, y+2, z-0.5)
               stone4 = createObject(3930, x+3*2, y+5, z-0.5)
               stone5 = createObject(3930, x+4*2, y+4, z-0.5)
   
               x1, y1, z1 =  getElementPosition(stone1)
               x2, y2, z2 =  getElementPosition(stone2)
               x3, y3, z3 =  getElementPosition(stone3)
               x4, y4, z4 =  getElementPosition(stone4)
               x5, y5, z5 =  getElementPosition(stone5)
   
               marker1 = createMarker(x1, y1, z1, "cylinder", 1.0, 0, 0, 0, 0)
               marker2 = createMarker(x2, y2, z2, "cylinder", 1.0, 0, 0, 0, 0)
               marker3 = createMarker(x3, y3, z3, "cylinder", 1.0, 0, 0, 0, 0)
               marker4 = createMarker(x4, y4, z4, "cylinder", 1.0, 0, 0, 0, 0)
               marker5 = createMarker(x5, y5, z5, "cylinder", 1.0, 0, 0, 0, 0)
   
               addEventHandler("onMarkerHit", marker1, function(thePlayer)
           
                 setPedFrozen(thePlayer, true)
                 setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
                 destroyElement(marker1)
   
                  setTimer(function()

                     destroyElement(stone1)
                     setPedFrozen(thePlayer, false)
                     givePlayerMoney(thePlayer, 300)

                  end, 3000, 1)
           
                end)
   
               addEventHandler("onMarkerHit", marker2, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker2)
   
               setTimer(function()
                   destroyElement(stone2)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1)
           
               end)
   
               addEventHandler("onMarkerHit", marker3, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker3)
   
               setTimer(function()
                   destroyElement(stone3)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1)
           
               end)
   
              addEventHandler("onMarkerHit", marker4, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker4)
   
               setTimer(function()
                   destroyElement(stone4)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1)
           
               end)
   
               addEventHandler("onMarkerHit", marker5, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker5)
   
               setTimer(function()
                   destroyElement(stone5)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1)
           
               end)
   
     
            end, 5000, 1)

            end

        

        end


    end

  addCommandHandler("plant", plant)

end

addEventHandler("startMinerJob", root, startJob)




--[[ Leave Miner Job Section  ]]
addEvent("leaveMinerJob", true)
function leaveJob(thePlayer)
   if (getElementData(thePlayer, "Jobs") == "miner") then 

      setElementData(thePlayer, "Jobs", nil)
      outputChatBox("you leaved miner job!", thePlayer, 0, 255, 0)

   end
end
addEventHandler("leaveMinerJob", root, leaveJob)

 

Link to comment
addEvent("startMinerJob", true)


function startJob(thePlayer)

  if not (getElementData(thePlayer, "Jobs") == "miner") then 
     setElementData(thePlayer, "Jobs", "miner")
  end

    function plant(thePlayer)



        if (getElementData(thePlayer, "Jobs") == "miner") then 
            x, y, z = getElementPosition(thePlayer)

            disx = 611.54028
            disy = 878.61017
            disz = -42.9609

            if (getDistanceBetweenPoints3D(x, y, z, disx, disy, disz) < 90) then 

                outputChatBox("Bomb Planted!", thePlayer, 255, 0, 0)

           setTimer(function()

               createExplosion(x, y, z, 10)
        
   
               stone1 = createObject(3930, x+0,   y+1, z-0.5)
               stone2 = createObject(3930, x+1*2, y+3, z-0.5)
               stone3 = createObject(3930, x+2*2, y+2, z-0.5)
               stone4 = createObject(3930, x+3*2, y+5, z-0.5)
               stone5 = createObject(3930, x+4*2, y+4, z-0.5)
   
               x1, y1, z1 =  getElementPosition(stone1)
               x2, y2, z2 =  getElementPosition(stone2)
               x3, y3, z3 =  getElementPosition(stone3)
               x4, y4, z4 =  getElementPosition(stone4)
               x5, y5, z5 =  getElementPosition(stone5)
   
               marker1 = createMarker(x1, y1, z1, "cylinder", 1.0, 0, 0, 0, 0)
               marker2 = createMarker(x2, y2, z2, "cylinder", 1.0, 0, 0, 0, 0)
               marker3 = createMarker(x3, y3, z3, "cylinder", 1.0, 0, 0, 0, 0)
               marker4 = createMarker(x4, y4, z4, "cylinder", 1.0, 0, 0, 0, 0)
               marker5 = createMarker(x5, y5, z5, "cylinder", 1.0, 0, 0, 0, 0)
   
               addEventHandler("onMarkerHit", marker1, function(thePlayer)
           
                 setPedFrozen(thePlayer, true)
                 setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
                 destroyElement(marker1)
   
                  setTimer(function(stone1)

                     destroyElement(stone1)
                     setPedFrozen(thePlayer, false)
                     givePlayerMoney(thePlayer, 300)

                  end, 3000, 1,stone1)
           
                end)
   
               addEventHandler("onMarkerHit", marker2, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker2)
   
               setTimer(function(stone2)
                   destroyElement(stone2)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1,stone2)
           
               end)
   
               addEventHandler("onMarkerHit", marker3, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker3)
   
               setTimer(function(stone3)
                   destroyElement(stone3)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1,stone3)
           
               end)
   
              addEventHandler("onMarkerHit", marker4, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker4)
   
               setTimer(function(stone4)
                   destroyElement(stone4)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1,stone4)
           
               end)
   
               addEventHandler("onMarkerHit", marker5, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker5)
   
               setTimer(function(stone5)
                   destroyElement(stone5)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1, stone5)
           
               end)
   
     
            end, 5000, 1)

            end

        

        end


    end

  addCommandHandler("plant", plant)

end

addEventHandler("startMinerJob", root, startJob)




--[[ Leave Miner Job Section  ]]
addEvent("leaveMinerJob", true)
function leaveJob(thePlayer)
   if (getElementData(thePlayer, "Jobs") == "miner") then 

      setElementData(thePlayer, "Jobs", nil)
      outputChatBox("you leaved miner job!", thePlayer, 0, 255, 0)

   end
end
addEventHandler("leaveMinerJob", root, leaveJob)

try this

Link to comment
21 minutes ago, Burak5312 said:
addEvent("startMinerJob", true)


function startJob(thePlayer)

  if not (getElementData(thePlayer, "Jobs") == "miner") then 
     setElementData(thePlayer, "Jobs", "miner")
  end

    function plant(thePlayer)



        if (getElementData(thePlayer, "Jobs") == "miner") then 
            x, y, z = getElementPosition(thePlayer)

            disx = 611.54028
            disy = 878.61017
            disz = -42.9609

            if (getDistanceBetweenPoints3D(x, y, z, disx, disy, disz) < 90) then 

                outputChatBox("Bomb Planted!", thePlayer, 255, 0, 0)

           setTimer(function()

               createExplosion(x, y, z, 10)
        
   
               stone1 = createObject(3930, x+0,   y+1, z-0.5)
               stone2 = createObject(3930, x+1*2, y+3, z-0.5)
               stone3 = createObject(3930, x+2*2, y+2, z-0.5)
               stone4 = createObject(3930, x+3*2, y+5, z-0.5)
               stone5 = createObject(3930, x+4*2, y+4, z-0.5)
   
               x1, y1, z1 =  getElementPosition(stone1)
               x2, y2, z2 =  getElementPosition(stone2)
               x3, y3, z3 =  getElementPosition(stone3)
               x4, y4, z4 =  getElementPosition(stone4)
               x5, y5, z5 =  getElementPosition(stone5)
   
               marker1 = createMarker(x1, y1, z1, "cylinder", 1.0, 0, 0, 0, 0)
               marker2 = createMarker(x2, y2, z2, "cylinder", 1.0, 0, 0, 0, 0)
               marker3 = createMarker(x3, y3, z3, "cylinder", 1.0, 0, 0, 0, 0)
               marker4 = createMarker(x4, y4, z4, "cylinder", 1.0, 0, 0, 0, 0)
               marker5 = createMarker(x5, y5, z5, "cylinder", 1.0, 0, 0, 0, 0)
   
               addEventHandler("onMarkerHit", marker1, function(thePlayer)
           
                 setPedFrozen(thePlayer, true)
                 setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
                 destroyElement(marker1)
   
                  setTimer(function(stone1)

                     destroyElement(stone1)
                     setPedFrozen(thePlayer, false)
                     givePlayerMoney(thePlayer, 300)

                  end, 3000, 1,stone1)
           
                end)
   
               addEventHandler("onMarkerHit", marker2, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker2)
   
               setTimer(function(stone2)
                   destroyElement(stone2)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1,stone2)
           
               end)
   
               addEventHandler("onMarkerHit", marker3, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker3)
   
               setTimer(function(stone3)
                   destroyElement(stone3)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1,stone3)
           
               end)
   
              addEventHandler("onMarkerHit", marker4, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker4)
   
               setTimer(function(stone4)
                   destroyElement(stone4)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1,stone4)
           
               end)
   
               addEventHandler("onMarkerHit", marker5, function(thePlayer)
           
               setPedFrozen(thePlayer, true)
               setPedAnimation(thePlayer, "FIGHT_B", "FightB_G", -1, false, false, false, false)
               destroyElement(marker5)
   
               setTimer(function(stone5)
                   destroyElement(stone5)
                   setPedFrozen(thePlayer, false)
                   givePlayerMoney(thePlayer, 300)
               end, 3000, 1, stone5)
           
               end)
   
     
            end, 5000, 1)

            end

        

        end


    end

  addCommandHandler("plant", plant)

end

addEventHandler("startMinerJob", root, startJob)




--[[ Leave Miner Job Section  ]]
addEvent("leaveMinerJob", true)
function leaveJob(thePlayer)
   if (getElementData(thePlayer, "Jobs") == "miner") then 

      setElementData(thePlayer, "Jobs", nil)
      outputChatBox("you leaved miner job!", thePlayer, 0, 255, 0)

   end
end
addEventHandler("leaveMinerJob", root, leaveJob)

try this

not wrking

 

Link to comment

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