Try this:
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 51511, 1) then
doSummonCreature("Bat", {x = 1037, y = 979, z = 7})
doSummonCreature("Bat", {x = 1033, y = 980, z = 7})
doSummonCreature("Bat", {x = 1035, y = 978, z = 7})...