What's new

Mods Draw System

buchaLL

bez spiny, luźno
Joined
Aug 2, 2011
Messages
1,013
Reaction score
68
Age
27
Autor: buchaLL
Podgl?d:
r7ukdj.gif

Uwagi: Pami?tajcie, aby zmieni? id d?wigni oraz uid i ca?y config.

MOD.xml
[xml]<?xml version="1.0" encoding="UTF-8"?>
<mod name="Draw System" version="1.0" author="buchaLL" contact="https://tibia.net.pl/members/353628-buchaLL" enabled="yes">
<config name="draw_config"><![CDATA[
cfg = {
items = {8982, 5810, 5943, 5903, 2344, 5899, 7487, 9006, 9019},
pos1 = {x = 1083, y = 1014, z = 7, stackpos=255},
pos2 = {x = 1084, y = 1014, z = 7, stackpos=255},
pos3 = {x = 1085, y = 1014, z = 7, stackpos=255},
storage = 41383, speed = 200, mine = 8, loop = 10, effect = 29, item_needed = 8978, count_item = 0
}

function times(n)
if n > 1 then
return (n*(cfg.loop/2))+5
end
end

function doSendEffect(cid, c)
doSendAnimatedText(cfg.pos2, math.floor((cfg.mine*(times(cfg.loop))/cfg.speed)*5-c), math.random(10, 20))
end

function draw(times, final, pos)
local randomitem = cfg.items[math.random(1, #cfg.items)]

if getThingfromPos(cfg.pos1).itemid == 0 then
doCreateItem(randomitem, 1, cfg.pos1)
elseif getThingfromPos(cfg.pos2).itemid == 0 then
doCreateItem(getThingfromPos(cfg.pos1).itemid, 1, cfg.pos2)
doTransformItem(getThingfromPos(cfg.pos1).uid,randomitem)
elseif getThingfromPos(cfg.pos3).itemid == 0 then
doCreateItem(getThingfromPos(cfg.pos2).itemid, 1, cfg.pos3)
doTransformItem(getThingfromPos(cfg.pos2).uid,getThingfromPos(cfg.pos1).itemid)
doTransformItem(getThingfromPos(cfg.pos1).uid,randomitem)
elseif getThingfromPos(cfg.pos3).itemid ~= 0 then
doTransformItem(getThingfromPos(cfg.pos3).uid,getThingfromPos(cfg.pos2).itemid)
doTransformItem(getThingfromPos(cfg.pos2).uid,getThingfromPos(cfg.pos1).itemid)
doTransformItem(getThingfromPos(cfg.pos1).uid,randomitem)
end
end

function winner(uid, item, eff)
if isPlayer(uid) then
if getThingfromPos(cfg.pos2).uid ~= 0 then
doSendMagicEffect(cfg.pos2, eff)
if getPlayerFreeCap(uid) < getItemWeightById(getThingfromPos(cfg.pos2).itemid, 1) then
local item = doCreateItemEx(getThingfromPos(cfg.pos2).itemid-1, 1)
doPlayerSendMailByName(getCreatureName(uid), item, getTownTemplePosition(getPlayerTown(uid)))
else
doPlayerAddItem(uid, getThingfromPos(cfg.pos2).itemid, 1, true)
end
doPlayerSendTextMessage(uid, 21, "Gratulacje " .. getCreatureName(uid) .. "!\n Wygrales " .. getItemNameById(getThingfromPos(cfg.pos2).itemid) .. ".")
end
end
end
]]></config>
<action uniqueid="6431" event="buffer"><![CDATA[
domodlib('draw_config')
if item.itemid == 9825 and getPlayerStorageValue(cid, cfg.storage) == -1 then
if(getPlayerItemCount(cid, cfg.item_needed) >= cfg.count_item) then
doTransformItem(item.uid,item.itemid+1)
doPlayerRemoveItem(cid, cfg.item_needed, cfg.count_item)
setPlayerStorageValue(cid, cfg.storage, 1)
addEvent(setPlayerStorageValue, cfg.mine*(times(cfg.loop))*5, cid, cfg.storage, -1)
for c = 0.1, (cfg.mine*(times(cfg.loop))/cfg.speed*5) do
addEvent(doSendEffect, c * cfg.speed, cid, c)
addEvent(draw, c * cfg.speed, 0, 0, pos)
end
addEvent(winner, cfg.mine*(times(cfg.loop))*5, cid, item, cfg.effect)
else
if cfg.count_item == 1 then
doPlayerSendTextMessage(cid, 23, "Potrzebujesz ".. cfg.count_item .." ".. getItemNameById(cfg.item_needed) .."!")
else
doPlayerSendTextMessage(cid, 23, "Potrzebujesz ".. cfg.count_item .." ".. getItemNameById(cfg.item_needed) .."s!")
end
end
elseif item.itemid == 9826 and getPlayerStorageValue(cid, cfg.storage) == -1 then
cleanArea(cfg.pos1, cfg.pos3)
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendTextMessage(cid, 23, "Poczekaj na koniec losowania.")
end
return true
]]></action>
<event type="logout" name="stop_logout" event="script"><![CDATA[
domodlib('draw_config')
if getPlayerStorageValue(cid, cfg.storage) == 1 then
doPlayerSendTextMessage(cid, 23, "Nie mozesz wylogowac sie podczas losowania.")
return false
else
return true
end
]]></event>

<event type="login" name="stop_logout" event="buffer"><![CDATA[
registerCreatureEvent(cid, 'stop_logout')
]]></event>
</mod>[/xml]

lib/050-function.lua na koniec doda?:
[lua] function tileArea(fromPos, toPos, stack)
-- Area iterator by Colandus, edit by Tufte for tiles
local pos = {x=fromPos.x, y=fromPos.y-1, z=fromPos.z}
return function()
if (pos.y < toPos.y) then
pos.y = pos.y+1
elseif (pos.x <= toPos.x) then
pos.y = fromPos.y
pos.x = pos.x+1
else
pos.x = fromPos.x
pos.y = fromPos.y
pos.z = pos.z+1
end
if (pos.x <= toPos.x and pos.y <= toPos.y or pos.z < toPos.z) then
if (stack == nil) then
return pos
else
pos.stackpos = stack
return pos, getTileThingByPos(pos)
end
end
end
end

function cleanArea(frompos, topos)
for pos, thing in tileArea(frompos, topos, 0) do
if thing.uid ~= 0 then
pos.stackpos = 255
while isCreature(getThingfromPos(pos).uid) ~= TRUE and getThingfromPos(pos).itemid > 0 and hasProperty(getThingfromPos(pos).uid, 6) == TRUE and getTileInfo(pos).house == FALSE do
if getThingfromPos(pos).type ~= 0 then
doRemoveItem(getThingfromPos(pos).uid, getThingfromPos(pos).type)
else
doRemoveItem(getThingfromPos(pos).uid, 1)
end
end
end
end
end[/lua]
 
Top