belier140
New Member
- Joined
- Apr 7, 2010
- Messages
- 36
- Reaction score
- 2
Hello everyone, could someone help me to make a global event from a talkaction? I cant find the way to do it, thanks in advance for your help. Here's the script:
- - - Updated - - -
I tried just changing function onSay() for function onThink(interval, lastExecution) but seems that i have to change more than that, if you dont want to remake the full script just tell me something like: change this to this and stuff. Please help ._.
Code:
config = {
center_pos = {x = 16936, y = 16697, z = 8},
item = 8304,
aid = 4003,
effect = CONST_ME_ENERGYAREA,
teleportPosition = {x = 32357, y = 32220, z = 7, stackpos = 1}, -- Where the teleport will be created
teleportToPosition = {x = 16938, y = 16694, z = 8}, -- Where the teleport will take you
teleportId = 1387, -- Id of the teleport
teleportActionId = 5000,
spawnItemTime1 = 1, -- Time when the first items will be created
spawnItemTime2 = 1, -- Time when the second items will be created
timeToStartEvent = 5, -- Minutes, after these minutes the teleport will be removed and the event will be declared started
itemRewards = {{2160,10}, {13305,1}, {13539,1}}
}
function onSay()
local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportPosition)
doItemSetAttribute(tp, "aid", config.teleportActionId)
doBroadcastMessage("Catch the item is starting in "..config.timeToStartEvent.." minute! Run to the Event Room !", MESSAGE_EVENT_ADVANCE)
addEvent(startEvent, config.timeToStartEvent * 60000)
print(getGlobalStorageValue(3333))
doBroadcastMessage("Usa las flamas para ganar puntos, el que tenga mas puntos gana! Nuevos premios cada dia !", MESSAGE_EVENT_ADVANCE)
return true
end
function startEvent()
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 1 minute ", MESSAGE_EVENT_ADVANCE)
addEvent(SpawnItem1, config.spawnItemTime1 * 60000)
end
end
function SpawnItem1()
local field = {}
local k = config.center_pos
for i = -4, 6 do
for j = -4, 6 do
table.insert(field, {x=k.x+i, y=k.y+j, z=k.z})
end
end
for i = 1, 20 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 ~= 12292 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 1 has been finished wave 2 in 1 minute", MESSAGE_EVENT_ADVANCE)
addEvent(SpawnItem2, config.spawnItemTime2 * 60000)
end
function SpawnItem2()
local field = {}
local k = config.center_pos
for i = -4, 6 do
for j = -4, 6 do
table.insert(field, {x=k.x+i, y=k.y+j, z=k.z})
end
end
for i = 1, 20 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 ~= 12292 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 * 6000 * 10)
end
function EndEvent()
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(3333, 0)
for _, kid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(kid, 7777) > 0) then
doTeleportThing(kid, getTownTemplePosition(getPlayerTown(kid)))
setPlayerStorageValue(kid, 7777, 0)
end
end
end
- - - Updated - - -
I tried just changing function onSay() for function onThink(interval, lastExecution) but seems that i have to change more than that, if you dont want to remake the full script just tell me something like: change this to this and stuff. Please help ._.
Last edited: