<?xml version="1.0" encoding="UTF-8"?><mod name="CTF" version="1.0" author="Doggynub" contact="otland.net" enabled="yes"><config name="CTF_CONFIG"><![CDATA[--[[ Storage Settings]]--
Owner =1900-- put empty storage
FLAG2_INn =4000-- put empty storage
FLAG_IN =4001-- put empty storage
TEAM1_FLAGS =3030-- put empty storage
TEAM2_FLAGS =3031-- put empty storage
Event_Start =3032-- put empty storage
Event_timeend =3033-- put empty storage
Event_Tile_Close =3039-- put empty storage
joined =2023--put empty storage
Timer =1010--put empty storage----------------------------------------[[ Places setting ]]--
BLUE_FLAG ={x=5036,y=2037,z=7}-- Blue flag Place
RED_FLAG ={x=5114,y=2112,z=7}--red flag Place
Tp_Place ={x=1000,y=994,z=7}-- Place where the event teleport will be created.
Wait_Place ={x=5053, y=2059, z=7}-- Positions Players will be sent when the enter event's teleport
frompos ={x=5051,y=2057,z=7}--start sqm in the waiting room(1 floor)
topos ={x=5055,y=2061,z=7}-- end sqm in the waiting room(1 floor)
Red_Position ={x=5114,y=2101,z=7}-- Red team temple pos
Blue_Position ={x=5046,y=2036,z=7}-- Blue team temple pos-----------------------------------------[[Event setting ]]--
Event_WaitTime =0.2-- time for the collection of player then event will start (in minutes)
Event_MaxTime =3--- in minutes ( this is the max time for an event to bb running )
Players_Speed =200-- put the level of base speed in event ( like if you want the speed of lvl 300 then wright 300)
Flag_Holder_Speed =7-- [Old-Styled feature] speed for the player when he hold a flag better not to increase.
TEAM2_NAME ="Red"-- team 2 name
TEAM1_NAME ="Green"-- team 1 name
FLAG_SCORE =3-- score when team gets he wins
Teleport_On_Score =true-- this teleport all players to their team main position when some one score a flag , make false to disable.
Players_Least_Number =2-- this means if there is less than 2 players joined the event will be cancelled
Min_Join_Level =50-- min lvl for a player to join event
rewards_random ={[60]={-- Rewards of 60% , if it is then it will randomly give one of the items in the items verible if there you put more than one item there
items ={2446,2446,2446}},[30]={-- Rewards of 30%
items ={2466,2466,2466}},[10]={-- Rewards of 10%
items ={2160,2160,2160}}}]]></config><lib name="CTF-lib"><![CDATA[function isTeamTwo(cid)return(isPlayer(cid)and getPlayerStorageValue(cid,5054)>-1)endfunction isTeamOne(cid)return(isPlayer(cid)and getPlayerStorageValue(cid,5055)>-1)endfunction resetTheTeams(cid)return(isPlayer(cid)and setPlayerStorageValue(cid,5054,-1)and setPlayerStorageValue(cid,5055,-1))endfunction setflagOwner(cid)return setPlayerStorageValue(cid,Owner,1)endfunction flagOwner(cid)return(isPlayer(cid)and getPlayerStorageValue(cid,Owner)>0)endfunction releaseBF(cid)
setGlobalStorageValue(FLAG_IN,-1)
setPlayerStorageValue(cid,103,0)
setPlayerStorageValue(cid,Owner,-1)returntrueendfunction releaseRF(cid)
setGlobalStorageValue(FLAG2_INn,-1)
setPlayerStorageValue(cid,103,0)
setPlayerStorageValue(cid,Owner,-1)returntrueendfunction setFirstTeam(cid)return setPlayerStorageValue(cid,5055,1)endfunction setSecondTeam(cid)return setPlayerStorageValue(cid,5054,2)endfunction addToRed()return setGlobalStorageValue(TEAM2_FLAGS,getGlobalStorageValue(TEAM2_FLAGS)+1)endfunction addToBlue()return setGlobalStorageValue(TEAM1_FLAGS,getGlobalStorageValue(TEAM1_FLAGS)+1)endfunction getBlueScore()return getGlobalStorageValue(TEAM1_FLAGS)endfunction getRedScore()return getGlobalStorageValue(TEAM2_FLAGS)endfunction getTheSpeed(level)
value =(220+(2*(level -1)))return value
endfunction resetTheStorage()
setGlobalStorageValue(Event_Start,-1)
setGlobalStorageValue(Event_timeend,-1)
setGlobalStorageValue(TEAM1_FLAGS,0)
setGlobalStorageValue(FLAG2_INn,-1)
setGlobalStorageValue(FLAG_IN,-1)
setGlobalStorageValue(TEAM2_FLAGS,0)returntrueendfunction blueStolen()return getGlobalStorageValue(FLAG_IN)endfunction redStolen()return getGlobalStorageValue(FLAG2_INn)endfunction giveReward(cid)local t = math.random(1,100)if t <=10thenlocal rare = rewards_random[10].items[math.random(1,#rewards_random[10].items)]
doPlayerAddItem(cid,rare,1)
doPlayerSendTextMessage(cid,25,"Rare rate Reward : you won "..getItemNameById(rare)..".")elseif t >10and t <=40thenlocal semi = rewards_random[30].items[math.random(1,#rewards_random[30].items)]
doPlayerAddItem(cid,semi,1)
doPlayerSendTextMessage(cid,25,"Semi rate Reward : you won "..getItemNameById(semi)..".")elseif t >40thenlocal aver = rewards_random[60].items[math.random(1,#rewards_random[60].items)]
doPlayerAddItem(cid,aver,1)
doPlayerSendTextMessage(cid,25,"Averege rate Reward : you won "..getItemNameById(aver)..".")endreturntrueend]]></lib><event type="login" name="Tutorial Login" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')function onLogin(cid)if getGlobalStorageValue(Event_Start)<1thenif isTeamOne(cid)or isTeamTwo(cid)then
resetTheTeams(cid)endend
registerCreatureEvent(cid,"Attk")
registerCreatureEvent(cid,"prepare")returntrueend]]></event><event type="combat" name="Attk" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')function onCombat(cid, target)if isTeamOne(cid)and isTeamOne(target)thenreturnfalseendif isTeamTwo(cid)and isTeamTwo(target)thenreturnfalseendreturntrueend]]></event><event type="statschange" name="prepare" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')local corpse_ids ={[0]=3065,-- female[1]=3058-- male}function onStatsChange(cid, attacker, type, combat, value)if combat == COMBAT_HEALING thenreturntrueendif getCreatureHealth(cid)> value thenreturntrueendif getGlobalStorageValue(Event_Start)>0thenif flagOwner(cid)thenif isTeamOne(cid)then
doItemSetAttribute(doCreateItem(corpse_ids[getPlayerSex(cid)],1, getThingPos(cid)),"description","You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker)and"a "..string.lower(getCreatureName(attacker))or isCreature(attacker)and getCreatureName(attacker)or"a field item").."[Flag Holder].")
doTeleportThing(cid,Blue_Position,false)
doSendMagicEffect(Blue_Position,10)
doCreatureAddHealth(cid,getCreatureMaxHealth(cid))
doCreatureAddMana(cid,getCreatureMaxMana(cid))
releaseRF(cid)for _,cid in ipairs(getPlayersOnline())doif isTeamOne(cid)or isTeamTwo(cid)then
doPlayerSendTextMessage(cid,22,getCreatureName(cid).." has died with the "..TEAM2_NAME.." team flag. The flag is returned back to the "..TEAM1_NAME.." team.")endendreturnfalseelseif isTeamTwo(cid)then
doItemSetAttribute(doCreateItem(corpse_ids[getPlayerSex(cid)],1, getThingPos(cid)),"description","You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker)and"a "..string.lower(getCreatureName(attacker))or isCreature(attacker)and getCreatureName(attacker)or"a field item").."[Flag Holder].")
doTeleportThing(cid,Red_Position,false)
doSendMagicEffect(Red_Position,10)
doCreatureAddHealth(cid,getCreatureMaxHealth(cid))
doCreatureAddMana(cid,getCreatureMaxMana(cid))
releaseBF(cid)for _,cid in ipairs(getPlayersOnline())doif isTeamOne(cid)or isTeamTwo(cid)then
doPlayerSendTextMessage(cid,22,getCreatureName(cid).." has died with the "..TEAM1_NAME.." team flag. The flag is returned back to the "..TEAM1_NAME.." team.")endendreturnfalseendelseif isTeamOne(cid)or isTeamTwo(cid)then
doItemSetAttribute(doCreateItem(corpse_ids[getPlayerSex(cid)],1, getThingPos(cid)),"description","You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker)and"a "..string.lower(getCreatureName(attacker))or isCreature(attacker)and getCreatureName(attacker)or"a field item").."[Normal kill].")
doTeleportThing(cid,( isTeamTwo(cid)and Red_Position or Blue_Position ),false)
doSendMagicEffect(Red_Position,10)
doCreatureAddHealth(cid,getCreatureMaxHealth(cid))
doCreatureAddMana(cid,getCreatureMaxMana(cid))returnfalseendendendreturntrueend]]></event><movevent type="StepIn" actionid="6000" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')function eventEnds()
doBroadcastMessage('CTF-Event : The '..TEAM2_NAME..' team won and reciaved their reward.')for _,cid in ipairs(getPlayersOnline())doif isTeamTwo(cid)then
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
doRemoveConditions(cid,false)
resetTheTeams(cid)
doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid))- getCreatureSpeed(cid))
giveReward(cid)elseif isTeamOne(cid)then
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
doRemoveConditions(cid,false)
doPlayerSendTextMessage(cid,22,'Your team have lost.')
resetTheTeams(cid)
doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid))- getCreatureSpeed(cid))endend
addEvent(resetTheStorage,5)endfunction onStepIn(cid, item, position, fromPosition)if getGlobalStorageValue(Event_Start)>0and getGlobalStorageValue(Event_timeend)>0thenif isTeamTwo(cid)and redStolen()<0thenifnot flagOwner(cid)then
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,27,"This is your team flag, you cant take it!")endelseif isTeamTwo(cid)and redStolen()>0and blueStolen()<0then
doPlayerSendTextMessage(cid,27,"Your team's Flag has been stolen, go get it back!")
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)returntrueendif isTeamTwo(cid)and flagOwner(cid)and blueStolen()>0and redStolen()<0thenif getRedScore()== FLAG_SCORE -1then
addEvent(eventEnds,1000)
addToRed()
doTeleportThing(cid, fromPosition,TRUE)
releaseBF(cid)
doChangeSpeed(cid, getTheSpeed(Players_Speed)- getCreatureSpeed(cid))for _,tid in ipairs(getPlayersOnline())doif isTeamOne(tid)or isTeamTwo(tid)then
doPlayerSendTextMessage(tid,22,getCreatureName(cid).." have captured the last flag and earned match win to the ".. TEAM2_NAME.." team!")endendelse
releaseBF(cid)
addToRed()
doTeleportThing(cid, fromPosition,TRUE)
doChangeSpeed(cid, getTheSpeed(Players_Speed)- getCreatureSpeed(cid))for _,tid in ipairs(getPlayersOnline())doif isTeamOne(tid)or isTeamTwo(tid)then
doPlayerSendTextMessage(tid,22,getCreatureName(cid).." have captured the flag and earned 1 point to the ".. TEAM2_NAME.." team!")if Teleport_On_Score ==truethen
doTeleportThing(tid,( isTeamTwo(tid)and Red_Position or Blue_Position ),false)
doSendMagicEffect(getThingPos(tid),10)endendendendendif isTeamOne(cid)thenif blueStolen()<0and redStolen()>0thenif flagOwner(cid)then
doPlayerSendTextMessage(cid,27,"You already holding the flag!")
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)elseif(not flagOwner(cid))then
doPlayerSendTextMessage(cid,27,"Your Team mates already stole the oponent flag, defend him!")
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)endelseif blueStolen()>0and redStolen()<0then
doPlayerSendTextMessage(cid,27,"Your team's flag is taken you can't capture or steel a flag!")
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)endif redStolen()<0and blueStolen()<0then
setGlobalStorageValue(FLAG2_INn,1)
setflagOwner(cid)
setPlayerStorageValue(cid,103, os.time()+300)
doTeleportThing(cid, fromPosition,TRUE)
doChangeSpeed(cid, getTheSpeed(Flag_Holder_Speed)- getCreatureSpeed(cid))for _,tid in ipairs(getPlayersOnline())doif isTeamOne(tid)or isTeamTwo(tid)then
doPlayerSendTextMessage(tid,22,getCreatureName(cid).." stolen the "..TEAM2_NAME.." team flag!")endendendendendreturntrueend]]></movevent><movevent type="StepIn" actionid="3435" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)if getStorage(Event_Tile_Close)>0thenif getPlayerLevel(cid)< Min_Join_Level then
doTeleportThing(cid,fromPosition,false)
doSendMagicEffect(fromPosition,10)
doPlayerSendTextMessage(cid,21,"Only players of level "..Min_Join_Level.." are allowed to pass.")else
doTeleportThing(cid,Wait_Place,false)
doSendMagicEffect(Wait_Place,10)endelse
doTeleportThing(cid,fromPosition,false)
doSendMagicEffect(fromPosition,10)
doPlayerSendTextMessage(cid,21,"Come back later, event is closed now.")endreturntrueend]]></movevent><movevent type="StepIn" actionid="6001" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')function eventEnded()if getGlobalStorageValue(Event_Start)>0and getGlobalStorageValue(Event_timeend)>0then
doBroadcastMessage('CTF-Event : The '.. TEAM1_NAME..' team won and reciaved their reward.')for _,cid in ipairs(getPlayersOnline())doif isTeamOne(cid)then
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
doRemoveConditions(cid,false)
resetTheTeams(cid)
doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid))- getCreatureSpeed(cid))
giveReward(cid)elseif isTeamTwo(cid)then
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
doRemoveConditions(cid,false)
doPlayerSendTextMessage(cid,22,'Your team have lost.')
resetTheTeams(cid)
doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid))- getCreatureSpeed(cid))endendend
addEvent(resetTheStorage,5)endfunction onStepIn(cid, item, position, fromPosition)if getGlobalStorageValue(Event_Start)>0and getGlobalStorageValue(Event_timeend)>0thenif isTeamOne(cid)and blueStolen()<0thenifnot flagOwner(cid)then
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,27,"This is your team flag, you cant take it!")endelseif isTeamOne(cid)and blueStolen()>0and redStolen()<0then
doPlayerSendTextMessage(cid,27,"Your team's Flag has been stolen, go get it back!")
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)returntrueendif isTeamOne(cid)and flagOwner(cid)and redStolen()>0and blueStolen()<0thenif getBlueScore()== FLAG_SCORE -1then
addEvent(eventEnded,1000)
addToBlue()
doTeleportThing(cid, fromPosition,TRUE)
doChangeSpeed(cid, getTheSpeed(Players_Speed)- getCreatureSpeed(cid))
releaseRF(cid)for _,tid in ipairs(getPlayersOnline())doif isTeamOne(tid)or isTeamTwo(tid)then
doPlayerSendTextMessage(tid,22,getCreatureName(cid).." have captured the last flag and earned match win to the ".. TEAM1_NAME.." team!")endendelse
releaseRF(cid)
addToBlue()
doTeleportThing(cid, fromPosition,TRUE)
doChangeSpeed(cid, getTheSpeed(Players_Speed)- getCreatureSpeed(cid))for _,tid in ipairs(getPlayersOnline())doif isTeamOne(tid)or isTeamTwo(tid)then
doPlayerSendTextMessage(tid,22,getCreatureName(cid).." have captured the flag and earned 1 point to the ".. TEAM1_NAME.." team!")if Teleport_On_Score ==truethen
doTeleportThing(tid,( isTeamTwo(tid)and Red_Position or Blue_Position ),false)
doSendMagicEffect(getThingPos(tid),10)endendendendendif isTeamTwo(cid)thenif blueStolen()>0and redStolen()<0thenif flagOwner(cid)then
doPlayerSendTextMessage(cid,27,"You already holding the flag!")
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)elseif(not flagOwner(cid))then
doPlayerSendTextMessage(cid,27,"Your Team mates already stole the oponent flag, defend him!")
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)endelseif redStolen()>0and blueStolen()<0then
doPlayerSendTextMessage(cid,27,"Your team's flag is taken you can't capture or steel a flag!")
doTeleportThing(cid, fromPosition,TRUE)
doSendMagicEffect(getThingPos(cid),2)endif blueStolen()<0and redStolen()<0then
setGlobalStorageValue(FLAG_IN,1)
setflagOwner(cid)
setPlayerStorageValue(cid,103, os.time()+300)
doTeleportThing(cid, fromPosition,TRUE)
doChangeSpeed(cid, getTheSpeed(Flag_Holder_Speed)- getCreatureSpeed(cid))for _,tid in ipairs(getPlayersOnline())doif isTeamOne(tid)or isTeamTwo(tid)then
doPlayerSendTextMessage(tid,22,getCreatureName(cid).." stolen the "..TEAM1_NAME.." team flag!")endendendendendreturntrueend]]></movevent><globalevent name="ctf" time="12:19:05" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')local players ={}function eventEnd()if getGlobalStorageValue(Event_Start)>0and getGlobalStorageValue(Event_timeend)>0thenif getRedScore()> getBlueScore()then
doBroadcastMessage('CTF-Event : The '.. TEAM2_NAME..' team won and recieved their reward.')for _,cid in ipairs(getPlayersOnline())doif isTeamTwo(cid)then
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
doRemoveConditions(cid,false)
resetTheTeams(cid)
doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid))- getCreatureSpeed(cid))
giveReward(cid)elseif isTeamOne(cid)then
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
doRemoveConditions(cid,false)
doPlayerSendTextMessage(cid,22,'Your team have lost.')
resetTheTeams(cid)
doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid))- getCreatureSpeed(cid))endendelseif getRedScore()< getBlueScore()then
doBroadcastMessage('CTF-Event : The '.. TEAM1_NAME..' team won and recieved their reward.')for _,cid in ipairs(getPlayersOnline())doif isTeamOne(cid)then
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
doRemoveConditions(cid,false)
resetTheTeams(cid)
doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid))- getCreatureSpeed(cid))
giveReward(cid)elseif isTeamTwo(cid)then
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
doRemoveConditions(cid,false)
doPlayerSendTextMessage(cid,22,'Your team have lost.')
resetTheTeams(cid)
doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid))- getCreatureSpeed(cid))endendelseif getRedScore()== getBlueScore()then
doBroadcastMessage('CTF-Event : The Event ended with a draw between both teams.')for _,cid in ipairs(getPlayersOnline())doif isTeamTwo(cid)or isTeamOne(cid)then
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)),false)
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)),10)
doRemoveConditions(cid,false)
doPlayerSendTextMessage(cid,22,'It was a draw between both teams.')
resetTheTeams(cid)
doChangeSpeed(cid, getTheSpeed(getPlayerLevel(cid))- getCreatureSpeed(cid))endendend
addEvent(resetTheStorage,1000)endendfunction eventStart()
doSetStorage(Event_Tile_Close,-1)
setGlobalStorageValue(Event_timeend,1)
setGlobalStorageValue(Timer, os.time()+ Event_MaxTime*60)
addEvent(eventEnd,Event_MaxTime*60*1000)local bmale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(bmale, CONDITION_PARAM_TICKS,-1)
addOutfitCondition(bmale,{lookType = math.random(128,134), lookHead =115, lookBody =114, lookLegs =81, lookFeet =81, lookTypeEx =0, lookAddons =3})local bfemale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(bfemale, CONDITION_PARAM_TICKS,-1)
addOutfitCondition(bfemale,{lookType = math.random(136,142), lookHead =115, lookBody =114, lookLegs =81, lookFeet =81, lookTypeEx =0, lookAddons =3})local rmale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(rmale, CONDITION_PARAM_TICKS,-1)
addOutfitCondition(rmale,{lookType = math.random(128,134), lookHead =94, lookBody =94, lookLegs =94, lookFeet =94, lookTypeEx =0, lookAddons =3})local rfemale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(rfemale, CONDITION_PARAM_TICKS,-1)
addOutfitCondition(rfemale,{lookType = math.random(136,142),lookHead =94, lookBody =94, lookLegs =94, lookFeet =94, lookTypeEx =0, lookAddons =3})local fight = createConditionObject(CONDITION_INFIGHT)
setConditionParam(fight, CONDITION_PARAM_TICKS,-1)for v = frompos.x , topos.x dofor k = frompos.y , topos.y dofor i =1,200do
position ={x = v, y = k, z =7, stackpos = i}
pid = getThingfromPos(position).uid
if(pid ~=niland isPlayer(pid))then
table.insert(players, pid)endendendendif math.mod(#players,2)~=0then
doTeleportThing(players[#players],getTownTemplePosition(getPlayerTown(players[#players])),false)
doSendMagicEffect(getThingPosition(players[#players]),10)
doPlayerSendTextMessage(players[#players],19,"Sorry, you have been kicked from event to balance teams.")
table.remove(players)endif#players < Players_Least_Number then
doBroadcastMessage("CTF event was cancelled because less than "..Players_Least_Number.." players joined.[joined : "..#players.." players]")
resetTheStorage()if#players >0thenfor i =1,#players do
doTeleportThing(players[i],getTownTemplePosition(getPlayerTown(players[i])),false)
doSendMagicEffect(getThingPos(players[i]),10)endendelse
doBroadcastMessage("CTF started")for i =1, math.floor(#players/2)do
setFirstTeam(players[i])endfor i = math.floor(#players/2)+1,#players do
setSecondTeam(players[i])endfor _,cid in ipairs(getPlayersOnline())doif isTeamOne(cid)thenif getPlayerSex(cid)==1then
doAddCondition(cid, bmale)elseif getPlayerSex(cid)~=1then
doAddCondition(cid, bfemale)end
doAddCondition(cid, fight)
doTeleportThing(cid,Blue_Position,false)
doSendMagicEffect(Blue_Position,10)
doChangeSpeed(cid, getTheSpeed(Players_Speed)- getCreatureSpeed(cid))elseif isTeamTwo(cid)thenif getPlayerSex(cid)==1then
doAddCondition(cid, rmale)elseif getPlayerSex(cid)~=1then
doAddCondition(cid, rfemale)end
doAddCondition(cid, fight)
doTeleportThing(cid,Red_Position,false)
doSendMagicEffect(Red_Position,10)
doChangeSpeed(cid, getTheSpeed(Players_Speed)- getCreatureSpeed(cid))endend
players ={}endendfunction onTime()if getGlobalStorageValue(Event_Start)<0then
setGlobalStorageValue(Event_Start,1)
doSetStorage(Event_Tile_Close,1)
doBroadcastMessage("CTF event is opened and teleport is created. It will start in "..Event_WaitTime.." minutes.")
players ={}if getTileItemById(Tp_Place,1387).uid <1then
doItemSetAttribute(doCreateItem(1387,1, Tp_Place),"aid",3435)end
f= Event_WaitTime -1for i =1,Event_WaitTime-1do
addEvent(doBroadcastMessage,i*60*1000,"CTF event is opened and teleport is created. It will start in "..f.." minutes.")
f= f-1end
addEvent(eventStart,Event_WaitTime*60*1000)endreturntrueend]]></globalevent><globalevent name="ctf" interval="3000" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')local bl = BLUE_FLAG
local re = RED_FLAG
function onThink(interval)if getGlobalStorageValue(Event_Start)>0and getGlobalStorageValue(Event_timeend)>0thenif redStolen()<0then
doSendAnimatedText(re,"FLAG!",TEXTCOLOR_DARKRED)
doSendMagicEffect(re, CONST_ME_SOUND_RED)endif blueStolen()<0then
doSendAnimatedText(bl,"FLAG!",TEXTCOLOR_GREEN)
doSendMagicEffect(bl, CONST_ME_SOUND_GREEN)endfor _, cid in ipairs(getPlayersOnline())doif isTeamOne(cid)or isTeamTwo(cid)thenif hasCondition(cid,CONDITION_HASTE)then
doRemoveCondition(cid,CONDITION_HASTE)endendif flagOwner(cid)then
pl = getThingPos(cid)if isTeamTwo(cid)thenif getPlayerStorageValue(cid,103)< os.time()then
releaseBF(cid)for _,cid in ipairs(getPlayersOnline())doif isTeamOne(cid)or isTeamTwo(cid)then
doPlayerSendTextMessage(cid,22,getCreatureName(cid).." wasted 5 minutes with FLAG."..TEAM2_NAME.." flag is again on spawn!")endendelse
doSendAnimatedText(pl,"FLAG!",TEXTCOLOR_GREEN)
doSendMagicEffect(pl, CONST_ME_SOUND_GREEN)endelseif isTeamOne(cid)thenif getPlayerStorageValue(cid,103)< os.time()then
releaseRF(cid)for _,cid in ipairs(getPlayersOnline())doif isTeamOne(cid)or isTeamTwo(cid)then
doPlayerSendTextMessage(cid,22,getCreatureName(cid).." wasted 5 minutes with FLAG."..TEAM1_NAME.." flag is again on spawn!")endendelse
doSendAnimatedText(pl,"FLAG!",COLOR_RED)
doSendMagicEffect(pl, CONST_ME_SOUND_RED)endendendendendreturntrueend]]></globalevent><globalevent name="timer" interval="400" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')function onThink(interval)for _,cid in ipairs(getPlayersOnline())doif isTeamOne(cid)or isTeamTwo(cid)thenif getGlobalStorageValue(Event_Start)>0and getGlobalStorageValue(Event_timeend)>0thenif getGlobalStorageValue(Timer)- os.time()>=0then
doPlayerSendCancel(cid,"Time -> ".. os.date("%M:%S ",getGlobalStorageValue(Timer)- os.time()).." | ".. TEAM1_NAME.." Score : "..getBlueScore(cid).."/"..FLAG_SCORE.." captures | ".. TEAM2_NAME.." Score : "..getRedScore(cid).."/"..FLAG_SCORE.." captures")endendendendreturntrueend]]></globalevent><globalevent name="starting" type="startup" event="script"><![CDATA[
domodlib('CTF_CONFIG')
domodlib('CTF-lib')function onStartup()
resetTheStorage()returntrueend]]></globalevent></mod>
Pergunta
LuanMahteus 0
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados