Lua:
function onThink(interval, lastExecution)
function winners(cid)
for _, pid in ipairs(getPlayersOnline()) do
if isInArea(getPlayerPosition(pid), War.fromPos, War.toPos) then
doTeleportThing(pid, War.rewardRoom, false)
end
end
end
local War = {
fromPos={x=638, y=711, z=7, stackpos=253},
toPos={x=751, y=780, z=7, stackpos=253},
rewardRoom = {x=636,y=662,z=7,stackpos=1}}
local redStorage = getGlobalStorageValue(2001)
local blueStorage = getGlobalStorageValue(2002)
if (blueStorage >= 1 and redStorage < 1) then
addEvent(winners,5000,cid)
setGlobalStorageValue(2001, 0)
setGlobalStorageValue(2002, 0)
doBroadcastMessage("The War-Event has finished, The Blue team has won.")
elseif (blueStorage < 1 and redStorage >= 1) then
doBroadcastMessage("The War-Event has finished, The Red team has won.")
addEvent(winners,5000,cid)
setGlobalStorageValue(2001, 0)
setGlobalStorageValue(2002, 0)
end
return true
end
end
This script basically checks the last person to die in a war event, and whenever they die. the server crashes