local FleecaBanksRob = {}
local Stage = 0

function FleecaBanksRob.init()
end

function FleecaBanksRob.tick()
	local playerPed = PLAYER.PLAYER_PED_ID()
   	local player = PLAYER.GET_PLAYER_PED(playerPed)
		if(Stage==0) then

			local location = ENTITY.GET_ENTITY_COORDS( playerPed, nil )
				if (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( -353.434, -54.280, 49.037 , location.x, location.y, location.z, true ) < 2 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( 147.434, -1045.106, 29.363 , location.x, location.y, location.z, true ) < 2 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( -1211.214, -335.523, 37.781 , location.x, location.y, location.z, true ) < 2 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( 311.724, -283.415, 54.165 , location.x, location.y, location.z, true ) < 2 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( -2957.724, 481.953, 15.693 , location.x, location.y, location.z, true ) < 2 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( 1175.934, 2711.700, 38.088 , location.x, location.y, location.z, true ) < 2 ) 
				then
					if(PLAYER.GET_PLAYER_WANTED_LEVEL(player)<3) then
					
					FIRE.ADD_EXPLOSION(location.x, location.y, location.z+10,1,1.0,false,false,0)
					PED.SET_PED_COMPONENT_VARIATION(playerPed, 9, 1, 0, 0)
					PLAYER.SET_PLAYER_WANTED_LEVEL(player,3,false)
					PLAYER.SET_PLAYER_WANTED_LEVEL_NOW(player,false)
					Stage = 1

					end
				end
				
	else if not(ENTITY.IS_ENTITY_DEAD(playerPed)) then

			local location = ENTITY.GET_ENTITY_COORDS( playerPed, nil )
				if (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( -353.434, -54.280, 49.037 , location.x, location.y, location.z, true ) < 37 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( 147.434, -1045.106, 29.363 , location.x, location.y, location.z, true ) < 37 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( -1211.214, -335.523, 37.781 , location.x, location.y, location.z, true ) < 37 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( 311.724, -283.415, 54.165 , location.x, location.y, location.z, true ) < 37 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( -2957.724, 481.953, 15.693 , location.x, location.y, location.z, true ) < 37 ) 
				or (GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( 1175.934, 2711.700, 38.088 , location.x, location.y, location.z, true ) < 37 ) 
				then
				if(PLAYER.GET_PLAYER_WANTED_LEVEL(player)<4) then

					PLAYER.SET_PLAYER_WANTED_LEVEL(player,4,false)
					PLAYER.SET_PLAYER_WANTED_LEVEL_NOW(player,false)
					PLAYER.SET_PLAYER_WANTED_LEVEL(player,3,false)
					PLAYER.SET_PLAYER_WANTED_LEVEL_NOW(player,false)
				end
			end
		-- if(PLAYER.GET_PLAYER_WANTED_LEVEL(player)<1) then
		
		if not(PLAYER.IS_PLAYER_WANTED_LEVEL_GREATER(player,0)) then
		
			if (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_zero"))) then
			model = 0
		elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_one"))) then                                
			model = 1                                         
		elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_two"))) then
			model = 2
		end
					local statname = "SP"..model.."_TOTAL_CASH"
					local hash = GAMEPLAY.GET_HASH_KEY(statname)
					local bool, score = STATS.STAT_GET_INT(hash, 0, -1)
					UI.DISPLAY_CASH(true)
					STATS.STAT_SET_INT(hash, score+math.random(15000,35000), true)
					PED.SET_PED_COMPONENT_VARIATION(playerPed, 9, 0, 0, 0)
					AUDIO.PLAY_MISSION_COMPLETE_AUDIO("FRANKLIN_SMALL_01")	
					Stage=0
				end
		else
		
		Stage = 0
		end
	end 
end

function FleecaBanksRob.unload()

end

return FleecaBanksRob