SanninStory
https://www.twitch.tv/sdrn
- Dołączył
- Październik 13, 2012
- Posty
- 1778
- Liczba reakcji
- 116
Witam.
Chcia?bym wam przedstawi? skrypt autorstwa Kimokimo, u?ytkownika Otlandu.
Mam nadziej?, ?e komu? si? przyda.
Wystarczy prosta edycja pod swoje wymagania.
Pozdrawiam.
Chcia?bym wam przedstawi? skrypt autorstwa Kimokimo, u?ytkownika Otlandu.
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Catch the item" version="1.00" author="Kimo" contact="otland.net" enabled="yes">
<config name="catchtheitem_config"><![CDATA[
config = {
center_pos = {x = 2736, y = 3497, z = 7},
item = 8304,
aid = 4003,
effect = CONST_ANI_FIRE,
teleportPosition = {x = 74, y = 136, z = 9, stackpos = 1}, -- Where the teleport will be created
teleportToPosition = {x = 78, y = 136, z = 9}, -- Where the teleport will take you
teleportId = 1387, -- Id of the teleport
spawnItemTime1 = 1, -- Time when the first items will be created
spawnItemTime2 = 1, -- Time when the second items will be created
timeToStartEvent = 1, -- Minutes, after these minutes the teleport will be removed and the event will be declared started
itemRewards = {{2160,10}, {13305,1}, {13539,1}}
}
]]></config>
<talkaction words="!catch" event="script"><![CDATA[
function onSay()
domodlib('catchtheitem_config')
local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportPosition)
doItemSetAttribute(tp, "aid", config.teleportActionId)
doBroadcastMessage("Catch the item is starting in "..config.timeToStartEvent.." minute!", MESSAGE_EVENT_ADVANCE)
addEvent(startEvent, config.timeToStartEvent * 1000 * 10)
print(getGlobalStorageValue(3333))
return true
end
function startEvent()
domodlib('catchtheitem_config')
local get = getThingfromPos(config.teleportPosition)
if get.itemid == config.teleportId then
doRemoveItem(get.uid, 1)
doBroadcastMessage("Catch the item teleport have been removed and the first items wave will start in " .. config.spawnItemTime1 .. " ", MESSAGE_EVENT_ADVANCE)
addEvent(SpawnItem1, config.timeToStartEvent * 1000 * 10)
end
end
function SpawnItem1()
domodlib('catchtheitem_config')
local field = {}
local k = config.center_pos
for i = -2, 3 do
for j = -2, 4 do
table.insert(field, {x=k.x+i, y=k.y+j, z=k.z})
end
end
for i = 1, 8 do
local a = math.random(1, #field)
local c = {x=field[a].x, y=field[a].y, z=field[a].z}
if getThingFromPos({x=c.x, y=c.y, z=c.z, stackpos=1}).itemid ~= 9767 then
local b = doCreateItem(config.item, {x=c.x, y=c.y, z=c.z, stackpos=1})
doItemSetAttribute(b, "aid", config.aid)
doItemSetAttribute(c, "moveable", 0)
doSendDistanceShoot(config.center_pos, c, config.effect)
end
end
doBroadcastMessage("Items wave 1 has been finished wave 2 in "..config.spawnItemTime2.." minute ", MESSAGE_EVENT_ADVANCE)
addEvent(SpawnItem2, config.spawnItemTime2 * 1000 * 10)
end
function SpawnItem2()
domodlib('catchtheitem_config')
local field = {}
local k = config.center_pos
for i = -2, 3 do
for j = -1, 2 do
table.insert(field, {x=k.x+i, y=k.y+j, z=k.z})
end
end
for i = 1, 8 do
local a = math.random(1, #field)
local c = {x=field[a].x, y=field[a].y, z=field[a].z}
if getThingFromPos({x=c.x, y=c.y, z=c.z, stackpos=1}).itemid ~= 9767 then
local b = doCreateItem(config.item, {x=c.x, y=c.y, z=c.z, stackpos=1})
doItemSetAttribute(b, "aid", config.aid)
doSendDistanceShoot(config.center_pos, c, config.effect)
end
end
doBroadcastMessage("Items wave 2 is finished and results in 1 minute", MESSAGE_EVENT_ADVANCE)
addEvent(EndEvent, 1 * 1000 * 10)
end
function EndEvent()
domodlib('catchtheitem_config')
local function maximum(a)
local mi = 1
local m = a[mi]
for i,val in ipairs(a) do
if val > m then
mi = i
m = val
end
end
return m
end
local first = {}
local second = 0
local third = 0
local players = getPlayersOnline()
local winamount = {}
local storage = 7777 --event storage
for i, pid in ipairs(players) do
if getPlayerStorageValue(pid, storage) >= 0 then
table.insert(winamount, getPlayerStorageValue(pid, storage))
end
end
local winningamount = maximum(winamount)
local price = math.random(1, #config.itemRewards)
for i, pid in ipairs(players) do
if getPlayerStorageValue(pid, storage) == winningamount then
table.insert(first, getPlayerName(pid))
end
end
if #first > 1 then
doBroadcastMessage('[Catch the item]\n We have a draw between '..first[1]..' and '..first[2]..'!\nTherefor NO PRICES will be given!')
else
for i, pid in ipairs(players) do
if getPlayerStorageValue(pid, storage) == winningamount then
doBroadcastMessage('[Catch the item]\n And the winner is:\n'..first[1]..' with a total score of '..winningamount..'\nYour Price: '..config.itemRewards[price][2]..' x '..getItemNameById(config.itemRewards[price][1])..'\nCongratulations!')
doPlayerAddItem(pid, config.itemRewards[price][1], config.itemRewards[price][2])
end
end
end
for i, pid in ipairs(players) do
if getPlayerStorageValue(pid, storage) == (winningamount-1) then
if second == 0 then
doBroadcastMessage('[Catch the item]\n 2nd place is:\n'..getPlayerName(pid)..' with a total score of '..getPlayerStorageValue(pid, storage)..'\nCongratulations!')
second = 1
end
end
end
for i, pid in ipairs(players) do
if getPlayerStorageValue(pid, storage) == (winningamount-2) then
if third == 0 then
doBroadcastMessage('[Catch the item]\n 3rd place is:\n'..getPlayerName(pid)..' with a total score of '..getPlayerStorageValue(pid, storage)..'\nCongratulations!')
third = 1
end
end
end
addEvent(EndEvent2, 1 * 1000 * 10)
end
function EndEvent2()
setGlobalStorageValue(4444, 0)
setGlobalStorageValue(3333, 0)
for _, kid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(kid, 7776) > 0) then
doTeleportThing(kid, getTownTemplePosition(getPlayerTown(kid)))
setPlayerStorageValue(kid, 7776, 0)
setPlayerStorageValue(kid, 7777, 0)
end
end
end
]]></talkaction>
<action actionid="4003" event="script"><![CDATA[
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.actionid == 4003 then
doRemoveItem(getThingFromPos(fromPosition).uid, 6119)
setPlayerStorageValue(cid,7777, getPlayerStorageValue(cid,7777)+1)
local score = getPlayerStorageValue(cid, 7777)
doCreatureSay(cid, "Point!\nScore ="..getPlayerStorageValue(cid, 7777), 34)
return true
end
end
]]></action>
<movevent type="StepIn" actionid="3000" event="script"><![CDATA[
local config = {
playerCount = 3333, -- Global storage for counting the players in the event
maxPlayers = 20 -- Max players who can participate
}
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if getGlobalStorageValue(config.playerCount) < config.maxPlayers then
setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)+1)
if getGlobalStorageValue(config.playerCount) == config.maxPlayers then
doBroadcastMessage("Catch the item event is now full [" .. getGlobalStorageValue(config.playerCount) .. " players]! The event will soon start.")
else
doBroadcastMessage(getPlayerName(cid) .. " entered catch the item event! Currently " .. getGlobalStorageValue(config.playerCount) .. " players have joined!", MESSAGE_STATUS_CONSOLE_RED)
end
else
doTeleportThing(cid, fromPosition)
doPlayerSendCancel(cid, "The event is full. There is already " .. config.maxPlayers .. " players participating in the event.")
return false
end
print(getGlobalStorageValue(config.playerCount) .. " Players in catch the item event.")
return true
end
]]></movevent>
</mod>
Mam nadziej?, ?e komu? si? przyda.
Wystarczy prosta edycja pod swoje wymagania.
Pozdrawiam.