hallabackkid101
New Member
Hello Everyone, I was wondering if it was possible to make a talkaction that lets you start this event automatically. This is the script, Its a war event I pulled off of the resource forum.
Code:
<config name="teamSetting"><![CDATA[
--[[Local Config]]--
--//storages
inBlue = 9900
inRed = 9901
joiner = 9907
blueKills = 9902
redKills = 9903
eventRecruiting = 9904
eventStarted = 9905
eventTime = 9906
itemToGet = 9908
countItemToGet = 9909
nextExecute = 9910
blueCount = 9911
redCount = 9912
--// Positions
teleporterPosition = {x = 96, y = 78, z = 7} --Place where the event tp will be created
waitRoomPlace = {x = 120, y = 53, z = 5} --Place of the waitnig room (the place ppl will wait for team to be full)
waitRoomDimensions = { --Enter the start pos[top left sqm] and end pos[bottom right sqm] of waitnig room here
startPos = {x = 114, y = 48, z = 5},
endPos = {x = 125, y = 57, z = 5}
}
eventPlaceDimensions = { --Enter the start pos[top left sqm] and end pos[bottom right sqm] of event place here
startPos = {x = 199, y = 37, z = 7},
endPos = {x = 250, y = 81, z = 7}
}
blueTeamPos = {x = 237, y = 66, z = 6}
redTeamPos = {x = 211, y = 50, z = 6}
--// General settings
recruitTime = 1 -- Time in minutes to gather players to event, will broadcast event started each min
minimumPlayersJoins = 2 --If the number of layer joined is less than that then event would be cancelled
balanceTeams = true -- This will balance number of players in both teams the extra player will be kicked out of event
removeTeleportOnEventEnd = true -- if you want to remove the tp when the event finish set it to true, normally tp will just be diabled
eventMaxTime = 5 -- Time in minutes, this is the max time event will be running. After checks are caried winner is declared
showEventSats = true -- This is like a timer that is always there about event stats (time,oponents left, teammates left). It appears in the cancel messages place.
sendLeftPlayers = true -- Well this will send to all alive players the names& numebr of the oponents left each interval defined down
intervalToSendLeftPlayers = 11 -- interval(in seconds) to sendLeftPlayers , must be more than 10 sec
countDownOnStart = true -- Well this occurs when players are teleported to their places in the arena , so if this is true it start to count down to the joined players then when count down finish they can start killing each other(event really begins)
countDownFrom = 10 -- Starts count down from this number when event start, if above is set true
minJoinLevel = 50 -- minimm lvl that can join event
rewards = { --Example [%] = { {itemid/name, count} ,..........} count isnt more than 100
[65] = { {6527,1} , {"6527",5} },
[25] = { {"Delaysia Coin",1} , {6527,10} },
[10] = { {"Delaysia Coin",1} , {"6527",15} }
}
--[[ Note : make sure if you edited % that sum should be equal to 100, you can add more % elements to suit your needs also more items if you want in each %
[65],[25],[10] -> is the % of this item to be found the rest is clear ,items in each % and it will be chosen randomly]]--
]]></config>
<lib name="teamFunctions"><![CDATA[
domodlib('teamSetting')
--[[Conditions don't touch]]--
local bmale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(bmale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(bmale, {lookType = math.random(128,134), lookHead = 88, lookBody = 88, lookLegs = 88, lookFeet = 88, lookTypeEx = 0, lookAddons = 3})
local bfemale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(bfemale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(bfemale, {lookType = math.random(136,142), lookHead = 88, lookBody = 88, lookLegs = 88, lookFeet = 88, 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 infight = createConditionObject(CONDITION_INFIGHT,-1)
--[[Local Config]]--
--[[Functions]]--
-- General info
function isFightOn()
return getStorage(eventStarted) > 0
end
function isRecruitOn()
return getStorage(eventRecruiting) > 0
end
function getMinJoinLevel()
return minJoinLevel
end
function getJoiners()
joiners = {}
for _,cid in ipairs(getPlayersOnline()) do
if isJoiner(cid) then
if isInRecruitArea(cid) or isInFightArea(cid) then
table.insert(joiners,cid)
end
end
end
return joiners
end
function getLeftMembersNames(team)
str = "Oponents left("..#team..") :"
left = ""
for k,cid in ipairs(team) do left = (left ..""..(k == 1 and "" or ", ")..""..getCreatureName(cid).."["..getPlayerLevel(cid).."]" ) end
str = str .." " .. (left == "" and "none" or left).. "."
return str
end
function disPlayEventStats()
if not showEventSats then return false end
if getStorage(eventTime) - os.time() <= 0 then return false end
left = os.date("%M:%S",(getStorage(eventTime) - os.time()))
for _,cid in ipairs(getJoiners()) do
oponentsLeft = isBlue(cid) and #getRedMembers() or #getBlueMembers()
teamMatesLeft = isBlue(cid) and math.max(0,#getBlueMembers()-1) or math.max(0,#getRedMembers()-1)
doPlayerSendCancel(cid,"Time left: ".. left.." || Oponents left: "..oponentsLeft.."/"..oponentCount(cid).." || Team-mates left: "..teamMatesLeft.."/".. math.max(0,matesCount(cid)-1))
end
end
function doSendLeftPlayers()
if not sendLeftPlayers then return false end
if intervalToSendLeftPlayers <= 10 then return false end
for _,cid in ipairs(getJoiners()) do
doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],getLeftMembersNames(isRed(cid) and getBlueMembers() or getRedMembers()))
end
end
function getBlueMembers()
members = {}
for _,cid in ipairs(getPlayersOnline()) do
if isBlue(cid) then
table.insert(members,cid)
end
end
return members
end
function getRedMembers()
members = {}
for _,cid in ipairs(getPlayersOnline()) do
if isRed(cid) then
table.insert(members,cid)
end
end
return members
end
-- starting fight
function startRecruiting()
doSetStorage(eventRecruiting,1)
end
function startEvent()
doSetStorage(eventRecruiting,-1)
if removeTeleportOnEventEnd then
tp = getTileItemById(teleporterPosition,1387).uid
if tp > 0 then doRemoveItem(tp) end
end
if not balanceTeams() then
resetEvent()
return false
end
for _,cid in ipairs(getBlueMembers()) do
doTeleportThing(cid,blueTeamPos,false)
doSendMagicEffect(getThingPos(cid),10)
end
setBlueCount(#getBlueMembers())
for _,cid in ipairs(getRedMembers()) do
doTeleportThing(cid,redTeamPos,false)
doSendMagicEffect(getThingPos(cid),10)
end
setRedCount(#getRedMembers())
startCountDown()
return true
end
function setBlueCount(count)
doSetStorage(blueCount,-1)
doSetStorage(blueCount,count)
end
function oponentCount(cid)
return isBlue(cid) and getStorage(redCount) or getStorage(blueCount)
end
function matesCount(cid)
return isBlue(cid) and getStorage(blueCount) or getStorage(redCount)
end
function setRedCount(count)
doSetStorage(redCount,-1)
doSetStorage(redCount,count)
end
function balanceTeams()
members = getJoiners()
if #members < minimumPlayersJoins then
doBroadcastMessage("Team-Battle event was cancelled as only ".. #members .. " players joined.")
return false
end
if (math.mod(#members,2) ~= 0) then
kicked = members[#members]
clearTeamEventStorages(kicked)
doPlayerSendTextMessage(kicked,MESSAGE_TYPES["info"],"Sorry, you have been kicked out of event for balancing both teams.")
end
count = 1
for _,cid in ipairs(getJoiners()) do
if (math.mod(count,2) ~= 0) then
addToBlue(cid)
else
addToRed(cid)
end
count = count + 1
end
return true
end
function startCountDown()
if(countDownOnStart) then
for _,cid in ipairs(getJoiners()) do
doCreatureSetNoMove(cid,true)
for i = 0,countDownFrom do
addEvent(doPlayerSendTextMessage,i*1000, cid, MESSAGE_TYPES["info"], (i == 0 and countDownFrom or countDownFrom-i) )
end
end
addEvent(startFight,(countDownFrom+1)*1000)
else
startFight()
end
end
function startFight()
doSetStorage(eventStarted,1)
for _,cid in ipairs(getJoiners()) do
doCreatureSetNoMove(cid,false)
doPlayerSendTextMessage(cid,MESSAGE_TYPES["warning"],"Fight Starts!")
end
addEvent(endTeamEvent,eventMaxTime*60*1000,"maxTime")
doSetStorage(eventTime,os.time()+eventMaxTime*60)
end
function teleportToWaitRoom(cid)
doTeleportThing(cid,waitRoomPlace)
doSendMagicEffect(waitRoomPlace,10)
if getPlayerGroupId(cid) < 4 then
addToJoiners(cid)
end
doPlayerSendTextMessage(cid,MESSAGE_TYPES["blue"],"Please be patient till the event starts and don't logout.")
return true
end