function onAddItem(moveitem, tileitem, position)
-- middle pos of soccers field, change it to position where ust be your ball spawned!
local ballpos = {x=524, y=1089, z=7, stackpos=1}
local ball = getThingfromPos(ballpos)
local komanda1 = getPlayerNameByGUID(getGlobalStorageValue(15026))
local komanda2 = getPlayerNameByGUID(getGlobalStorageValue(15027))
if tileitem.actionid == 15027 and moveitem.itemid == 2109 then
local wet = getGlobalStorageValue(15025) + 1
local wet2 = getGlobalStorageValue(15024)
doRemoveItem(moveitem.uid, 1)
doSendMagicEffect(ballpos, 5)
setGlobalStorageValue(15025, wet)
if getGlobalStorageValue(15025) ~= 3 then
doCreateItem(2109, 1, ballpos)
end
doBroadcastMessage("GOOOL, "..komanda1.."'s team score! "..wet2.." : " ..wet.. "!", MESSAGE_EVENT_ADVANCE)
if getGlobalStorageValue(15025) == 3 then
doBroadcastMessage("Game over, "..komanda1.."'s team won! "..wet2.." : " ..wet.. "!", MESSAGE_EVENT_ADVANCE)
doPlayerAddItem(komanda1, 9020, 6)
doCreatureSay(komanda1, "Your team won 6 game tokens", TALKTYPE_ORANGE_1)
doSetItemActionId(doCreateItem(8058, 1, ballpos), 15029)
end
elseif tileitem.actionid == 15028 and moveitem.itemid == 2109 then
local wet3 = getGlobalStorageValue(15024) + 1
local wet4 = getGlobalStorageValue(15025)
doRemoveItem(moveitem.uid, 1)
doSendMagicEffect(ballpos, 5)
setGlobalStorageValue(15024, wet3)
if getGlobalStorageValue(15024) ~= 3 then
doCreateItem(2109, 1, ballpos)
end
doBroadcastMessage("GOOOL, "..komanda2.."'s team score! "..wet3.." : " ..wet4.. "!", MESSAGE_EVENT_ADVANCE)
if getGlobalStorageValue(15024) == 3 then
doBroadcastMessage("Game over, "..komanda2.."'s team won! "..wet3.." : " ..wet4.. "!", MESSAGE_EVENT_ADVANCE)
doPlayerAddItem(komanda2, 9020, 6)
doCreatureSay(komanda2, "Your team won 6 game tokens", TALKTYPE_ORANGE_1)
doSetItemActionId(doCreateItem(8058, 1, ballpos), 15029)
end
end
return TRUE
end