Jump to content

bank rob script and there is a big problem


scolen

Recommended Posts

I made a bank rob script and there is a big problem. When a person plants the bomb, if another player hits the markers to get money, nothing will happen to him. The person who planted the bomb will get those things. How to fix it?

 

ped1 = createPed(76, 2306.65967, -3.14179, 26.74219, -90)
ped2 = createPed(76, 2312.06738, -11.00959, 26.74219, 90*2)
ped3 = createPed(76, 2318.17793, -7.16190, 26.74219, 90)
entranceGate = createObject(3036, 2304.04873, -17.82764, 26.74219, 0, 0, 90)
exitgate = createObject(2930, 2314.72744, 0.79857, 27.94219, 0, 0, 90)
marker = createMarker(2303.18848, -16.23989, 25.58438, "cylinder", 1.5, 255,0,0)
createBlipAttachedTo(marker, 36)


addEventHandler("onMarkerHit", marker, function(thePlayer)
    
    destroyElement(marker)
    setPedFrozen(thePlayer, true)

    setTimer(function()-- repeat animation set bomb
      setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", -1, false, false, false, false)
    end, 1000, 15)

    setTimer(function()-- bomb planting time
      Dynamite = createObject(1654, 2303.78211, -16.25232, 25.78438, 0, 90, -90)
      setObjectScale(Dynamite, 2)
      setPedFrozen(thePlayer, false)
      outputChatBox("Run! Run! Run! The bomb was planted", thePlayer, 255,0,0)
    end, 15000, 1)
    

    
  setTimer(function()-- settimer to expolsion
    
      x = 1
      while (x < 20) do 
        expolsion = createExplosion(2304.04873, -17.82764, 26.74219, 10)
        x = x+1
      end

      if expolsion then 
        outputChatBox("The entrance of the bank was destroyed", thePlayer, 255,255,0)
        destroyElement(entranceGate)
        destroyElement(Dynamite)
        setPedAnimation(ped1, "ped", "handsup", -1, false)
        setPedAnimation(ped2, "ped", "handsup", -1, false)
        setPedAnimation(ped3, "ped", "handsup", -1, false)
      end

      moneyOb1 = createObject(1212, 2312.23828, -17.32469, 27.38801)
      moneyOb2 = createObject(1212, 2314.83828, -17.32469, 27.38801)
      setObjectScale(moneyOb1, 2)
      setObjectScale(moneyOb2, 2)

      moneyOne = createMarker(2312.33984, -16.28635, 25.84957, "cylinder", 1, 0,255,255)
      moneyTwo = createMarker(2314.93530, -16.28635, 25.84957, "cylinder", 1, 0,255,255)

     addEventHandler("onMarkerHit", moneyOne, function()

        setPedFrozen(thePlayer, true)
        destroyElement(moneyOne)
          setTimer(function()
            setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", -1, false, false, false, false)
          end, 500, 20)
            
          setTimer(function()
            setPedFrozen(thePlayer, false)
            mathRandomMoney = math.random(40000, 60000)
            givePlayerMoney(thePlayer, mathRandomMoney)
            outputChatBox("You have received $"..mathRandomMoney, thePlayer, 0,255,0)
            destroyElement(moneyOb1)

            moneyBag = createObject(1550,0,0,0)
            exports.bone_attach:attachElementToBone(moneyBag,thePlayer,3, 0, -0.17, 0.07, 0, 0, 0)

            setTimer(function() ---- Money bag destroy Time 5min (1000*60*5)
              destroyElement(moneyBag)
            end, 1000*60*5, 1)

          end, 1000*35, 1)
      
     end)

     addEventHandler("onMarkerHit", moneyTwo, function()

      setPedFrozen(thePlayer, true)
      destroyElement(moneyTwo)
        setTimer(function()
          setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", -1, false, false, false, false)
        end, 500, 20)
          
        setTimer(function()
          setPedFrozen(thePlayer, false)
          mathRandomMoney = math.random(40000, 60000)
          givePlayerMoney(thePlayer, mathRandomMoney)
          outputChatBox("You have received $"..mathRandomMoney, thePlayer, 0,255,0)
          destroyElement(moneyOb2)

          moneyBag = createObject(1550,0,0,0)
          exports.bone_attach:attachElementToBone(moneyBag,thePlayer,3, 0, -0.17, 0.07, 0, 0, 0)

          setTimer(function()---- Money bag destroy Time 5min (1000*60*5)
            destroyElement(moneyBag)
          end, 1000*60*5, 1)

        end, 1000*35, 1)
  
   end)
     
  end, 25000, 1)

end)

 

Edited by scolen
Link to comment

Well first you should to this

     addEventHandler("onMarkerHit", moneyOne, function(hitElement)
    local elementType = getElementType(hitElement)
	local thePlayer = hitElement
 	if elementType == "player" then
    --- your code  
      
    
     end 
 end)
     addEventHandler("onMarkerHit", moneyTwo, function(hitElement)
     local elementType = getElementType(hitElement)
	local thePlayer = hitElement
 	if elementType == "player" then
    --- your code  
      
    
     end 
 end)

it should work i didn`t test it

Edited by FlorinSzasz
  • Thanks 1
Link to comment
2 hours ago, FlorinSzasz said:

Well first you should to this

     addEventHandler("onMarkerHit", moneyOne, function(hitElement)
    local elementType = getElementType(hitElement)
	local thePlayer = hitElement
 	if elementType == "player" then
    --- your code  
      
    
     end 
 end)
     addEventHandler("onMarkerHit", moneyTwo, function(hitElement)
     local elementType = getElementType(hitElement)
	local thePlayer = hitElement
 	if elementType == "player" then
    --- your code  
      
    
     end 
 end)

it should work i didn`t test it

thanks my friend ❤️

4 minutes ago, scolen said:

thanks my friend ❤️

 

2 hours ago, FlorinSzasz said:

Well first you should to this

     addEventHandler("onMarkerHit", moneyOne, function(hitElement)
    local elementType = getElementType(hitElement)
	local thePlayer = hitElement
 	if elementType == "player" then
    --- your code  
      
    
     end 
 end)
     addEventHandler("onMarkerHit", moneyTwo, function(hitElement)
     local elementType = getElementType(hitElement)
	local thePlayer = hitElement
 	if elementType == "player" then
    --- your code  
      
    
     end 
 end)

 

May I know why elementType is being looked at?
Edited by scolen
worng
  • Thanks 1
Link to comment
1 hour ago, scolen said:

thanks my friend ❤️

 

May I know why elementType is being looked at?

Well we get the elementType of the hitElement if u look on wiki the event onMarkerHit has a element asked by function that is hitElement which is the element that hits the marker so we check if a player hits the market and nothing else.

  • Thanks 1
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...