iSanto
Demetri-World.net
- Joined
- Jan 8, 2011
- Messages
- 922
- Reaction score
- 87
Skrypt by? pisany dla revana.pl, ale Vxr przerobi? mnie na pieni?dze, wi?c nic nie stoi mi na przeszkodzie aby udost?pni? wam ten skrypt. Z dedykacj? dla Vxr'a.
Opis dzia?ania:
PVP Enfo Event to event kt?ry zapisanych graczy, (gracze zapisuj? si? poprzez komend? !enfoevent) przenosi na specjaln? arene do walk. Gracze mog? bezkarnie zabija? si?, nie ?api?c przy tym fraga. Je?eli zabijemy kogo?, ta osoba trafia w miejsce odrodzenia(nie traci bp, skilla) i ponownie mo?e walczy?. Zab?jca za? dostaje +1 Evo Event Frag. Po sko?czeniu eventu, najlepszy zab?jca (najwi?cej Pvp Enfo Frags), dostaj? nagrod?. Event z szerok? configuracj?. Aktywuje si? o wyznaczonej godzinie ustalonej w globalevent.xml.
W trakcie zapis?w, GM+ mo?e zobaczy? ile aktualnie zapisa?o si? uczestnik?w poprzez komend? !enfoevent info
Skrypt:
W data>creaturescripts>creaturescripts.xml dodajemy:
[xml] <event type="preparedeath" name="PVP_ENFO_EVENT_DIE" event="script" value="PVP_ENFO_EVENT_DIE.lua"/>
<event type="login" name="PVP_ENFO_EVENT_DIE_LOGIN" event="script" value="PVP_ENFO_EVENT_DIE.lua"/>[/xml]
data>creaturescripts>scripts tworzymy plik o nazwie: PVP_ENFO_EVENT_DIE.lua i wklejamy:
[lua]local config = {
placeAfterDie = {{x=677, y=922, z=7}, {x=690, y=935, z=7}},
placeAfterDieIfNotSuccessfullFirst = {{x=677, y=922, z=7}}
}
local storages = {
["Globals"] = {default = 74531, notification = 74532},
["Creatures"] = {skull_type = 74529, participant = 74530, frags = 74531}
}
function onLogin(cid)
if getStorage(storages["Globals"].participant) == "pvpEvent" then
doCreatureSetStorage(cid, storages["Globals"].participant, -1)
end
registerCreatureEvent(cid, "PVP_ENFO_EVENT_DIE")
return true
end
function onPrepareDeath(cid, deathList)
if getStorage(storages["Globals"].default) == 1 then
if getCreatureStorage(cid, storages["Creatures"].participant) == "pvpEventStart" then
local health, mana = getCreatureMaxHealth(cid), getCreatureMaxMana(cid)
local toPos_Player = {x=math.random(config.placeAfterDie[1].x, config.placeAfterDie[2].x), y=math.random(config.placeAfterDie[1].y, config.placeAfterDie[2].y), z=math.random(config.placeAfterDie[1].z, config.placeAfterDie[2].z)}
if doTileQueryAdd(cid, toPos_Player, 48) == 1 then
doTeleportThing(cid, toPos_Player)
else
doTeleportThing(cid, config.placeAfterDieIfNotSuccessfullFirst)
end
doCreatureAddHealth(cid, health, 0, 0, true)
doCreatureAddMana(cid, mana)
for k, v in pairs(deathList) do
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You were killed by: "..getCreatureName(v))
if isPlayer(v) then
doCreatureSetStorage(v, storages["Creatures"].frags, getCreatureStorage(v, storages["Creatures"].frags)+1)
doPlayerSendTextMessage(v, MESSAGE_STATUS_CONSOLE_BLUE, "+1 Enfo Event Frag for the murder of "..getCreatureName(cid)..".\n Total frags: "..getCreatureStorage(v, storages["Creatures"].frags))
end
end
return false
end
end
return true
end[/lua]
W data>globalevents>globalevents.xml wklejamy:
[xml]<globalevent name="PVP_ENFO_EVENT" time="12:00:00" event="script" value="PVP_ENFO_EVENT.lua"/>[/xml]
W data>globalevents>scripts tworzymy plik o nazwie: PVP_ENFO_EVENT.lua i wklejamy:
[lua]local config = {
whenStartEventBeforInformation = 5.0,
howLongEventHaveToLast = 20.0,
startEventPosition = {{x=665, y=920, z=7},{x=699, y=943, z=7}},
positionIfNotPosibleFirstTeleport = {x=665, y=920, z=7}, --pozycja, je?eli nie jest mo?liwa teleportacja na wybranym polu wyzej
award = { [1] = {item = 8983}, -- [Zaj?teMiejsce] = {item = idNagrody} To jest dla pierwszego miejsca
[2] = {item = 2400},
[3] = {item = 2160},
[4] = {item = 2409},
[5] = {item = 2405}
},
howManyPlayersToStartEvent = 20,
howManyPlayersGetsAward = 5 --ilosc osob ktore dostana nagrod? (musi si? zgadzac z powy?sz? tabelk? z nagrodami - 5 miejsc - 5 nagr?d)
}
local storages = {
["Globals"] = {default = 74531, notification = 74532},
["Creatures"] = {skull_type = 74529, participant = 74530, frags = 74531}
}
local tbl = {}
function showInformationAboutEvent(whenEventStartBeforINF)
local function second()
a=whenEventStartBeforINF-1
doBroadcastMessage("PVP Enfo Event is starting up! If you want take part, write !enfoevent . Be quick, only 50 players can participate. Anybody can report its part only for "..a.." minutes.", MESSAGE_EVENT_ADVANCE)
doBroadcastMessage("PVP Enfo Event rozpoczyna sie! Je?eli chcesz wziac udzial, napisz !enfoevent . Badz szybki, tylko 50 graczy moze uczestniczyc. Kazdy moze zglosic swoj udzial tylko przez "..a.." minut.", MESSAGE_EVENT_ADVANCE)
end
a=0
if whenEventStartBeforINF <= 1 then
doBroadcastMessage("PVP Enfo Event is starting up! If you want take part, write !enfoevent . Be quick, only 50 players can participate. Anybody can report its part only for "..config.whenStartEventBeforInformation.." minutes.", MESSAGE_EVENT_ADVANCE)
doBroadcastMessage("PVP Enfo Event rozpoczyna sie! Je?eli chcesz wziac udzial, napisz !enfoevent . Badz szybki, tylko 50 graczy moze uczestniczyc. Kazdy moze zglosic swoj udzial tylko przez "..config.whenStartEventBeforInformation.." minut.", MESSAGE_EVENT_ADVANCE)
return true
end
doBroadcastMessage("PVP Enfo Event is starting up! If you want take part, write !enfoevent . Be quick, only 50 players can participate. Anybody can report its part only for "..config.whenStartEventBeforInformation.." minutes.", MESSAGE_EVENT_ADVANCE)
for i = 1, whenEventStartBeforINF-1 do
addEvent(second, i* (1000*60))
end
return true
end
function checkMinimumNumberOfPlayers(number)
needPlayers = 0
for k, v in pairs(getOnlinePlayers()) do
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEvent" then
needPlayers=needPlayers+1
end
end
if needPlayers >= number then
return true
end
for k, v in pairs(getOnlinePlayers()) do
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEvent" then
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].participant, -1)
end
end
return false
end
function spairs(t, order)
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
if order then
table.sort(keys, function(a,b) return order(t, a, b) end)
else
table.sort(keys)
end
local i = 0
return function()
i = i + 1
if keys then
return keys, t[keys]
end
end
end
function startEvent()
local players_table = {}
a=1
if not checkMinimumNumberOfPlayers( config.howManyPlayersToStartEvent) then
doBroadcastMessage("PVP Enfo Event will not be started due to lack of adequate entered number of players.", MESSAGE_EVENT_ADVANCE)
doSetStorage(storages["Globals"].default, -1)
stopEvent(finish)
return true
end
for k, v in pairs(getOnlinePlayers()) do
if isPlayer(getPlayerByName(v)) then
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEvent" then
players_table[a] = {name = getPlayerByName(v)}
a=a+1
local creatureSkull = getCreatureSkullType(getPlayerByName(v))
if creatureSkull == SKULL_WHITE then
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].skull_type, creatureSkull)
end
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].frags) == -1 then doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].frags, 0) end
local toPos_Player = {x=math.random(config.startEventPosition[1].x, config.startEventPosition[2].x), y=math.random(config.startEventPosition[1].y, config.startEventPosition[2].y), z=math.random(config.startEventPosition[1].z, config.startEventPosition[2].z)}
if doTileQueryAdd(getPlayerByName(v), toPos_Player, 48) == 1 then
doTeleportThing(getPlayerByName(v), toPos_Player)
else
doTeleportThing(getPlayerByName(v), config.positionIfNotPosibleFirstTeleport)
end
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].participant, "pvpEventStart")
end
end
end
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerAccess(pid) > 3 then
doPlayerPopupFYI(pid, "Ilosc uczestnikow w PVP ENFO EVENT: "..a-1 ..".\nCzas trwania eventu: "..config.howLongEventHaveToLast..".\n")
end
end
doBroadcastMessage("PVP Enfo Event is starting up!", MESSAGE_EVENT_ADVANCE)
doSetStorage(storages["Globals"].default, 1)
return true
end
function endEvent()
doBroadcastMessage("PVP Enfo Event has been completed.", MESSAGE_EVENT_ADVANCE)
doSetStorage(storages["Globals"].default, -1)
for k, v in pairs(getOnlinePlayers()) do
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEventStart" then
local creature_skull_type = getCreatureStorage(getPlayerByName(v), storages["Creatures"].skull_type)
if creature_skull_type ~= -1 then
doCreatureSetSkullType(getPlayerByName(v), creature_skull_type)
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].skull_type, -1)
doPlayerSendTextMessage(getPlayerByName(v), MESSAGE_STATUS_CONSOLE_BLUE, "Before the start of the event, had a white skull.")
end
local town_position = getTownTemplePosition(getPlayerTown(getPlayerByName(v)))
doTeleportThing(getPlayerByName(v), town_position)
doCreatureSetSkullType(getPlayerByName(v), 0)
doPlayerSetPzLocked(getPlayerByName(v), false)
tbl[v] = getCreatureStorage(getPlayerByName(v), storages["Creatures"].frags)
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].frags, 0)
end
end
ss = ""
a=0
for k,v in spairs(tbl, function(t,a,b) return t < t[a] end) do
if a ~= config.howManyPlayersGetsAward then
a=a+1
doPlayerPopupFYI(getPlayerByName(k), "Congratulation!\nYou took "..a.." place in PVP ENFO EVENT and you won:\n "..getItemNameById(config.award[a].item).."!")
doPlayerAddItem(getPlayerByName(k), config.award[a].item)
doPlayerSendTextMessage(getPlayerByName(k), MESSAGE_EVENT_DEFAULT, "You get "..getItemNameById(config.award[a].item).." for "..a..". place in PVP ENFO EVENT.")
ss = ss.."Name: "..k.." Frags: ["..v.."]\n "
end
end
for _, v in pairs(getOnlinePlayers()) do
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEventStart" then
doPlayerPopupFYI(getPlayerByName(v), ss)
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].participant, -1)
end
end
return true
end
function onTime()
showInformationAboutEvent(config.whenStartEventBeforInformation)
doSetStorage(storages["Globals"].default, 0)
doSetStorage(storages["Globals"].notification, 0)
addEvent(startEvent, config.whenStartEventBeforInformation*1000*60)
finish = addEvent(endEvent, (config.whenStartEventBeforInformation*1000*60)+(config.howLongEventHaveToLast*1000*60))
return true
end[/lua]
W data>talkactions>talkactions.xml wklejamy:
[xml]<talkaction words="!enfoevent" event="script" value="ENFOEVENT.lua"/>[/xml]
W data>talkactions>scripts tworzymy plik o nazwie: ENFOEVENT.lua i wklejamy:
[lua]local smallCFG = {
maxPlayersInEvent = 60, --maksymalna ilosc osob w evencie
storage = 193781,
seconds = 1*60
}
function isEvent(nonEventText)
if getStorage(74531) ~= 0 then
return nonEventText
end
return getStorage(74532)
end
function onSay(cid, words, param, channel)
local tile = string.explode(param, ",")
if exhaustion.get(cid, smallCFG.storage) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You cant use this command twice.")
return true
end
if tile[1] == "info" and getPlayerAccess(cid) > 3 then
doPlayerPopupFYI(cid, "Aktualna ilosc zapisanych uczestnikow w PVP ENFO EVENT: "..isEvent("Event is disabled").."/"..smallCFG.maxPlayersInEvent..".\n")
return true
end
if getStorage(74531) ~= 0 then
doPlayerSendCancel(cid, "At this time, an event is disabled.")
return true
end
if getStorage(74532) > smallCFG.maxPlayersInEvent then
doPlayerSendCancel(cid, "Sorry, there are no more rooms available for this event.")
return true
end
if getCreatureStorage(cid, 74530) == "pvpEvent" then
doPlayerSendCancel(cid, "You are already subscribed to this event.")
doSendMagicEffect(getCreaturePosition(cid), 2)
return true
end
exhaustion.set(cid, smallCFG.storage, smallCFG.seconds)
doSetStorage(74532, getStorage(74532)+1)
doCreatureSetStorage(cid, 74530, "pvpEvent")
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Yours application has been accepted.")
return true
end[/lua]
Wyja?nienie configu:
W pliku znajduj?cym si? w creaturescripts:
[LUA]placeAfterDie = {{x=677, y=922, z=7}, {x=690, y=935, z=7}},
--[[
Miejsce w kt?rym zrespimy si? po ?mierci. (Randomowe miejsce zawieraj?ce si? w prostok?cie)
Pierwsza pozycja to lewy g?rny r?g prostok?ta, druga prawy dolny r?g.
--]]
placeAfterDieIfNotSuccessfullFirst = {{x=677, y=922, z=7}}
--[[
Miejsce w kt?rym zrespimy si? po ?mierci, je?eli na powy?szej pozycji nie jest to mo?liwe (np. je?eli akurat b?dzie woda na pozycji na g?rze)
]]--[/LUA]
GlobalEvent:
[lua]whenStartEventBeforInformation = 5.0,
--[[
Po ilu minutach rozpocznie sie event od pokazania informacji, o mo?liwo?ci do??czenia do eventu.
]]--
howLongEventHaveToLast = 20.0,
--[[
Ile minut ma trwa? event.
]]--
startEventPosition = {{x=665, y=920, z=7},{x=699, y=943, z=7}},
--[[
W jakie miejsce ma przeteleportowa? graczy przy stacie eventu (r?wnie? prostok?t z kt?rego s? wybrane randowmowe miejsca)
]]--
positionIfNotPosibleFirstTeleport = {x=665, y=920, z=7},
--[[
Pozycja na kt?r? zostanie przeteleportowany gracz, je?eli nie jest mo?liwa teleportacja na wybranym polu wyzej.
]]--
award = { [1] = {item = 8983}, -- [Zaj?teMiejsce] = {item = idNagrody} To jest dla pierwszego miejsca
[2] = {item = 2400},
[3] = {item = 2160},
[4] = {item = 2409},
[5] = {item = 2405}
},
--[[
Nagroda dla graczy, kt?rzy zajeli miejsca (u mnie dostanie nagrod? 5 os?b, ale mo?na dowolnie modyfikowa?) oraz id itema jaki gracz dostanie za jego miejsce.
]]--
howManyPlayersToStartEvent = 20,
--[[
Ile wymaganych zapisanych graczy, aby event rozpocz?? si? (je?eli nie zapisze si? wymagana ilo?? graczy event nie rozpocznie si?)
]]--
howManyPlayersGetsAward = 5 --ilosc osob ktore dostana nagrod?
--[[
Ile os?b dostanie nagrod? (musi si? zgadzac z powy?sz? tabelk? z nagrodami - 5 miejsc - 5 nagr?d)
]]--[/lua]
Talkactions:
[lua]maxPlayersInEvent = 60,
--[[
Ile maksymalnie moze zapisa? si? os?b.
]]--
storage = 193781,
--[[
Exhasted storage, je?eli inny skrypt nie wykorzystuje to ID, lepiej nie rusza?.
]]--
seconds = 1*60
--[[
Ile sekund exhasted ma by? na wpisywanie !pvpevent, zabezpieczenia przed bezsensownym spammem.
]]--
[/lua]
[xml]<globalevent name="PVP_ENFO_EVENT" time="12:00:00" event="script" value="PVP_ENFO_EVENT.lua"/>[/xml]
Tutaj za? ustalamy o kt?rej godzinie ma si? w??czy? event. (time="12:00:00")
Zabraniam kopiowania na inne fora bez mojej zgody!
Opis dzia?ania:
PVP Enfo Event to event kt?ry zapisanych graczy, (gracze zapisuj? si? poprzez komend? !enfoevent) przenosi na specjaln? arene do walk. Gracze mog? bezkarnie zabija? si?, nie ?api?c przy tym fraga. Je?eli zabijemy kogo?, ta osoba trafia w miejsce odrodzenia(nie traci bp, skilla) i ponownie mo?e walczy?. Zab?jca za? dostaje +1 Evo Event Frag. Po sko?czeniu eventu, najlepszy zab?jca (najwi?cej Pvp Enfo Frags), dostaj? nagrod?. Event z szerok? configuracj?. Aktywuje si? o wyznaczonej godzinie ustalonej w globalevent.xml.
W trakcie zapis?w, GM+ mo?e zobaczy? ile aktualnie zapisa?o si? uczestnik?w poprzez komend? !enfoevent info
Skrypt:
W data>creaturescripts>creaturescripts.xml dodajemy:
[xml] <event type="preparedeath" name="PVP_ENFO_EVENT_DIE" event="script" value="PVP_ENFO_EVENT_DIE.lua"/>
<event type="login" name="PVP_ENFO_EVENT_DIE_LOGIN" event="script" value="PVP_ENFO_EVENT_DIE.lua"/>[/xml]
data>creaturescripts>scripts tworzymy plik o nazwie: PVP_ENFO_EVENT_DIE.lua i wklejamy:
[lua]local config = {
placeAfterDie = {{x=677, y=922, z=7}, {x=690, y=935, z=7}},
placeAfterDieIfNotSuccessfullFirst = {{x=677, y=922, z=7}}
}
local storages = {
["Globals"] = {default = 74531, notification = 74532},
["Creatures"] = {skull_type = 74529, participant = 74530, frags = 74531}
}
function onLogin(cid)
if getStorage(storages["Globals"].participant) == "pvpEvent" then
doCreatureSetStorage(cid, storages["Globals"].participant, -1)
end
registerCreatureEvent(cid, "PVP_ENFO_EVENT_DIE")
return true
end
function onPrepareDeath(cid, deathList)
if getStorage(storages["Globals"].default) == 1 then
if getCreatureStorage(cid, storages["Creatures"].participant) == "pvpEventStart" then
local health, mana = getCreatureMaxHealth(cid), getCreatureMaxMana(cid)
local toPos_Player = {x=math.random(config.placeAfterDie[1].x, config.placeAfterDie[2].x), y=math.random(config.placeAfterDie[1].y, config.placeAfterDie[2].y), z=math.random(config.placeAfterDie[1].z, config.placeAfterDie[2].z)}
if doTileQueryAdd(cid, toPos_Player, 48) == 1 then
doTeleportThing(cid, toPos_Player)
else
doTeleportThing(cid, config.placeAfterDieIfNotSuccessfullFirst)
end
doCreatureAddHealth(cid, health, 0, 0, true)
doCreatureAddMana(cid, mana)
for k, v in pairs(deathList) do
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You were killed by: "..getCreatureName(v))
if isPlayer(v) then
doCreatureSetStorage(v, storages["Creatures"].frags, getCreatureStorage(v, storages["Creatures"].frags)+1)
doPlayerSendTextMessage(v, MESSAGE_STATUS_CONSOLE_BLUE, "+1 Enfo Event Frag for the murder of "..getCreatureName(cid)..".\n Total frags: "..getCreatureStorage(v, storages["Creatures"].frags))
end
end
return false
end
end
return true
end[/lua]
W data>globalevents>globalevents.xml wklejamy:
[xml]<globalevent name="PVP_ENFO_EVENT" time="12:00:00" event="script" value="PVP_ENFO_EVENT.lua"/>[/xml]
W data>globalevents>scripts tworzymy plik o nazwie: PVP_ENFO_EVENT.lua i wklejamy:
[lua]local config = {
whenStartEventBeforInformation = 5.0,
howLongEventHaveToLast = 20.0,
startEventPosition = {{x=665, y=920, z=7},{x=699, y=943, z=7}},
positionIfNotPosibleFirstTeleport = {x=665, y=920, z=7}, --pozycja, je?eli nie jest mo?liwa teleportacja na wybranym polu wyzej
award = { [1] = {item = 8983}, -- [Zaj?teMiejsce] = {item = idNagrody} To jest dla pierwszego miejsca
[2] = {item = 2400},
[3] = {item = 2160},
[4] = {item = 2409},
[5] = {item = 2405}
},
howManyPlayersToStartEvent = 20,
howManyPlayersGetsAward = 5 --ilosc osob ktore dostana nagrod? (musi si? zgadzac z powy?sz? tabelk? z nagrodami - 5 miejsc - 5 nagr?d)
}
local storages = {
["Globals"] = {default = 74531, notification = 74532},
["Creatures"] = {skull_type = 74529, participant = 74530, frags = 74531}
}
local tbl = {}
function showInformationAboutEvent(whenEventStartBeforINF)
local function second()
a=whenEventStartBeforINF-1
doBroadcastMessage("PVP Enfo Event is starting up! If you want take part, write !enfoevent . Be quick, only 50 players can participate. Anybody can report its part only for "..a.." minutes.", MESSAGE_EVENT_ADVANCE)
doBroadcastMessage("PVP Enfo Event rozpoczyna sie! Je?eli chcesz wziac udzial, napisz !enfoevent . Badz szybki, tylko 50 graczy moze uczestniczyc. Kazdy moze zglosic swoj udzial tylko przez "..a.." minut.", MESSAGE_EVENT_ADVANCE)
end
a=0
if whenEventStartBeforINF <= 1 then
doBroadcastMessage("PVP Enfo Event is starting up! If you want take part, write !enfoevent . Be quick, only 50 players can participate. Anybody can report its part only for "..config.whenStartEventBeforInformation.." minutes.", MESSAGE_EVENT_ADVANCE)
doBroadcastMessage("PVP Enfo Event rozpoczyna sie! Je?eli chcesz wziac udzial, napisz !enfoevent . Badz szybki, tylko 50 graczy moze uczestniczyc. Kazdy moze zglosic swoj udzial tylko przez "..config.whenStartEventBeforInformation.." minut.", MESSAGE_EVENT_ADVANCE)
return true
end
doBroadcastMessage("PVP Enfo Event is starting up! If you want take part, write !enfoevent . Be quick, only 50 players can participate. Anybody can report its part only for "..config.whenStartEventBeforInformation.." minutes.", MESSAGE_EVENT_ADVANCE)
for i = 1, whenEventStartBeforINF-1 do
addEvent(second, i* (1000*60))
end
return true
end
function checkMinimumNumberOfPlayers(number)
needPlayers = 0
for k, v in pairs(getOnlinePlayers()) do
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEvent" then
needPlayers=needPlayers+1
end
end
if needPlayers >= number then
return true
end
for k, v in pairs(getOnlinePlayers()) do
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEvent" then
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].participant, -1)
end
end
return false
end
function spairs(t, order)
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
if order then
table.sort(keys, function(a,b) return order(t, a, b) end)
else
table.sort(keys)
end
local i = 0
return function()
i = i + 1
if keys then
return keys, t[keys]
end
end
end
function startEvent()
local players_table = {}
a=1
if not checkMinimumNumberOfPlayers( config.howManyPlayersToStartEvent) then
doBroadcastMessage("PVP Enfo Event will not be started due to lack of adequate entered number of players.", MESSAGE_EVENT_ADVANCE)
doSetStorage(storages["Globals"].default, -1)
stopEvent(finish)
return true
end
for k, v in pairs(getOnlinePlayers()) do
if isPlayer(getPlayerByName(v)) then
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEvent" then
players_table[a] = {name = getPlayerByName(v)}
a=a+1
local creatureSkull = getCreatureSkullType(getPlayerByName(v))
if creatureSkull == SKULL_WHITE then
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].skull_type, creatureSkull)
end
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].frags) == -1 then doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].frags, 0) end
local toPos_Player = {x=math.random(config.startEventPosition[1].x, config.startEventPosition[2].x), y=math.random(config.startEventPosition[1].y, config.startEventPosition[2].y), z=math.random(config.startEventPosition[1].z, config.startEventPosition[2].z)}
if doTileQueryAdd(getPlayerByName(v), toPos_Player, 48) == 1 then
doTeleportThing(getPlayerByName(v), toPos_Player)
else
doTeleportThing(getPlayerByName(v), config.positionIfNotPosibleFirstTeleport)
end
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].participant, "pvpEventStart")
end
end
end
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerAccess(pid) > 3 then
doPlayerPopupFYI(pid, "Ilosc uczestnikow w PVP ENFO EVENT: "..a-1 ..".\nCzas trwania eventu: "..config.howLongEventHaveToLast..".\n")
end
end
doBroadcastMessage("PVP Enfo Event is starting up!", MESSAGE_EVENT_ADVANCE)
doSetStorage(storages["Globals"].default, 1)
return true
end
function endEvent()
doBroadcastMessage("PVP Enfo Event has been completed.", MESSAGE_EVENT_ADVANCE)
doSetStorage(storages["Globals"].default, -1)
for k, v in pairs(getOnlinePlayers()) do
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEventStart" then
local creature_skull_type = getCreatureStorage(getPlayerByName(v), storages["Creatures"].skull_type)
if creature_skull_type ~= -1 then
doCreatureSetSkullType(getPlayerByName(v), creature_skull_type)
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].skull_type, -1)
doPlayerSendTextMessage(getPlayerByName(v), MESSAGE_STATUS_CONSOLE_BLUE, "Before the start of the event, had a white skull.")
end
local town_position = getTownTemplePosition(getPlayerTown(getPlayerByName(v)))
doTeleportThing(getPlayerByName(v), town_position)
doCreatureSetSkullType(getPlayerByName(v), 0)
doPlayerSetPzLocked(getPlayerByName(v), false)
tbl[v] = getCreatureStorage(getPlayerByName(v), storages["Creatures"].frags)
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].frags, 0)
end
end
ss = ""
a=0
for k,v in spairs(tbl, function(t,a,b) return t < t[a] end) do
if a ~= config.howManyPlayersGetsAward then
a=a+1
doPlayerPopupFYI(getPlayerByName(k), "Congratulation!\nYou took "..a.." place in PVP ENFO EVENT and you won:\n "..getItemNameById(config.award[a].item).."!")
doPlayerAddItem(getPlayerByName(k), config.award[a].item)
doPlayerSendTextMessage(getPlayerByName(k), MESSAGE_EVENT_DEFAULT, "You get "..getItemNameById(config.award[a].item).." for "..a..". place in PVP ENFO EVENT.")
ss = ss.."Name: "..k.." Frags: ["..v.."]\n "
end
end
for _, v in pairs(getOnlinePlayers()) do
if getCreatureStorage(getPlayerByName(v), storages["Creatures"].participant) == "pvpEventStart" then
doPlayerPopupFYI(getPlayerByName(v), ss)
doCreatureSetStorage(getPlayerByName(v), storages["Creatures"].participant, -1)
end
end
return true
end
function onTime()
showInformationAboutEvent(config.whenStartEventBeforInformation)
doSetStorage(storages["Globals"].default, 0)
doSetStorage(storages["Globals"].notification, 0)
addEvent(startEvent, config.whenStartEventBeforInformation*1000*60)
finish = addEvent(endEvent, (config.whenStartEventBeforInformation*1000*60)+(config.howLongEventHaveToLast*1000*60))
return true
end[/lua]
W data>talkactions>talkactions.xml wklejamy:
[xml]<talkaction words="!enfoevent" event="script" value="ENFOEVENT.lua"/>[/xml]
W data>talkactions>scripts tworzymy plik o nazwie: ENFOEVENT.lua i wklejamy:
[lua]local smallCFG = {
maxPlayersInEvent = 60, --maksymalna ilosc osob w evencie
storage = 193781,
seconds = 1*60
}
function isEvent(nonEventText)
if getStorage(74531) ~= 0 then
return nonEventText
end
return getStorage(74532)
end
function onSay(cid, words, param, channel)
local tile = string.explode(param, ",")
if exhaustion.get(cid, smallCFG.storage) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You cant use this command twice.")
return true
end
if tile[1] == "info" and getPlayerAccess(cid) > 3 then
doPlayerPopupFYI(cid, "Aktualna ilosc zapisanych uczestnikow w PVP ENFO EVENT: "..isEvent("Event is disabled").."/"..smallCFG.maxPlayersInEvent..".\n")
return true
end
if getStorage(74531) ~= 0 then
doPlayerSendCancel(cid, "At this time, an event is disabled.")
return true
end
if getStorage(74532) > smallCFG.maxPlayersInEvent then
doPlayerSendCancel(cid, "Sorry, there are no more rooms available for this event.")
return true
end
if getCreatureStorage(cid, 74530) == "pvpEvent" then
doPlayerSendCancel(cid, "You are already subscribed to this event.")
doSendMagicEffect(getCreaturePosition(cid), 2)
return true
end
exhaustion.set(cid, smallCFG.storage, smallCFG.seconds)
doSetStorage(74532, getStorage(74532)+1)
doCreatureSetStorage(cid, 74530, "pvpEvent")
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Yours application has been accepted.")
return true
end[/lua]
Wyja?nienie configu:
W pliku znajduj?cym si? w creaturescripts:
[LUA]placeAfterDie = {{x=677, y=922, z=7}, {x=690, y=935, z=7}},
--[[
Miejsce w kt?rym zrespimy si? po ?mierci. (Randomowe miejsce zawieraj?ce si? w prostok?cie)
Pierwsza pozycja to lewy g?rny r?g prostok?ta, druga prawy dolny r?g.
--]]
placeAfterDieIfNotSuccessfullFirst = {{x=677, y=922, z=7}}
--[[
Miejsce w kt?rym zrespimy si? po ?mierci, je?eli na powy?szej pozycji nie jest to mo?liwe (np. je?eli akurat b?dzie woda na pozycji na g?rze)
]]--[/LUA]
GlobalEvent:
[lua]whenStartEventBeforInformation = 5.0,
--[[
Po ilu minutach rozpocznie sie event od pokazania informacji, o mo?liwo?ci do??czenia do eventu.
]]--
howLongEventHaveToLast = 20.0,
--[[
Ile minut ma trwa? event.
]]--
startEventPosition = {{x=665, y=920, z=7},{x=699, y=943, z=7}},
--[[
W jakie miejsce ma przeteleportowa? graczy przy stacie eventu (r?wnie? prostok?t z kt?rego s? wybrane randowmowe miejsca)
]]--
positionIfNotPosibleFirstTeleport = {x=665, y=920, z=7},
--[[
Pozycja na kt?r? zostanie przeteleportowany gracz, je?eli nie jest mo?liwa teleportacja na wybranym polu wyzej.
]]--
award = { [1] = {item = 8983}, -- [Zaj?teMiejsce] = {item = idNagrody} To jest dla pierwszego miejsca
[2] = {item = 2400},
[3] = {item = 2160},
[4] = {item = 2409},
[5] = {item = 2405}
},
--[[
Nagroda dla graczy, kt?rzy zajeli miejsca (u mnie dostanie nagrod? 5 os?b, ale mo?na dowolnie modyfikowa?) oraz id itema jaki gracz dostanie za jego miejsce.
]]--
howManyPlayersToStartEvent = 20,
--[[
Ile wymaganych zapisanych graczy, aby event rozpocz?? si? (je?eli nie zapisze si? wymagana ilo?? graczy event nie rozpocznie si?)
]]--
howManyPlayersGetsAward = 5 --ilosc osob ktore dostana nagrod?
--[[
Ile os?b dostanie nagrod? (musi si? zgadzac z powy?sz? tabelk? z nagrodami - 5 miejsc - 5 nagr?d)
]]--[/lua]
Talkactions:
[lua]maxPlayersInEvent = 60,
--[[
Ile maksymalnie moze zapisa? si? os?b.
]]--
storage = 193781,
--[[
Exhasted storage, je?eli inny skrypt nie wykorzystuje to ID, lepiej nie rusza?.
]]--
seconds = 1*60
--[[
Ile sekund exhasted ma by? na wpisywanie !pvpevent, zabezpieczenia przed bezsensownym spammem.
]]--
[/lua]
[xml]<globalevent name="PVP_ENFO_EVENT" time="12:00:00" event="script" value="PVP_ENFO_EVENT.lua"/>[/xml]
Tutaj za? ustalamy o kt?rej godzinie ma si? w??czy? event. (time="12:00:00")
Zabraniam kopiowania na inne fora bez mojej zgody!