LucasFerraz
Systems Analyst
Hi, im doing a Capture the Flag Event and I just have to finish the last function (Getwinners).
Can someone tell me the best way to check it? I'm thinking about operating cost.
Can someone tell me the best way to check it? I'm thinking about operating cost.
LUA:
function ctfcheckwinnerteam(cid)
for _, pid in ipairs(getPlayersOnline()) do
if pid ~= cid and isInRange(getCreaturePosition(pid), ctfconfig.frompos, ctfconfig.topos) then
if getGlobalStorageValue(ctfredGoal) < getGlobalStorageValue(ctfblueGoal) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCondition(cid, CONDITION_INFIGHT)
if getPlayerStorageValue(cid, ctfplayerblueteam) == 1 then
doPlayerAddItem(cid, ctfmedal, 1)
doPlayerAddItem(cid, ctfreward, ctfrewardcount)
doAddEventPoints(cid, 1)
end
doSavePlayerAndHouse(cid)
elseif getGlobalStorageValue(ctfredGoal) > getGlobalStorageValue(ctfblueGoal) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCondition(cid, CONDITION_INFIGHT)
if getPlayerStorageValue(cid, ctfplayerredteam) == 1 then
doPlayerAddItem(cid, ctfmedal, 1)
doPlayerAddItem(cid, ctfreward, ctfrewardcount)
doAddEventPoints(cid, 1)
end
doSavePlayerAndHouse(cid)
elseif getGlobalStorageValue(ctfredGoal) == getGlobalStorageValue(ctfblueGoal) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCondition(cid, CONDITION_INFIGHT)
doSavePlayerAndHouse(cid)
end
end
end
if getGlobalStorageValue(ctfredGoal) < getGlobalStorageValue(ctfblueGoal) then
broadcastMessage("The Blue Team won in Capture the Flag\'s Camp today!", MESSAGE_EVENT_ADVANCE)
elseif getGlobalStorageValue(ctfredGoal) > getGlobalStorageValue(ctfblueGoal) then
broadcastMessage("The Red Team won in Capture the Flag\'s Camp today!", MESSAGE_EVENT_ADVANCE)
elseif getGlobalStorageValue(ctfredGoal) == getGlobalStorageValue(ctfblueGoal) then
broadcastMessage("No winners in Capture the Flag\'s Camp today!", MESSAGE_EVENT_ADVANCE)
end
addEvent(ctfremovetp(cid), 1 * 1000, cid)
addEvent(ctfremovestorages(cid), 2 * 1000, cid)
end
Last edited: