• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Get players in area and compare (operating cost) HELP

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
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.
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:
Back
Top