Please Help Me
New Member
- Joined
- Jun 21, 2011
- Messages
- 126
- Reaction score
- 2
Hello otlanders,I was trying to add capture the flag event by fallen and tic-tac-toc event by doggynub to my ots but they didnt work and I would like to ask any of you to help me fix them .
With Capture the flag the TP wasnt creating and it kept broadcasting event starts in 1 minute,2 minutes or now but it didnt work & when i went to the flag place it said "flag is not at home" or "you cannot take your own flag".
script
With tic-tac-toc I couldnt use the levar to begin the game,it just moved but nothing happend and I got this error
this is the script
[it is also a mod]
With Capture the flag the TP wasnt creating and it kept broadcasting event starts in 1 minute,2 minutes or now but it didnt work & when i went to the flag place it said "flag is not at home" or "you cannot take your own flag".
script
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Capture The Flag" enabled="yes">
<description>
[[
@actionids:
actionid 6000:
red team
actionid 6001:
blue team
@fromPos
@toPos:
fromPos top left position
toPos buttom right position
@redPlayers, bluePlayers, redGoal, blueGoal:
all are storages
@ctf {
@redPos:
red team position (where they get teleported when they die)
@bluePos:
blue team position (/// same)
}
@temple:
temple position.
]]
</description>
<config name="ctf_config"><![CDATA[
waitingRoom = {
fromPos = {x = 746, y = 811, z = 7},
toPos = {x = 756, y = 822, z = 7}
}
redPlayers = 1200
bluePlayers = 2200
redGoal = 3200
blueGoal = 4200
redFlag = 5200
blueFlag = 5520
ctf = {
redPos = {x = 730, y = 842, z = 7},
bluePos = {x = 772, y = 847, z = 7}
}
temple = {x = 1001, y = 1002, z = 7}
]]></config>
<globalevent name="onstartup_ctf" type="start" event="script"><![CDATA[
domodlib("ctf_config")
setGlobalStorageValue(redGoal, 0)
setGlobalStorageValue(blueGoal, 0)
setGlobalStorageValue(redFlag, -1)
setGlobalStorageValue(blueFlag, -1)
db.executeQuery("DELETE FROM `player_storage` WHERE `key` = " .. redFlag .. ";")
db.executeQuery("DELETE FROM `player_storage` WHERE `key` = " .. blueFlag .. ";")
db.executeQuery("DELETE FROM `player_storage` WHERE `key`= " .. redPlayers .. ";")
db.executeQuery("DELETE FROM `player_storage` WHERE `key` = " .. bluePlayers .. ";")
return true
]]></globalevent>
<globalevent name="start_ctf" interval="60000" event="script"><![CDATA[
domodlib("ctf_config")
local red, blue = {}, {}
local conditionBlue = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, 1800 * 1000)
addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionRed, CONDITION_PARAM_TICKS, 1800 * 1000)
addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})
local function getPlayers(from, to)
local list = {}
for x = from.x, to.x do
for y = from.y, to.y do
for z = from.z, to.z do
local creature = getTopCreature({x =x , y =y, z = z}).uid
if isPlayer(creature) then
table.insert(list, creature)
end
end
end
end
return list
end
local function finishThis()
local t = getPlayers(waitingRoom.fromPos, waitingRoom.toPos)
if #t == 1 then
doPlayerSendTextMessage(t[1], 27, "Find another player to play with.")
doTeleportThing(t[1], temple, true)
elseif #t == 2 then
table.insert(red, t[1])
table.insert(blue, t[2])
elseif #t == 3 then
table.insert(red, t[2])
table.insert(blue, t[3])
table.insert(red, t[1])
elseif #t == 4 then
table.insert(red, t[1])
table.insert(blue, t[2])
table.insert(red, t[3])
table.insert(blue, t[4])
else
for _, v in ipairs(t) do
if math.random(1, 3) < 3 then
table.insert(red, v)
else
table.insert(blue, v)
end
end
end
if #red > 0 and #blue > 0 then
for _, r in ipairs(red) do
setPlayerStorageValue(r, redPlayers, 1)
doAddCondition(r, conditionRed)
doTeleportThing(r, ctf.redPos, true)
red = {}
end
for _, b in ipairs(blue) do
setPlayerStorageValue(b, bluePlayers, 1)
doAddCondition(b, conditionBlue)
doTeleportThing(b, ctf.bluePos, true)
blue = {}
end
end
return true
end
local function teleport()
addEvent(doBroadcastMessage, 1000, "Capture The Flag will begin in 2 minutes.")
addEvent(doBroadcastMessage, 60 * 1000, "Capture The Flag will begin in 1 minute.")
addEvent(doBroadcastMessage, 120 * 1000, "Capture The Flag will begin now.")
addEvent(finishThis, 120 * 1000)
end
function onThink(interval)
return teleport()
end
]]></globalevent>
<event type="login" name="ctf_login" event="script"><![CDATA[
registerCreatureEvent(cid, "ctf_stats")
return registerCreatureEvent(cid, "ctf_target")
]]></event>
<event type="statschange" name="ctf_stats" event="script"><![CDATA[
domodlib("ctf_config")
function onStatsChange(cid, attacker, type, combat, value)
if type == 1 then
if getCreatureHealth(cid) <= value then
if isPlayer(cid) and isCreature(attacker) then
if getPlayerStorageValue(cid, redFlag) == 1 then
setPlayerStorageValue(cid, redFlag, -1)
setGlobalStorageValue(redFlag, -1)
doBroadcastMessage(getCreatureName(cid) .. " has dropped the red flag!")
elseif getPlayerStorageValue(cid, blueFlag) == 1 then
setPlayerStorageValue(cid, blueFlag, -1)
setGlobalStorageValue(blueFlag, -1)
doBroadcastMessage(getCreatureName(cid) .. " has dropped the blue flag!")
end
if getPlayerStorageValue(cid, redPlayers) == 1 then
doTeleportThing(cid, ctf.redPos, true)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), false)
doCreatureAddMana(cid, getCreatureMaxMana(cid), false)
return false
elseif getPlayerStorageValue(cid, bluePlayers) == 1 then
doTeleportThing(cid, ctf.bluePos, true)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), false)
doCreatureAddMana(cid, getCreatureMaxMana(cid), false)
return false
end
end
end
end
return true
end
]]></event>
<event type="combat" name="ctf_target" event="script"><![CDATA[
domodlib("ctf_config")
if isPlayer(cid) and isPlayer(target) then
if(getPlayerStorageValue(cid, redPlayers) == 1 and getPlayerStorageValue(target, redPlayers) == 1) or (getPlayerStorageValue(cid, bluePlayers) == 1 and getPlayerStorageValue(target, bluePlayers) == 1) then
doPlayerSendCancel(cid, "You may not attack your team mates.")
return false
end
end
return true
]]></event>
<movevent type="StepIn" actionid="6000-6001" event="script"><![CDATA[
domodlib("ctf_config")
local function repeatFlag(cid)
local k = getThingPos(cid)
local r = {
{pos = {x = k.x + 2, y = k.y - 2, z = k.z}, delay = 300},
{pos = {x = k.x + 2, y = k.y + 2, z = k.z}, delay = 300},
{pos = {x = k.x - 2, y = k.y + 2, z = k.z}, delay = 300},
{pos = {x = k.x - 2, y = k.y, z = k.z}, delay = 300},
{pos = {x = k.x - 2, y = k.y - 2, z = k.z}, delay = 300},
{pos = {x = k.x, y = k.y - 2, z = k.z}, delay = 300}
}
local effects = {27, 28, 29, 30}
if getPlayerStorageValue(cid, redFlag) == 1 or getPlayerStorageValue(cid, blueFlag) == 1 then
for i = 1, 6 do
addEvent(doSendDistanceShoot, r[i].delay, r[i].pos, k, CONST_ME_FIREWORK_YELLOW)
end
for i = 1, 4 do
addEvent(doSendMagicEffect, 1000, getThingPos(cid), effects[i])
end
return addEvent(repeatFlag, 2 * 1000, cid)
end
return true
end
function onStepIn(cid, item, position, fromPosition, toPosition, lastPosition, actor)
if isPlayer(cid) then
if item.actionid == 6000 then --red team
if getPlayerStorageValue(cid, bluePlayers) == 1 then
if getPlayerStorageValue(cid, redFlag) == -1 and getGlobalStorageValue(redFlag) == -1 then
setPlayerStorageValue(cid, redFlag, 1)
setGlobalStorageValue(redFlag, 1)
doBroadcastMessage(getCreatureName(cid) .. " has stolen the Red Flag!")
repeatFlag(cid)
else
doCreatureSay(cid, "The flag is not at home!", 19)
doTeleportThing(cid, fromPosition)
end
elseif getPlayerStorageValue(cid, redPlayers) == 1 then
if getGlobalStorageValue(redFlag) == -1 then
if getPlayerStorageValue(cid, blueFlag) == 1 and getGlobalStorageValue(blueFlag) == 1 then
setPlayerStorageValue(cid, blueFlag, -1)
setGlobalStorageValue(blueFlag, -1)
doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point to the Red Team!")
setGlobalStorageValue(redGoal, getGlobalStorageValue(redGoal)+1)
doBroadcastMessage("Current CTF Game Score:\nRed Team: " .. getGlobalStorageValue(redGoal) .. "\nBlue Team: " .. getGlobalStorageValue(blueGoal) .. "\nTen scores to win!", 19)
else
doCreatureSay(cid, "You dont have the flag!", 19)
doTeleportThing(cid, fromPosition)
end
else
doCreatureSay(cid, "Return your flag firstly", 19)
doTeleportThing(cid, fromPosition)
end
else
doPlayerSendTextMessage(cid, 27, "Your not in any team, try reporting this to gamemaster?")
doTeleportThing(cid, temple, true)
end
elseif item.actionid == 6001 then --blue team
if getPlayerStorageValue(cid, redPlayers) == 1 then
if getPlayerStorageValue(cid, blueFlag) == -1 and getGlobalStorageValue(blueFlag) == -1 then
setPlayerStorageValue(cid, blueFlag, 1)
setGlobalStorageValue(blueFlag, 1)
doBroadcastMessage(getCreatureName(cid) .. " has stolen the Blue Flag!")
repeatFlag(cid)
else
doCreatureSay(cid, "The flag is not at home!", 19)
doTeleportThing(cid, fromPosition)
end
elseif getPlayerStorageValue(cid, bluePlayers) == 1 then
if getGlobalStorageValue(blueFlag) == -1 then
if getPlayerStorageValue(cid, redFlag) == 1 and getGlobalStorageValue(redFlag) == 1 then
setPlayerStorageValue(cid, redFlag, -1)
setGlobalStorageValue(redFlag, -1)
doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point to Blue Team!")
setGlobalStorageValue(blueGoal, getGlobalStorageValue(blueGoal)+1)
doBroadcastMessage("Current CTF Game Score:\nRed Team: " .. getGlobalStorageValue(redGoal) .. "\nBlue Team: " .. getGlobalStorageValue(blueGoal) .. "\nTen scores to win!", 19)
else
doCreatureSay(cid, "You dont have the flag!", 19)
doTeleportThing(cid, fromPosition)
end
else
doCreatureSay(cid, "Return your flag firstly", 19)
doTeleportThing(cid, fromPosition)
end
else
doPlayerSendTextMessage(cid, 27, "Your not in any team, try reporting this to gamemaster?")
doTeleportThing(cid, temple, true)
end
end
if getGlobalStorageValue(redGoal) == 10 and getGlobalStorageValue(blueGoal) < 10 then
doBroadcastMessage("Red Team has won the event!", 27)
for _, cid in ipairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, redPlayers) == 1 then
doPlayerAddItem(cid, 9020, math.random(1, 15))
doTeleportThing(cid, temple, true)
doRemoveCondition(cid, CONDITION_OUTFIT)
elseif getPlayerStorageValue(cid, bluePlayers) == 1 then
doTeleportThing(cid, temple, true)
doRemoveCondition(cid, CONDITION_OUTFIT)
end
if getPlayerStorageValue(cid, redFlag) == 1 then
setPlayerStorageValue(cid, redFlag, -1)
end
if getPlayerStorageValue(cid, blueFlag) == 1 then
setPlayerStorageValue(cid, blueFlag, -1)
end
end
setGlobalStorageValue(blueGoal, 0)
setGlobalStorageValue(redGoal, 0)
setGlobalStorageValue(redFlag, -1)
setGlobalStorageValue(blueFlag, -1)
elseif getGlobalStorageValue(blueGoal) == 10 and getGlobalStorageValue(redGoal) < 10 then
doBroadcastMessage("Blue Team has won the event!", 27)
for _, cid in ipairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, bluePlayers) == 1 then
doPlayerAddItem(cid, 9020, math.random(1, 15))
doTeleportThing(cid, temple, true)
doRemoveCondition(cid, CONDITION_OUTFIT)
elseif getPlayerStorageValue(cid, redPlayers) == 1 then
doTeleportThing(cid, temple, true)
doRemoveCondition(cid, CONDITION_OUTFIT)
end
if getPlayerStorageValue(cid, redFlag) == 1 then
setPlayerStorageValue(cid, redFlag, -1)
end
if getPlayerStorageValue(cid, blueFlag) == 1 then
setPlayerStorageValue(cid, blueFlag, -1)
end
end
setGlobalStorageValue(blueGoal, 0)
setGlobalStorageValue(redGoal, 0)
setGlobalStorageValue(redFlag, -1)
setGlobalStorageValue(blueFlag, -1)
end
else
doRemoveCreature(cid)
end
return true
end
]]></movevent>
</mod>
With tic-tac-toc I couldnt use the levar to begin the game,it just moved but nothing happend and I got this error
Lua:
[02/01/2012 14:42:36] [Error - Action Interface]
[02/01/2012 14:42:37] buffer
[02/01/2012 14:42:37] Description:
[02/01/2012 14:42:37] [string "--..."]:4: unexpected symbol near '{'
[02/01/2012 14:42:37] [Error - Action Interface]
[02/01/2012 14:42:37] buffer
[02/01/2012 14:42:37] Description:
[02/01/2012 14:42:37] [string "Phases_Tic_Tac = { ..."]:3: attempt to index global 'tic_pos' (a nil value)
[02/01/2012 14:42:37] [Error - MoveEvents Interface]
[02/01/2012 14:42:37] buffer
[02/01/2012 14:42:37] Description:
[02/01/2012 14:42:37] [string "--..."]:4: unexpected symbol near '{'
[02/01/2012 14:42:37] [Error - MoveEvents Interface]
[02/01/2012 14:42:37] buffer
[02/01/2012 14:42:37] Description:
[02/01/2012 14:42:37] [string "Phases_Tic_Tac = { ..."]:3: attempt to index global 'tic_pos' (a nil value)
[02/01/2012 14:42:37] [Error - MoveEvents Interface]
[02/01/2012 14:42:37] buffer
[02/01/2012 14:42:37] Description:
[02/01/2012 14:42:37] [string "--..."]:4: unexpected symbol near '{'
[02/01/2012 14:42:37] [Error - MoveEvents Interface]
[02/01/2012 14:42:37] buffer
[02/01/2012 14:42:37] Description:
[02/01/2012 14:42:37] [string "Phases_Tic_Tac = { ..."]:3: attempt to index global 'tic_pos' (a nil value)
this is the script
[it is also a mod]
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Tictactoc" version="1.0" author="Doggynub" contact="[email protected]" enabled="yes">
<config name="Tic_config">
<![CDATA[ --
--// Editable \\--
turn_id_tocken = 555541 -- empty storage
turn_tocken = 555542 -- empty storage
canMove_token = 555543 -- empty storage
round_token = 555544 -- empty storage
winner_token = 555545 -- empty storage
running_token = 555546 -- empty storage
won_token = 555547 -- empty storage
ITem_WinnEr = { {2160,2} , {2446,1} } -- {item,count} make sure non-stackable items would be with count 1 only
tic_pos = { -- game area, the little white area you place tokens at
frompos = { x= 1322, y = 2017, z = 7 }, -- start position of playing field
topos = { x= 1330, y = 2023, z = 7 } -- end position of playing field }
config_tic = { -- in game config
{ --[[The player playing with "Cross" tokens config ]]--
pos_start = { x= 1327, y = 2015, z = 7 }, -- Lever place : the place he would be standing when the lever ispushed
pos_game = { x= 1329, y = 2020, z = 7 }, --Game place : the place where he stands in game
storage = 553466, -- Empty storage : needed for wins
token_pos = { x= 1329, y = 2019, z = 7 } --Token pos : the pos where the "Cross" tokens will be in
},
{ --[[The player playing with "Circle" tokens config ]]--
pos_start = { x= 1325, y = 2015, z = 7 }, -- Lever place : the place he would be standing when the lever ispushed
pos_game = { x= 1323, y = 2020, z = 7 }, --Game place : the place where he stands in game
storage = 553469, -- Empty storage : needed for wins
token_pos = { x= 1323, y = 2021, z = 7 } --Token pos : the pos where the circle tokens will be in
}
}
]]></config>
<lib name="Tic_lib"><![CDATA[
Phases_Tic_Tac = {
-- // Horizontal raws \\--
{ {x = tic_pos.frompos.x, y = tic_pos.frompos.y, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+1, y = tic_pos.frompos.y, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+2, y = tic_pos.frompos.y, z = tic_pos.frompos.z } },
{ {x = tic_pos.frompos.x, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+1, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+2, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z } },
{ {x = tic_pos.frompos.x, y = tic_pos.frompos.y+2, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+1, y = tic_pos.frompos.y+2, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+2, y = tic_pos.frompos.y+2, z = tic_pos.frompos.z } },
-- // Vertical raws \\--
{ {x = tic_pos.frompos.x, y = tic_pos.frompos.y, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x, y = tic_pos.frompos.y+2, z = tic_pos.frompos.z } },
{ {x = tic_pos.frompos.x+1, y = tic_pos.frompos.y, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+1, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+1, y = tic_pos.frompos.y+2, z = tic_pos.frompos.z } },
{ {x = tic_pos.frompos.x+2, y = tic_pos.frompos.y, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+2, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+2, y = tic_pos.frompos.y+2, z = tic_pos.frompos.z } },
--// Crosses raws \\--
{ {x = tic_pos.frompos.x, y = tic_pos.frompos.y, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+1, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+2, y = tic_pos.frompos.y+2, z = tic_pos.frompos.z } },
{ {x = tic_pos.frompos.x, y = tic_pos.frompos.y+2, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+1, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z } , {x = tic_pos.frompos.x+2, y = tic_pos.frompos.y, z = tic_pos.frompos.z } }
}
function markWinningRaw(item, pos1, pos2, pos3, timer)--By Doggynub
doRemoveItem(getTileItemById(pos1,item).uid)
doRemoveItem(getTileItemById(pos2,item).uid)
doRemoveItem(getTileItemById(pos3,item).uid)
addEvent(doCreateItem,timer,item,1,pos1)
addEvent(doCreateItem,timer,item,1,pos2)
addEvent(doCreateItem,timer,item,1,pos3)
end
function turn()
if getStorage(canMove_token) ~= 0 and getStorage(running_token) > 0 then
doSendAnimatedText(config_tic[getStorage(turn_tocken)].token_pos,"Play",TEXTCOLOR_GREEN)
addEvent(turn,1000)
end
end
function checkCircle() --By Doggynub
local raw = 0
local check = false
for i = 1,#Phases_Tic_Tac do
local caller = Phases_Tic_Tac[i]
local item = getTileItemById(caller[1],6557).uid
local item1 = getTileItemById(caller[2],6557).uid
local item2 = getTileItemById(caller[3],6557).uid
if ( item > 0 and item1 > 0 and item2 > 0 ) then
check = true
raw = i
break
end
end
if check == true and raw > 0 then
local call = Phases_Tic_Tac[raw]
for i = 1,7 do
addEvent(markWinningRaw, i *800, 6557,call[1] , call[2], call[3], 400)
end
end
return check
end
function checkCross()--By Doggynub
local raw = 0
local check = false
for i = 1,#Phases_Tic_Tac do
local caller = Phases_Tic_Tac[i]
local item = getTileItemById(caller[1],6556).uid
local item1 = getTileItemById(caller[2],6556).uid
local item2 = getTileItemById(caller[3],6556).uid
if ( item > 0 and item1 > 0 and item2 > 0 ) then
check = true
raw = i
break
end
end
if check == true and raw > 0 then
local call = Phases_Tic_Tac[raw]
for i = 1,7 do
addEvent(markWinningRaw, i *800, 6556,call[1] , call[2], call[3], 400)
end
end
return check
end
function isCircle(cid)--By Doggynub
return getPlayerStorageValue(cid,config_tic[2].storage) == 1 and true or false
end
function isCross(cid)--By Doggynub
return getPlayerStorageValue(cid,config_tic[1].storage) == 1 and true or false
end
function gatherTokens(frompos,topos, crosspos , circlepos)--By Doggynub
for i = frompos.x, topos.x do
for j = frompos.y, topos.y do
local pos = {x = i, y=j,z=frompos.z}
local circle = getTileItemById(pos,6557).uid
local cross = getTileItemById(pos,6556).uid
if cross > 0 then
doTeleportThing(cross,crosspos)
elseif circle > 0 then
doTeleportThing(circle,circlepos)
end
end
end
return true
end
function endPoint(frompos,topos)--By Doggynub
local check = true
for i = frompos.x, topos.x do
for j = frompos.y, topos.y do
local pos = {x = i, y=j,z=frompos.z}
local circle = getTileItemById(pos,6557).uid
local cross = getTileItemById(pos,6556).uid
if circle < 1 and cross < 1 then
check = false
break
end
end
end
return check
end
function isWinner(cid)--By Doggynub
if isCircle(cid) then
if checkCircle() then
return true
end
elseif isCross(cid) then
if checkCross() then
return true
end
end
return false
end
function send(uid,cid,n,type)--By Doggynub
for i = 1, n do
if type == nil then
addEvent(doSendDistanceShoot,i*300,getThingPos(uid),getThingPos(cid),41)
addEvent(doSendAnimatedText,i*300,getThingPos(cid),"Winner!",math.random(0,255))
else
addEvent(doSendDistanceShoot,i*300,getThingPos(uid),config_tic[1].pos_game,41)
addEvent(doSendDistanceShoot,i*300,getThingPos(uid),config_tic[2].pos_game,41)
addEvent(doSendAnimatedText,i*300,config_tic[1].pos_game,"Draw!",math.random(0,255))
addEvent(doSendAnimatedText,i*300,config_tic[2].pos_game,"Draw!",math.random(0,255))
end
end
return true
end
function endGame()--By Doggynub
local array = {getTopCreature(config_tic[1].pos_game).uid, getTopCreature(config_tic[2].pos_game).uid}
for i = 1,2 do
doTeleportThing(array[i],getTownTemplePosition(getPlayerTown(array[i])))
doCreatureSetNoMove(array[i],0)
doRemoveCondition(array[i],CONDITION_INFIGHT)
doSendMagicEffect(getThingPos(array[i]),10)
end
doSetStorage(winner_token,-1)
doSetStorage(round_token,-1)
doSetStorage(running_token,-1)
doSetStorage(won_token,-1)
return true
end
function doAddCopiedContainer(it, new) --By Doggynub
local uid,its,news = it.uid, {},{}
local size = getContainerSize(uid)
local test = {}
for i = 0, size-1 do
local item = getContainerItem(uid,i)
table.insert(test,{item, item.type})
if isContainer(item.uid) then
table.insert(its,item)
end
end
for i = #test,1,-1 do
local call = test[i]
local ufg = doAddContainerItem(new,call[1].itemid,(call[2] < 1 and 1 or call[2]) )
if isContainer(ufg) then
table.insert(news,ufg)
end
end
for i = 1,#its do
doAddCopiedContainer(its[i], news[i])
end
return true
end
function getRefree(cid,type)--By Doggynub
local str1 = ""
local str2 = ""
if type == nil then
if getStorage(round_token) < 1 then
str1 = getCreatureName(cid).." won Round <1> "
str2 = "Round <2> : start"
doSetStorage(round_token,2)
doSetStorage(winner_token,cid)
elseif getStorage(round_token) == 2 then
if getStorage(winner_token) == cid then
str1 = getCreatureName(cid).." won the game, and will recive his reward."
doSetStorage(won_token,1)
str2 = "You will be teleported out shortly."
else
str1 = getCreatureName(cid).." won Round <2>."
str2 = "Final Round : start"
doSetStorage(round_token,3)
doSetStorage(winner_token,cid)
end
elseif getStorage(round_token) == 3 then
str1 = getCreatureName(cid).." won the game, and will recive his reward."
local item = ITem_WinnEr[math.random(1,#ITem_WinnEr)]
local bp = doCreateItemEx(cid, item[1],item[2] )
if(doPlayerAddItemEx(cid, bp) ~= RETURNVALUE_NOERROR) then
doPlayerSendTextMessage(cid,MESSAGE_EVENT_ORANGE,"You didn't recieve your reward as you don't have enough space or cap.")
else
doPlayerSendTextMessage(cid,MESSAGE_TYPES["blue"],"You won "..item[2] .."x ".. getItemNameById(item[1])..".")
end
doSetStorage(won_token,1)
str2 = "You will be teleported out shortly."
doSetStorage(winner_token,cid)
end
else
str1 = "No one won. Round re-match. "
str2 = "Round <".. ( getStorage(round_token) < 1 and "1" or getStorage(round_token) ) .."> : start"
end
local uid = doCreateMonster("chicken",{x = tic_pos.frompos.x+1, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z,stackpos = 0 })
doChangeSpeed(uid, - getCreatureSpeed(uid) )
addEvent(doCreatureSay,100,uid,str1,19)
addEvent(doCreatureSay,10*300+ 1000,uid,str2,19)
addEvent(turn,10*300+ 3305)
if type == nil then
addEvent(doCreatureSetLookDirection,10*300+ 8,uid, 2)
end
addEvent(doRemoveCreature,10*300+ 3300,uid)
doCreatureSetLookDirection(uid, getDirectionTo(getThingPos(uid), getThingPos(cid)))
send(uid,cid,10,type)
addEvent(doSetStorage,10*300+ 3300,canMove_token,1)
if getStorage(won_token) > 0 then
addEvent(endGame,10*300+ 3300)
end
return true
end
function getCounOnTile(posi)
local found = 0
local f = getThingFromPos({x=posi.x , y= posi.y, z= posi.z, stackpos = 255}).uid > 0 and getThingFromPos({x=posi.x , y= posi.y, z= posi.z, stackpos = 255}).itemid or false
if f~= false then
for i = 1,254 do
pos = {x=posi.x , y= posi.y, z= posi.z, stackpos = i}
if getThingFromPos({x=posi.x , y= posi.y, z= posi.z, stackpos = i}).uid > 0 then
if getThingFromPos({x=posi.x , y= posi.y, z= posi.z, stackpos = 255}).itemid == f then
found = found+1
end
end
end
end
return f == false and 0 or found
end
]]></lib>
<action actionid="1111" event="script"> <![CDATA[
domodlib('Tic_config')
domodlib('Tic_lib')
local fight = createConditionObject(CONDITION_INFIGHT,-1)
function onUse(cid, item, fromPosition, itemEx, toPosition)
local pl1_game = getTopCreature(config_tic[1].pos_start).uid
local pl2_game = getTopCreature(config_tic[2].pos_start).uid
local players1_enter = getTopCreature(config_tic[1].pos_game).uid
local players2_enter = getTopCreature(config_tic[2].pos_game).uid
local players = {}
if players1_enter < 1 and players2_enter < 1 then
if getStorage(running_token) > 0 then
doSetStorage(winner_token,-1)
doSetStorage(round_token,-1)
doSetStorage(running_token,-1)
doSetStorage(won_token,-1)
end
end
if getStorage(running_token) > 0 then
return doPlayerSendCancel(cid,"The players inside didn't finish there game yet.")
end
if pl1_game > 0 and pl2_game > 0 then
table.insert(players, pl1_game)
table.insert(players, pl2_game)
else
return doPlayerSendCancel(cid,"The game needs 2 players to start.")
end
gatherTokens(tic_pos.frompos,tic_pos.topos, config_tic[1].token_pos , config_tic[2].token_pos)
for i = 1,#players do
doTeleportThing(players[i],config_tic[i].pos_game,false)
doSendMagicEffect(config_tic[i].pos_game,10)
doCreatureSetNoMove(players[i],1)
doAddCondition(players[i],fight)
setPlayerStorageValue(players[i],config_tic[i].storage,1)
setPlayerStorageValue(players[i],turn_id_tocken,i)
end
local uid = doCreateMonster("chicken",{x = tic_pos.frompos.x+1, y = tic_pos.frompos.y+1, z = tic_pos.frompos.z,stackpos = 0 })
doSetStorage(turn_tocken,math.random(1,2))
doSetStorage(running_token,1)
doChangeSpeed(uid, - getCreatureSpeed(uid) )
doSetStorage(canMove_token,0)
addEvent(doCreatureSay,100,uid,"Round <1> : start",19)
addEvent(doRemoveCreature,2400,uid)
addEvent(doSetStorage,2410,canMove_token,1)
addEvent(turn,2411)
return true
end
]]></action>
<movevent type="RemoveItem" fromid="6556" toid="6557" event="script"><![CDATA[
domodlib('Tic_config')
domodlib('Tic_lib')
function onRemoveItem(moveItem, tileItem, position, cid)
local returnplace = ( moveItem.itemid == 6556 and config_tic[1].token_pos or config_tic[2].token_pos )
if cid > 0 then
if getStorage(running_token) > 0 then
if doComparePositions(position,config_tic[1].token_pos) or doComparePositions(position,config_tic[2].token_pos) then
if getStorage(canMove_token) == 0 then
return doPlayerSendCancel(cid,"Sorry, you can't move your token now.") and doSendMagicEffect(returnplace,2) and doTeleportThing(moveItem.uid,returnplace)
end
if getStorage(turn_tocken) ~= getPlayerStorageValue(cid,turn_id_tocken) then
return doSendMagicEffect(returnplace,2) and doPlayerSendCancel(cid,"Sorry, this isn't your turn.") and doTeleportThing(moveItem.uid,returnplace)
end
local p = getThingPosition(moveItem.uid)
local f = moveItem.itemid
if not isInRange(p,tic_pos.frompos,tic_pos.topos) then
return doSendMagicEffect(returnplace,2) and doTeleportThing(moveItem.uid,returnplace) and doPlayerSendCancel(cid,"You can't move the token outside play zone.")
else
if getCounOnTile(p) > 1 then
return doSendMagicEffect(returnplace,2) and doTeleportThing(moveItem.uid,returnplace) and doPlayerSendCancel(cid,"You can't place another token here.")
end
end
if isWinner(cid) then
doSetStorage(canMove_token,0)
addEvent(gatherTokens,6700,tic_pos.frompos,tic_pos.topos, config_tic[1].token_pos , config_tic[2].token_pos)
addEvent(getRefree,7000,cid)
else
if endPoint(tic_pos.frompos,tic_pos.topos) then
doSetStorage(canMove_token,0)
gatherTokens(tic_pos.frompos,tic_pos.topos, config_tic[1].token_pos , config_tic[2].token_pos)
addEvent(getRefree,200,cid,1)
doSetStorage(turn_tocken, math.random(1,2) )
else
doSetStorage(turn_tocken, ( getStorage(turn_tocken) == 1 and 2 or 1 ) )
end
end
end
else
return doSendMagicEffect(returnplace,2) and doTeleportThing(moveItem.uid,returnplace) and doPlayerSendCancel(cid,"Game not started.")
end
end
return true
end
]]></movevent>
<movevent type="AddItem" tileitem="1" uniqueid="6666" event="script"><![CDATA[
domodlib('Tic_config')
domodlib('Tic_lib')
function onAddItem(moveItem, tileItem, position, cid)
if cid > 0 then
local returnplace = ( moveItem.itemid == 6556 and config_tic[1].token_pos or config_tic[2].token_pos )
local check = false
for i = tic_pos.frompos.x, tic_pos.topos.x do
for j = tic_pos.frompos.y, tic_pos.topos.y do
local pos = {x = i, y=j,z=tic_pos.frompos.z}
if doComparePositions(position,pos) then
check = true
break
end
end
end
if not isInArray({6556,6557},moveItem.itemid) then
local count = moveItem.type
if not isContainer(moveItem.uid) then
doRemoveItem(moveItem.uid)
doPlayerAddItem(cid,moveItem.itemid,count)
doPlayerSendCancel(cid,"You can't drop your item here.")
doSendMagicEffect(getThingPos(cid),2)
else
local uids = moveItem
local bp = doPlayerAddItem(cid,uids.itemid,1)
doAddCopiedContainer(uids, bp)
return doRemoveItem(moveItem.uid) and doPlayerSendCancel(cid,"You can't drop your item here.") and doSendMagicEffect(getThingPos(cid),2)
end
else
if check == false then
doRemoveItem(moveItem.uid)
end
end
end
return true
end
]]></movevent>
</mod>
Last edited: