timer = {} counted = {} local first_run_loot = nil function loot_for_enemies_control_init(e) Hide(e) CollisionOff(e) end function loot_for_enemies_control_main(e) if first_run_loot == nil then first_run_loot = 1 return end end function DropLoot(a) local tempcount = 0 local try = 0 local b = 0 local c = 0 local le = 0 repeat b = math.random(0,max_loot_items) --max number needs to be equal or more than max number of loot items tempcount = tempcount + 1 c = math.random(0,100) --% chance to drop le = loot_entity_number[b] if drop_chance[le] ~= nil then if c > drop_chance[le] then try = try + 1 b = 0 end end until (loot[le] ~= nil and loot[le] == 1) or tempcount >= 9 or try > rerolls counted[a] = 1 if loot[le] ~= nil then loot[le] = 2 CollisionOff(le) SetPosition(le,GetEntityPositionX(a),GetEntityPositionY(a)+1,GetEntityPositionZ(a)) SetRotation(le,GetEntityAngleX(a),GetEntityAngleY(a),GetEntityAngleZ(a)) --ResetPosition(le,g_Entity[a]['x'],GetEntityPositionY(a)+10,g_Entity[a]['z']) --ResetRotation(le,g_Entity[a]['anglex'],g_Entity[a]['angley'],g_Entity[a]['anglez']) CollisionOn(le) Show(le) --PromptDuration("dropped some loot @ "..le..", "..GetEntityPositionX(le).." , "..GetEntityPositionX(a).." v "..GetEntityPositionY(le).." , "..GetEntityPositionZ(le),3000) end end