Ir para conteúdo

Posts Recomendados

Jogo da velha (Tic-Tac-Toe)

créditos doggynob

 

Hoje venhos vos trazer o 'mod' do jogo da velha, onde os players interagem com esse jogo famoso in-game. Não precisa explicar muito né, vamos ao script:

 

Na pasta Mods do seu ot crie um arquivo chamado game.xml, e dentro coloque isso:

 

 

<?xml version="1.0" encoding="UTF-8"?>

<mod name="Tic tac toc" version="1.0" author="Doggynub" contact="tarabishy_2020@hotmail.com" enabled="yes">

 

<config name="Tic_config"><![CDATA[

--[[

##*#*#*#*#*#*#* •••• VVVVVVVVV •••• #%#%#%#%#%#%#%

#%#%#%#%#%#%#%* •••• VVVVVVVVV •••• #%#%#%#%#%#%#%

#$#%#%#%#%#%#%#%# << Tic-Tac-Tuc System >> #$#$#$#$#$#$#$#$#

<< By : Doggynub >>

#%#%#%#%#%#%#% •••• ^^^^^^^^^ •••• #%#%#%#%#%#%%#

#%#%#%#%#%#%##% •••• ^^^^^^^^^ •••• ##*#*#*#*#*#*#

 

]]--

 

 

 

 

--// 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= 976, y = 1016, z = 7 }, -- posição inicial da area de jogo

 

topos = { x= 978, y = 1018, z = 7 } -- posição do fim da area de jogo

}

 

config_tic = { -- in game config

 

{ --[[The player playing with "Cross" tokens config ]]--

 

pos_start = { x= 978, y = 1012, z = 7 }, -- Lever place : the place he would be standing when the lever ispushed

 

pos_game = { x= 980, y = 1017, z = 7 }, --Posicao onde o jogador vai ser teleportado

 

storage = 553466, -- Nao mecha

 

token_pos = { x= 980, y = 1016, z = 7 } --Posicao do Xisinho

 

},

 

 

{ --[[The player playing with "Circle" tokens config ]]--

 

pos_start = { x= 976, y = 1012, z = 7 }, -- Lever place : the place he would be standing when the lever ispushed

 

pos_game = { x= 974, y = 1017, z = 7 }, --Game place : the place where he stands in game

 

storage = 553469, -- Empty storage : needed for wins

 

token_pos = { x= 974, y = 1018, 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

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

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,getTownTemplePosition(getPlayerTown(array)))

doCreatureSetNoMove(array,0)

doRemoveCondition(array,CONDITION_INFIGHT)

doSendMagicEffect(getThingPos(array),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

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, news)

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,config_tic.pos_game,false)

doSendMagicEffect(config_tic.pos_game,10)

doCreatureSetNoMove(players,1)

doAddCondition(players,fight)

setPlayerStorageValue(players,config_tic.storage,1)

setPlayerStorageValue(players,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>

 

 

 

Coloquei as informações importantes em negrito e dividi em cores, em breve estarei adicionando uma legendinha pra que serve cada coisa, e onde você deve alterar (para os que não sabem).

 

Instruções:

  • Cinza: Alguns dialogos importantes, caso alguem queira editar e talz.
  • Verde/Azul: TImes:

Verde: "Xizinho"

 

 

 

Verde: Time do X (xizinho do jogo da velha)

 

{ --[[The player playing with "Cross" tokens config ]]--

 

pos_start = { x= 978, y = 1012, z = 7 }, -- Lugar onde ele vai estar antes de puxar a alavanca

 

pos_game = { x= 980, y = 1017, z = 7 }, --Lugar pra onde ele vai estar após puxar a alavanca

 

storage = 553466, -- Nao mecha

 

token_pos = { x= 980, y = 1016, z = 7 } --Posicao do Xisinho, aonde vai estar o xisinho...

 

},

 

 

 

Azul: "Bolinha"

 

 

 

{ --[[The player playing with "Circle" tokens config ]]--

 

pos_start = { x= 976, y = 1012, z = 7 }, -- Local onde o jogador vai estar antes de puxar a alavanca

 

pos_game = { x= 974, y = 1017, z = 7 }, --Lugar onde ele vai estar após puxar a alavanca

 

storage = 553469, -- Não mexa...

 

token_pos = { x= 974, y = 1018, z = 7 } --Posição aonde vai ta o circulusinho

 

}

 

}

  • Em Laranja: É o id dos items xis e circulo, que vão ser usados in-game. Não precisa de alterar, por que foi colocado ja com os ids corretos.

Foto de como colocar os uniques/actions:

tutorialjogodavelha.png

Mapa Disponível Para Download:

http://www.4shared.c...zitoG_to_X.html

(Uids já alteradas)

Editado por GuizitoG
Link para o comentário
Compartilhar em outros sites

Tópico modificado. Agora com imagem e tutorial de como fazer.

Ps. Tava sem tempo de arrumar o tópico, cheguei e já arrumei, desculpe a demora!

Editado por GuizitoG
Link para o comentário
Compartilhar em outros sites

  • 3 weeks later...

Aqui não funfou, o 8.60 não funcionouu =/ da uma olhada no meu codigo ! aáaa explica como funciona se paga e se nãao se tem que mudar a id da lavanca explica melhor ai..

 

 

<?xml version="1.0" encoding="UTF-8"?>

<mod name="Tic tac toc" version="1.0" author="Doggynub" contact="tarabishy_2020@hotmail.com" enabled="yes">

 

<config name="Tic_config"><![CDATA[

--[[

##*#*#*#*#*#*#* •••• VVVVVVVVV •••• #%#%#%#%#%#%#%

#%#%#%#%#%#%#%* •••• VVVVVVVVV •••• #%#%#%#%#%#%#%

#$#%#%#%#%#%#%#%# << Tic-Tac-Tuc System >> #$#$#$#$#$#$#$#$#

<< By : Doggynub >>

#%#%#%#%#%#%#% •••• ^^^^^^^^^ •••• #%#%#%#%#%#%%#

#%#%#%#%#%#%##% •••• ^^^^^^^^^ •••• ##*#*#*#*#*#*#

 

]]--

 

 

 

 

--// 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= 514, y = 857, z = 4 }, -- posição inicial da area de jogo

 

topos = { x= 520, y = 858, z = 4 } -- posição do fim da area de jogo

}

 

config_tic = { -- in game config

 

{ --[[The player playing with "Cross" tokens config ]]--

 

pos_start = { x= 514, y = 855, z = 4 }, -- Lever place : the place he would be standing when the lever ispushed

 

pos_game = { x= 518, y = 858, z = 4 }, --Posicao onde o jogador vai ser teleportado

 

storage = 553466, -- Nao mecha

 

token_pos = { x= 518, y = 857, z = 4 } --Posicao do Xisinho

 

},

 

 

{ --[[The player playing with "Circle" tokens config ]]--

 

pos_start = { x= 516, y = 855, z = 4 }, -- Lever place : the place he would be standing when the lever ispushed

 

pos_game = { x= 512, y = 1858, z = 4 }, --Game place : the place where he stands in game

 

storage = 553469, -- Empty storage : needed for wins

 

token_pos = { x= 512, y = 854, z = 4 } --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

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

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,getTownTemplePosition(getPlayerTown(array)))

doCreatureSetNoMove(array,0)

doRemoveCondition(array,CONDITION_INFIGHT)

doSendMagicEffect(getThingPos(array),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

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, news)

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,config_tic.pos_game,false)

doSendMagicEffect(config_tic.pos_game,10)

doCreatureSetNoMove(players,1)

doAddCondition(players,fight)

setPlayerStorageValue(players,config_tic.storage,1)

setPlayerStorageValue(players,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>

Link para o comentário
Compartilhar em outros sites

agora ta tranquilo só falta resolver um erro !

 

 

[ERRO - ACTION Interface]

buffer:onUse

Description:

attempt to index a nil value

stack traceback:

[C]:in function 'doTeleportThing'

[string "loadBuffer"]:32: in function <[string "loadBuffer"]:4>

 

quando coloco um player e puxo a lavanca ele diz que tem que ter outro player mais quando coloco outro player que puxo a lavanca da esse erro ai acima e não teleporta para o jogo =(

Link para o comentário
Compartilhar em outros sites

  • 2 months later...

Legal !! Mais não entendi nada ...

 

Além de você ter postado em um tópico inativo há mais de 30 dias, faz um comentário que não representa dúvida, feedback, erro no script, nem nada. Apenas um comentário sem conteúdo algum.

 

Estou te dando um alerta verbal, na próxima, negativo sua reputação.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...