Ir para conteúdo
  • 0

[Mod] Editar Script


popohat7

Pergunta

Algem pode trocar esse sistema para começar com o npc ao invés de horario ?

 

Grato, Skydevil.

 

 

 

<?xml version="1.0" encoding="UTF-8"?>

<mod name="Team Event" version="2.0" author="Damadgerz" contact="support@lualand.net" enabled="yes">

<description>

Full auto Team BattleEvent(v2.0) for 0.3.6PL1 :

 

1- I currently rescripted this event from scratch again.

 

2- This version is much more better than the one before, it is more cleaner, clearer and with more options.

 

3- This version dislike the previous one , was tested on 0.3.6PL1 and works just fine.

 

4- Removed the npc part it is now based on tp creation.

 

5- More silent boradcasting for in event progress and no spam, I hope!

 

6- you now get the options to show event stats on cancel msg area and (to / not to) show left players with names each x interval.

 

8- Team balancer have been added to only balance count in both teams.

 

9- Added a countdown option before fight starts.

 

10- Now starts on a defined time every day

 

</description>

 

<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 = 159, y = 54, z = 7} --Place where the event tp will be created

 

waitRoomPlace = {x = 1114, y = 290, z = 7} --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 = 1110, y = 286, z = 7},

endPos = {x = 1119, y = 294, z = 7}

}

 

 

eventPlaceDimensions = { --Enter the start pos[top left sqm] and end pos[bottom right sqm] of event place here

startPos = {x = 1080, y = 275, z = 7},

endPos = {x = 1101, y = 289, z = 7}

}

blueTeamPos = {x = 1080, y = 281, z = 7}

redTeamPos = {x = 1101, y = 281, z = 7}

 

 

--// General settings

 

recruitTime = 3 -- 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 = false -- if you want to remove the tp when the event finish set it to true, normally tp will just be diabled

 

eventMaxTime = 10 -- 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 = 300 -- minimm lvl that can join event

 

rewards = { --Example [%] = { {itemid/name, count} ,..........} count isnt more than 100

 

[65] = { {2476,1} , {"gold coin",500} },

[25] = { {"golden armor",1} , {2152,90} },

[10] = { {"dragon scale mail",1} , {"crystal coin",10} }

}

 

--[[ 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

 

 

 

-- Modifing teams & checking member states

function isBlue(cid)

return (getPlayerStorageValue(cid,inBlue) > 0)

end

function isRed(cid)

return (getPlayerStorageValue(cid,inRed) > 0)

end

function isJoiner(cid)

return (getPlayerStorageValue(cid,joiner) > 0)

end

function addToBlue(cid)

setPlayerStorageValue(cid,inBlue,1)

doAddCondition(cid, (getPlayerSex(cid) == 1) and bmale or bfemale)

doAddCondition(cid,infight)

end

function addToRed(cid)

setPlayerStorageValue(cid,inRed,1)

doAddCondition(cid, (getPlayerSex(cid) == 1) and rmale or rfemale)

doAddCondition(cid,infight)

end

function addToJoiners(cid)

setPlayerStorageValue(cid,joiner,1)

end

function removeFromBlue(cid)

setPlayerStorageValue(cid,inBlue,-1)

end

function removeFromRed(cid)

setPlayerStorageValue(cid,inRed,-1)

end

function removeFromjoiners(cid)

setPlayerStorageValue(cid,joiner,-1)

end

function isInRecruitArea(cid)

return isInRange(getThingPos(cid),waitRoomDimensions.startPos,waitRoomDimensions.endPos)

end

function isInFightArea(cid)

return isInRange(getThingPos(cid),eventPlaceDimensions.startPos,eventPlaceDimensions.endPos)

end

function clearTeamEventStorages(cid)

if isInRecruitArea(cid) or isInFightArea(cid) then

doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))

doSendMagicEffect(getThingPos(cid),10)

end

 

if isFightOn() then

if isJoiner(cid) then

if isBlue(cid) then

addRedKills()

elseif isRed(cid) then

addBlueKills()

end

doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],"You have died in Team-Battle Event.")

end

end

 

removeFromjoiners(cid)

removeFromBlue(cid)

removeFromRed(cid)

doRemoveConditions(cid, false)

 

end

function haveUnrecivedReward(cid)

return getPlayerStorageValue(cid,itemToGet) > 0 and getPlayerStorageValue(cid,countItemToGet) > 0

end

function recieveLateReward(cid)

if haveUnrecivedReward(cid) then

if not doPlayerAddItem(cid,getPlayerStorageValue(cid,itemToGet),getPlayerStorageValue(cid,countItemToGet),false) then

msg = "You need to free some space then relog to take your reward."

doPlayerSendTextMessage(cid,MESSAGE_TYPES["warning"],msg)

else

setPlayerStorageValue(cid,itemToGet,-1)

setPlayerStorageValue(cid,countItemToGet,-1)

doPlayerSendTextMessage(cid,MESSAGE_TYPES["info"],"You have recieved your reward.")

end

end

end

 

-- Win or lose

function thereIsAWinner()

if redWon() or blueWon() then

return true

end

return false

end

function blueWon()

return( (#getBlueMembers() > 0 ) and ( #getRedMembers() == 0) )

end

function redWon()

return( (#getRedMembers() > 0) and (#getBlueMembers() == 0) )

end

function isDraw()

return #getBlueMembers() == #getRedMembers()

end

function getWinner()

if #getBlueMembers() > #getRedMembers() then

return {getBlueMembers(),getRedMembers(),"Blue team won."}

elseif #getRedMembers() > #getBlueMembers() then

return {getRedMembers(),getBlueMembers(),"Red team won."}

else

return { {},{},"it was a draw."}

end

end

 

 

-- Adding kills

function addBlueKills()

doSetStorage(blueKills, math.max(1,getStorage(blueKills)+1))

end

function addRedKills()

doSetStorage(redKills, math.max(1,getStorage(redKills)+1))

end

 

-- Ending event

 

function endTeamEvent(type)

if isFightOn() then

doSetStorage(eventStarted,-1)

doBroadcastMessage("Team-Battle event ended and "..getWinner()[3])

if not isDraw() then

win(getWinner()[1],type)

lose(getWinner()[2],type)

else

draw()

end

end

addEvent(resetEvent,2 * 1000) --- tp player to home remove all storages and reset event global storages

end

 

function getPercent()

rand= math.random(1,100)

prev = 0

chosenItem = 0

for k, v in pairs(rewards) do

if rand > prev and rand <= k+prev then

chosenItem = k

break

else

prev = k+prev

end

end

return chosenItem

end

 

function generateReward(cid)

percent = getPercent()

if percent == 0 then

print("Error in the reward item. Please inform Doggynub.")

return true

end

 

randomizer = rewards[percent][math.random(1,#rewards[percent])]

item = not tonumber(randomizer[1]) and getItemIdByName(randomizer[1]) or randomizer[1]

count = isItemStackable(item) and math.min(randomizer[2],100) or 1

if item == nil or item == 0 then

print("Error in the item format. Please inform Doggynub.")

return true

end

 

msg = "You have won ".. (count == 1 and "a" or count) .." " .. getItemNameById(item) .. "" .. (count == 1 and "" or "s").."."

 

if not doPlayerAddItem(cid,item,count,false) then

msg = msg.. "You need to free some space then relog to take your reward."

setPlayerStorageValue(cid,itemToGet,item)

setPlayerStorageValue(cid,countItemToGet,count)

end

 

doPlayerSendTextMessage(cid,MESSAGE_TYPES["white"],msg)

 

end

 

 

 

function generateStatsMessage(cid, type, stats)

msg = {

["KO"] = { ["win"] = "Event ended. Your team have won by killing all oponent's team members. You will recieve your reward shortly, check incoming messages.",

["lose"] = "Event ended. Your team have lost as the Oponent team killed all your team's members."

},

["maxTime"] = {

["win"] = "Event max-time finished and your team have won. You will recieve your reward shortly, check incoming messages.",

["lose"] = "Event max-time finished and your team have lost.",

["draw"] = "Event max-time finished and it is a draw.(no team won)"

}

}

doPlayerSendTextMessage(cid,MESSAGE_TYPES["info"],msg[type][stats])

 

end

function win(winners,type)

for _,cid in ipairs(winners) do

generateStatsMessage(cid, type, "win")

generateReward(cid)

end

end

function lose(losers,type)

for _,cid in ipairs(losers) do

generateStatsMessage(cid, type, "lose")

end

end

function draw()

for _,cid in ipairs(getJoiners()) do

generateStatsMessage(cid, "maxTime", "draw")

end

end

 

function resetEvent()

doSetStorage(eventRecruiting,-1)

doSetStorage(nextExecute,-1)

doSetStorage(eventStarted,-1)

doSetStorage(eventTime,-1)

doSetStorage(blueKills,-1)

doSetStorage(redKills,-1)

for _,cid in ipairs(getPlayersOnline()) do

if isBlue(cid) or isRed(cid) or isJoiner(cid) then

clearTeamEventStorages(cid)

end

end

end

 

 

]]></lib>

<event type="login" name="teambattleLogin" event="script"><![CDATA[

domodlib('teamFunctions')

 

function onLogin(cid)

clearTeamEventStorages(cid)

recieveLateReward(cid)

 

registerCreatureEvent(cid, "teamEventStats")

registerCreatureEvent(cid, "teambattleLogout")

registerCreatureEvent(cid, "teambattleCombat")

return true

end

]]></event>

<event type="combat" name="teambattleCombat" event="script"><![CDATA[

domodlib('teamFunctions')

 

function onCombat(cid, target)

if isFightOn() then

if isBlue(cid) and isBlue(target) then

return false

end

if isRed(cid) and isRed(target) then

return false

end

end

return true

end

 

]]></event>

<event type="logout" name="teambattleLogout" event="script"><![CDATA[

domodlib('teamFunctions')

 

function onLogout(cid)

clearTeamEventStorages(cid)

if thereIsAWinner() then

endTeamEvent("KO")

end

return true

end

 

]]></event>

<event type="statschange" name="teamEventStats" event="script"><![CDATA[

domodlib('teamFunctions')

 

corpse_ids = {

[0] = 3065, -- female

[1] = 3058 -- male

}

function onStatsChange(cid, attacker, type, combat, value)

if combat == COMBAT_HEALING then

return true

end

if getCreatureHealth(cid) > value then

return true

end

 

if isInFightArea(cid) and isFightOn() then

if isBlue(cid) or isRed(cid) then

corpse = doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid))

doCreateItem(2016, 2, getThingPos(cid))

clearTeamEventStorages(cid)

doItemSetAttribute(corpse, "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")..".n[Team-Event kill]")

doCreatureAddHealth(cid,getCreatureMaxHealth(cid))

if thereIsAWinner() then

endTeamEvent("KO")

end

 

return false

 

end

 

end

 

return true

end

]]></event>

 

<globalevent name = "teamBattleStart" time="18:45" event="script"><![CDATA[

domodlib('teamFunctions')

 

function onTimer()

resetEvent()

if getTileItemById(teleporterPosition,1387).uid < 1 then

tp = doCreateItem(1387,1,teleporterPosition)

doItemSetAttribute(tp, "aid", 9990)

end

 

startRecruiting()

for i = 0, recruitTime-1 do

addEvent(doBroadcastMessage, i * 60* 1000,"Team-Battle event is recruting players by entering event tp. Fight begins in "..(i == 0 and recruitTime or recruitTime-i).." minutes.",MESSAGE_TYPES["warning"])

end

 

addEvent(startEvent, recruitTime * 60 * 1000)

 

return true

end

 

 

]]></globalevent>

 

<globalevent name = "teamBattletime" interval="1" event="script"><![CDATA[

domodlib('teamFunctions')

 

function onThink()

if isFightOn() then

disPlayEventStats()

 

if getStorage(nextExecute) == -1 or getStorage(nextExecute) <= os.time() then

doSendLeftPlayers()

doSetStorage(nextExecute,os.time()+intervalToSendLeftPlayers)

end

end

return true

end

 

]]></globalevent>

<movevent type="StepIn" actionid="9990" event="script"><![CDATA[

domodlib('teamFunctions')

 

function onStepIn(cid, item, position, fromPosition)

if not isRecruitOn() then

doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],"Event isn't currently opened.")

doTeleportThing(cid,fromPosition)

doSendMagicEffect(fromPosition,2)

return true

end

if getPlayerLevel(cid) < getMinJoinLevel() then

doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],"Only players of level ".. getMinJoinLevel().. "+ can join this event.")

doTeleportThing(cid,fromPosition)

return true

end

teleportToWaitRoom(cid)

return true

end

 

 

]]> </movevent>

</mod>

 

 

 

Brigadão galera ó/

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Veja se este te ajuda:

 

NPC

 

Em data/npcs:

 

Eventer.xml

 

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Eventer" script="event.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="235" head="0" body="0" legs="0" feet="0" corpse="6348" addons="0"/>
	<parameters>
			<parameter key="message_greet" value="Ola |PLAYERNAME|. Para entrar na batalha diga {Battle} e para sair diga {leave}."/>
			<parameter key="message_farewell" value="Good bye."/>
			<parameter key="message_walkaway" value="Farewell then.." />
</parameters>

</npc>

 

 

 

Em data/npcs/scripts:

 

event.lua

 

 

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)			npcHandler:onCreatureSay(cid, type, msg) end
function onThink()					npcHandler:onThink() end

--[[start edit]]--  

	local mingroup = 4 --(updated) minimum group to reset the event
	local joined = 10000 ---must be like the storage in mod
	local maxPlayerEachTeam = 5 ---must be like max number in mod
	local team1Name = "Blue" ---must be like team number i mod
	local team2Name = "Red"
	local minlevel = 80 --(added) min lvl for a player to join.

			--[[storage like in the mod file]]--
	  local  running1 = 12000 --just add a non ussed storage
	  local running2 = 12001 --just add a non ussed storage
	  local sto = 12223 --just add a non ussed storage
	 --[[storage end]]--


--[[End of edit]]--
local function getBlue()
	return getGlobalStorageValue(9888)
end
local function removeBlue()
return setGlobalStorageValue(9888, getGlobalStorageValue(9888) - 1)
end
local function addBlue()
  return setGlobalStorageValue(9888, getGlobalStorageValue(9888) + 1)
end
local function resetBlue()
  return setGlobalStorageValue(9888,0)
end

local function getRed()
	return getGlobalStorageValue(9887)
end
local function removeRed()
return setGlobalStorageValue(9887, getGlobalStorageValue(9887) - 1)
end
local function addRed()
  return setGlobalStorageValue(9887, getGlobalStorageValue(9887) + 1)
end
local function resetRed()
  return setGlobalStorageValue(9887,0)
end
--[[script start]]--

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
	return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if getPlayerGroupId(cid) >= mingroup then
 npcHandler:say("Oh! Hail, senhor. Voce quer resetar o meu evento?", cid)
	 talkState[talkUser] = 1
  if msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
				 resetBlue()
			 resetRed()
					 setGlobalStorageValue(running1,-1)
			 setGlobalStorageValue(running2,-1)
			 setGlobalStorageValue(sto,-1)
					 npcHandler:say("Event was reseted, sire.", cid)
					 doBroadcastMessage("Eventer: Meu evento foi resetado por ordens do "..getCreatureName(cid)..". Para participar fale comigo outra vez,estou no meu castelo.")
			 for _,cid in ipairs(getPlayersOnline()) do
				if getPlayerStorageValue(cid, joined) > 0 then
					   setPlayerStorageValue(cid, joined,-1)  
						 doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
			 doSendMagicEffect(getCreaturePosition(cid), 10)
					 end
			 end
	  elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
		npcHandler:say("Como quiser, senhor.", cid)
		 talkState[talkUser] = 0
	 end
else
if msgcontains(msg, 'battle') then
		 if getGlobalStorageValue(running2) == 1 then	
		 npcHandler:say("Ja tem batalha em andamento,tente mais tarde.", cid)
	 elseif getPlayerLevel(cid) < minlevel then
			 npcHandler:say("Apenas level 100+ pode participar.",cid)
			 else
	 npcHandler:say("Voce esta preparado para a batalha? Por enquanto temos " .. getBlue() .. "/" .. maxPlayerEachTeam .. " players no {" .. team1Name .. "} team e " .. getRed() .. "/" .. maxPlayerEachTeam .. " players no {" .. team2Name .. "} team,vc quer escolher algum?", cid)
	 talkState[talkUser] = 1
		 end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
	if getPlayerStorageValue(cid, joined) ~= 1 and getPlayerStorageValue(cid, joined) ~= 2 then
		npcHandler:say("Vc quer ser do  {" .. team1Name .. "} team  ou {" .. team2Name .. "} team?", cid)
		talkState[talkUser] = 2
	else
		npcHandler:say("Vc esta recrutado!", cid)
		talkState[talkUser] = 0
	end
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
	npcHandler:say("Okay then.", cid)
	talkState[talkUser] = 0
elseif msgcontains(msg, team1Name) and talkState[talkUser] == 2 then
	if getBlue() ~= maxPlayerEachTeam then --fixed
		setPlayerStorageValue(cid, joined, 1)
	   addBlue()
		npcHandler:say("Vc entrou no " .. team1Name .. " team! Quando ambas equipes tiverem " .. maxPlayerEachTeam .. " os players serao teleportados para arena de batalha.", cid)

		talkState[talkUser] = 0
	else
		npcHandler:say("{" .. team1Name .. "} team esta cheio, entre no {" .. team2Name .. "} team ou espere alguem sair do {" .. team1Name .. "} team.", cid) --fixed
		talkState[talkUser] = 1
	end
elseif msgcontains(msg, team2Name) and talkState[talkUser] == 2 then
	if getRed() ~= maxPlayerEachTeam then --fixed
		setPlayerStorageValue(cid, joined, 2) --fixed
	   addRed()
		npcHandler:say("Vc esta no " .. team2Name .. " team! Quando ambas equipes tiverem " .. maxPlayerEachTeam .. " os players serao teleportados para arena de batalha.", cid)

		talkState[talkUser] = 0
	else
		npcHandler:say("{" .. team2Name .. "} team esta cheio, entre no {" .. team1Name .. "} team ou espere alguem sair do {" .. team2Name .. "} team.", cid)
		talkState[talkUser] = 1
	end
elseif msgcontains(msg, 'leave') then
	npcHandler:say("Vc quer sair da lista de espera para batalha?", cid)
	talkState[talkUser] = 3
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
	if getPlayerStorageValue(cid,joined) == 1 then
		setPlayerStorageValue(cid, joined, -1) -- fixed
	   removeBlue()
		npcHandler:say("Vc saiu da batalha.", cid)
		doBroadcastMessage("Event: " .. getPlayerName(cid) .. " saiu da batalha " .. team1Name .. " e " .. team2Name .. "!")
	elseif getPlayerStorageValue(cid,joined) == 2 then --fixed
				  setPlayerStorageValue(cid,joined,-1)
		  removeRed()
		  npcHandler:say("Vc saiu da batalha.", cid)
		 doBroadcastMessage("Event: " .. getPlayerName(cid) .. " saiu da batalha " .. team1Name .. " e " .. team2Name .. "!")
			else
		npcHandler:say("Vc nao esta recrutado!", cid)
	end
	talkState[talkUser] = 0 -- moved
end  
end	  
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

 

MODS

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<mod name="Team Event" version="1.0" author="Damadgerz" contact="support@lualand.net" enabled="yes">
<description>

  This is a full auto Team BattleEvent(missing part for site) :
		 1- Player will get the ability to talk to the npc event starter to start the event every x times(time between each event)
			 2- players will go to npc and say battle and then join their desired team(you adjust team names) , they also have ability to leave team
			 3- You have ability to set max players per each team, npc will not tp the players to arena except when both teams are full
			 4- Script automatically set the place of event to a pvp arena (players no lose items,levels,geet msg who killed them).Place cant be a non-pvp area.
			 5- if player logged out they will automatically be lifted out from event.
			 6- players in same team cant attack each others even with spells
			 7- each team will have a uniform 
			 8-you choose where the first team be tped and where the second team be tped
			 9-when event start, you set a max time for event.So if ppl couldnt kill each other( if players in first team = players in second team when event times finish) They will automatically be sent to temple and no one will take reward and broadcast 
			 10 -during event if max time didnt finish and player of team 1 killed all of those of team2 then players of team1 will be tped to temple broadcasting they won by killing all other members and will recieve a random reward taht you set
			 11 -Then the event will be on hold untill time between each event pass(you set that) , and when it pass a auto broadcast is made every minute to tell player that event is open.
  </description>

<config name="tutorial_m"><![CDATA[

running1 = 12000 --just add a non ussed storage
	running2 = 12001 --just add a non ussed storage
	joined = 10000 --just add a non ussed storage
	sto = 12223 --just add a non ussed storage
	check = 5454 -- empty storage
	redpotision = {x=1, y=1, z=7} --place where the red team player be teleported to
blueposition = {x=1, y=1, z=7} --place where the blue team player be teleported to
	stoptime = 20 --in minutes
	team1name = "Blue" --just put the name without <team>
	team2name = "Red"  
	timebetween = 120 -- time between each event  
	arena = { frompos = {x=15,y=15,z=7}, topos = {x=16,y=16,z=7} } ----Put you event area here
	conf = {
							rewards_id = {2160}, -- Rewards ID
							maxplayers = 5 ---maxplayers per team
					}
]]></config>
<lib name="football-lib"><![CDATA[

function getBlue()
	return getGlobalStorageValue(9888)
end
function removeBlue()
return setGlobalStorageValue(9888, getGlobalStorageValue(9888) - 1)
end
function addBlue()
  return setGlobalStorageValue(9888, getGlobalStorageValue(9888) + 1)
end
function resetBlue()
  return setGlobalStorageValue(9888,0)
end

function getRed()
	return getGlobalStorageValue(9887)
end
function removeRed()
return setGlobalStorageValue(9887, getGlobalStorageValue(9887) - 1)
end
function addRed()
  return setGlobalStorageValue(9887, getGlobalStorageValue(9887) + 1)
end
function resetRed()
  return setGlobalStorageValue(9887,0)
end
function onStop()
	if getGlobalStorageValue(running1) == 1 then
			setGlobalStorageValue(running1, -1)
			setGlobalStorageValue(sto,1)
	end
	return true
end
function onStopp()
	if getGlobalStorageValue(running2) > 0 then
			setGlobalStorageValue(running2,-1)
			doBroadcastMessage("Evento : o evento esta comecando de novo , va e fale com o Npc Eventer.")
	end
end

]]></lib>

<event type="login" name="Tutorial Login" event="script"><![CDATA[
domodlib('football-lib')
domodlib('tutorial_m')
function onLogin(cid)
	if getPlayerStorageValue(cid,check) > 0 then
			if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) then
					doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
					doSendMagicEffect(getCreaturePosition(cid), 10)
				setPlayerStorageValue(cid,check,-1)
			else
					setPlayerStorageValue(cid,check,-1)	
			end
	end
	registerCreatureEvent(cid, "Log")
	registerCreatureEvent(cid, "Arena")
	registerCreatureEvent(cid, "Attk")
	return true
end
]]></event>
<event type="combat" name="Attk" event="script"><![CDATA[
	domodlib('tutorial_m')
			domodlib('football-lib')
	function onCombat(cid, target)
	if getPlayerStorageValue(cid, joined) == 1 and getPlayerStorageValue(target, joined) == 1 then

			return false
	end
			if getPlayerStorageValue(cid, joined) == 2 and getPlayerStorageValue(target, joined) == 2 then

			return false
	end
	return true
end
]]></event>
<event type="logout" name="Log" event="script"><![CDATA[
domodlib('football-lib')
domodlib('tutorial_m')
function onLogout(cid)
 if getPlayerStorageValue(cid,joined) == 1 then
doBroadcastMessage(""..getPlayerName(cid).." saiu do War-Event")
setPlayerStorageValue(cid,joined,-1)
	setPlayerStorageValue(cid,check,1)
	removeBlue()
  return true
  end
  if getPlayerStorageValue(cid,joined) == 2 then
doBroadcastMessage(""..getPlayerName(cid).." saiu do War-Event")
  setPlayerStorageValue(cid,check,1)
	removeRed()
  return true
  end
  return true
 end

]]></event>
<event type="statschange" name="Arena" event="script"><![CDATA[
domodlib('football-lib')
domodlib('tutorial_m')
local corpse_ids = {
	[0] = 3065, -- female
	[1] = 3058 -- male
}
function onStatsChange(cid, attacker, type, combat, value)
	if combat == COMBAT_HEALING then
					return true
	end
	if getCreatureHealth(cid) > value then
					return true
	end
	if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) 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")..".\n[War-Event kill]")  
			doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
			doSendMagicEffect(getCreaturePosition(cid), 10)
			doRemoveConditions(cid, FALSE)
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
			doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item").." in the war event.")
					if isPlayer(attacker) then
									doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You killed "..getCreatureName(cid).." in the war event.")
					end
					if getPlayerStorageValue(cid,joined) == 1 then
							removeBlue()
							setPlayerStorageValue(cid,10000,-1)
					elseif getPlayerStorageValue(cid,joined) == 2 then
							removeRed()
							setPlayerStorageValue(cid,10000,-1)
					end
	end
	return true
end

]]></event>
<globalevent name="reset" type="start" event="script"><![CDATA[
domodlib('football-lib')
domodlib('tutorial_m')
 function onStartup()
		 resetBlue()
	  resetRed()
				setGlobalStorageValue(running1,-1)
 setGlobalStorageValue(running2,-1)
  setGlobalStorageValue(sto,-1)

	return true
end
]]></globalevent>
 <globalevent name="TeamBattle" interval="7" event="script"><![CDATA[
			domodlib('football-lib')
	domodlib('tutorial_m')



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})

function onThink(interval, lastExecution)
	local random_item = conf.rewards_id[math.random(1, #conf.rewards_id)]
	if (getBlue() == conf.maxplayers and getRed() == conf.maxplayers) then  
			if (getGlobalStorageValue(running1) == -1 and getGlobalStorageValue(sto) == -1) then
					setGlobalStorageValue(running1,1)
					doBroadcastMessage("O Evento da Batalha dos Times comecou! E ele acabara em "..stoptime.." minutes, a menos que um dos times mate todos seus oponentes.")
					addEvent(onStop, stoptime * 60 * 1000)
							for _, cid in ipairs(getPlayersOnline()) do

		 if getPlayerStorageValue(cid, joined) == 1 then  
				 if getPlayerSex(cid) == 1 then
					doAddCondition(cid, bmale)
			elseif getPlayerSex(cid) ~= 1 then
					doAddCondition(cid, bfemale)
			end
			   doTeleportThing(cid, blueposition, FALSE)
		doSendMagicEffect(blueposition, 10)
			 elseif getPlayerStorageValue(cid, joined) == 2 then  
				   if getPlayerSex(cid) == 1 then
			 doAddCondition(cid, rmale)
		   elseif getPlayerSex(cid) ~= 1 then
			  doAddCondition(cid, rfemale)
		   end
			   doTeleportThing(cid, redpotision, FALSE)
		doSendMagicEffect(redpotision, 10)
			 end
			end
  end
	end
	if getGlobalStorageValue(running1) == 1 then
			setGlobalStorageValue(running2,1)
			if (getBlue() >= 1 and getRed() < 1) then
					addEvent(onStopp, timebetween * 60 * 1000)
					doBroadcastMessage("O War-Event acabou porque o " ..team1name.. " team matou todos os players do seu time oponente,eles receberao sua recompensa.O Evento sera reaberto em ".. timebetween .." minutos")
			elseif (getBlue() < 1 and getRed() >= 1) then
					doBroadcastMessage("O War-Event acabou porque o " ..team2name.. "  team matou todos os players do seu time oponente,eles receberao sua recompensa.O Evento sera reaberto em ".. timebetween .." minutos")
					addEvent(onStopp, timebetween * 60 * 1000)
			end
	for _, cid in ipairs(getPlayersOnline()) do
					if (getBlue() >= 1 and getRed() < 1) then
							if getPlayerStorageValue(cid,joined) == 1 then
									doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
									doSendMagicEffect(getCreaturePosition(cid), 10)
									doRemoveConditions(cid, FALSE)
									doPlayerAddItem(cid, random_item, 1)
									doRemoveConditions(cid, FALSE)
									doCreatureSay(cid, "Voce ganhou um "..getItemNameById(random_item).." como recompensa do war-event", TALKTYPE_ORANGE_1)
									setPlayerStorageValue(cid, joined,-1)
									setGlobalStorageValue(running1,-1)
									resetBlue()
							end
					end
					if (getBlue() < 1 and getRed() >= 1) then
							if getPlayerStorageValue(cid,joined) == 2 then
									doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
									doRemoveConditions(cid, FALSE)
									doSendMagicEffect(getCreaturePosition(cid), 10)
									doRemoveConditions(cid, FALSE)
									doPlayerAddItem(cid, random_item, 1)
									doCreatureSay(cid, "Voce ganhou um "..getItemNameById(random_item).." como recompensa do war-event", TALKTYPE_ORANGE_1)
									setGlobalStorageValue(running1,-1)
									setPlayerStorageValue(cid, joined,-1)
									resetRed()
							end
					end
			end
	end

	return true
end
]]></globalevent>
<globalevent name="Team" interval="3" event="script"><![CDATA[
domodlib('football-lib')
domodlib('tutorial_m')

function onThink(interval, lastExecution)

local random_item = conf.rewards_id[math.random(1, #conf.rewards_id)]
	if getGlobalStorageValue(sto) == 1 then
			if (getRed() > getBlue()) then
					doBroadcastMessage("O War-Event acabou porque o " ..team2name.. "  team matou todos os players do time oponente,eles receberao sua recompensa..O Evento sera reaberto em ".. timebetween .." minutos")
							for _, cid in ipairs(getPlayersOnline()) do
									if getPlayerStorageValue(cid,joined) == 2 then
											doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
											doSendMagicEffect(getCreaturePosition(cid), 10)
											doRemoveConditions(cid, FALSE)
											doPlayerAddItem(cid, random_item, 1)
											doRemoveConditions(cid, FALSE)
											doCreatureSay(cid, "Voce ganhou um "..getItemNameById(random_item).." como recompensa do war-event", TALKTYPE_ORANGE_1)
											setPlayerStorageValue(cid, joined,-1)
									end	
									if getPlayerStorageValue(cid,joined) == 1 then
											doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
											doSendMagicEffect(getCreaturePosition(cid), 10)
											doPlayerSendTextMessage(cid,24, "Seu time perdeu a guerra no war-event")
											setPlayerStorageValue(cid, joined,-1)
											doRemoveConditions(cid, FALSE)
									end									  
							end
							addEvent(onStopp, timebetween * 60 * 1000)
			end
			if (getRed() < getBlue()) then
					doBroadcastMessage("O War-Event acabou porque o " ..team1name.. "  team matou todos os players do time oponente,eles receberao sua recompensa.O Evento sera reaberto em ".. timebetween .." minutos")
							for _, cid in ipairs(getPlayersOnline()) do
									if getPlayerStorageValue(cid,joined) == 1 then
											doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
											doSendMagicEffect(getCreaturePosition(cid), 10)
											doPlayerAddItem(cid, random_item, 1)
											doRemoveConditions(cid, FALSE)
											doRemoveConditions(cid, FALSE)
											doCreatureSay(cid, "Voce ganhou um "..getItemNameById(random_item).." como recompensa do war-event", TALKTYPE_ORANGE_1)
											setPlayerStorageValue(cid, joined,-1)
									end	
									if getPlayerStorageValue(cid,joined) == 2 then
											doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
											doRemoveConditions(cid, FALSE)
											doSendMagicEffect(getCreaturePosition(cid), 10)
											doPlayerSendTextMessage(cid,24, "Seu time perdeu a guerra no war-event")
											setPlayerStorageValue(cid, joined,-1)
									end									  
							end
							addEvent(onStopp, timebetween * 60 * 1000)
			end
			if (getRed() == getBlue()) then
					for _, cid in ipairs(getPlayersOnline()) do
							if getPlayerStorageValue(cid,joined) == 2 or getPlayerStorageValue(cid,joined) == 1 then  
									doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
									doRemoveConditions(cid, FALSE)
									doSendMagicEffect(getCreaturePosition(cid), 10)
									doRemoveConditions(cid, FALSE)
				setPlayerStorageValue(cid, joined,-1)
									doBroadcastMessage("Tempo do evento acabado.E nenhum dos times venceu o evento.O Evento sera reaberto em ".. timebetween .." minutos")
							end						
					end
					addEvent(onStopp, timebetween * 60 * 1000)
			end
			resetBlue()
			resetRed()
			setGlobalStorageValue(sto, -1)
	end
	return true
end
]]></globalevent>
	<globalevent name="Broad" interval="240" event="script"><![CDATA[
			domodlib('football-lib')
			domodlib('tutorial_m')

function onThink(interval, lastExecution)
 if getGlobalStorageValue(running2) == -1 then
doBroadcastMessage("[War Eventer Aberto] O Npc precisa de 5 players em cada time.Ja tem no Blue "..getBlue().." players  vs Red "..getRed().." players.")
	return true
	end
return true
end
]]></globalevent>
	<globalevent name="Karim" interval="40000" event="script"><![CDATA[
			domodlib('football-lib')
			domodlib('tutorial_m')

function onThink(interval, lastExecution)
	if getGlobalStorageValue(running1) > 0 then
			local blue = {}
			local green = {}
			for _, pid in ipairs(getPlayersOnline()) do
					if isInRange(getCreaturePosition(pid),arena.frompos, arena.topos) then
							if getPlayerStorageValue(pid, joined) == 1 then  
									table.insert(blue,getCreatureName(pid))
							elseif getPlayerStorageValue(pid, joined) == 2 then  
									table.insert(green,getCreatureName(pid))
							end
					end
			end
			local greenn = table.concat(green,', ')
			local bluee = table.concat(blue,', ')
			for _, tid in ipairs(getPlayersOnline()) do
					if getPlayerStorageValue(tid, joined) > 0 then
							doPlayerSendTextMessage(tid,19,'<<!-- Players left --!>>\n '..team1name..' team ('..#blue..') : '..bluee..'.\n '..team2name..' team ('..#green..') : '..greenn..'.')
					end
			end
	end
	return true
end
]]></globalevent>
</mod>

 

 

Editado por Leoxtibia
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...