Tibia Mod
Forum zostało Przeniesione tutaj:
http://tibiamod.xaa.pl/

Zapraszam.

Join the forum, it's quick and easy

Tibia Mod
Forum zostało Przeniesione tutaj:
http://tibiamod.xaa.pl/

Zapraszam.
Tibia Mod
Czy chcesz zareagować na tę wiadomość? Zarejestruj się na forum za pomocą kilku kliknięć lub zaloguj się, aby kontynuować.

[Action]System Piłki Nożnej

Go down

[Action]System Piłki Nożnej Empty [Action]System Piłki Nożnej

Pisanie by Sedron Nie Lis 11, 2012 3:46 pm

Witam.

Posiadam system Piłki Nożnej.

Instrukcja:

1.
a) W actrions/scripts tworzymy plik o nazwie: fut.lua i wpisujemy tam:


Kod:
</-- Script By Potreco =D -->
function onUse(cid,item,frompos,item2,topos)
pos1 = {x = 344,y = 248,z = 7}
pos2 = {x = 337,y = 248,z = 7}
poscentro2 = {x = 335,y = 242,z = 7}
poscentro1 = {x = 346,y = 242,z = 7}
idbola = 2160 -- Id do item que irá ser utilizado como bola
tempo = 2*60*1000 -- Tempo de duração de cada partida
outfit1 = {lookType = 128, lookHead =  94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookAddons = getCreatureOutfit(cid).lookAddons}--Outfit que o time 1 utilizará
outfit2 = {lookType = 128, lookHead =  0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = getCreatureOutfit(cid).lookAddons} --Outfit do time 2
time1 = getSpectators(pos1,2,0)
time2 = getSpectators(pos2,2,0)
if getGlobalStorageValue(20003) == -1 then
setGlobalStorageValue(20003,1)
      if time1 then
        for i = 1,#time1 do
            doSetCreatureOutfit(time1[i], outfit1,tempo)
            doTeleportThing(time1[i],poscentro1)
        end
      end
      if time2 then
        for i = 1,#time2 do
            doSetCreatureOutfit(time2[i], outfit2,tempo)
            doTeleportThing(time2[i],poscentro2)
        end
      end
      doCreateItem(idbola,poscentro1)
      doBroadcastMessage("Começa o jogo!")
      addEvent(function()
      players = getSpectators(poscentro1,12,5)
      if players ~= nil then
        for i = 1,#players do
            doTeleportThing(players[i],pos1)
        end
      end
      doBroadcastMessage("Fim de jogo! O placar foi de: Time 1 "..getGlobalStorageValue(20000).." x "..getGlobalStorageValue(20001).." Time 2")
      setGlobalStorageValue(20000,0)
      setGlobalStorageValue(20001,0)
setGlobalStorageValue(20003,-1)
      end,tempo)                           
end
return TRUE
end
b) Następnie dodajemy linijke do actions.xml

Kod:
<action actionid="5555" event="script" value="fut.lua"/>
2.
a) Wchodzimy w Movements/scripts i tworzymy nowy plik o nazwie: fut.lua i wpisujemy do niego:


Kod:
</-- Script By Potreco =D -->
function onAddItem(moveitem, tileitem, position, cid)
gol1 = {
{x=328,y=240,z=7},
{x=329,y=244,z=7}
}
gol2 = {
{x=352,y=240,z=7},
{x=353,y=244,z=7}
}
poscentro2 = {x = 335,y = 242,z = 7}
poscentro1 = {x = 346,y = 242,z = 7}
if inArea(position,gol1[1],gol1[2]) then
  doBroadcastMessage("Gol do time 1!")
  setGlobalStorageValue(20000,getGlobalStorageValue(20000) + 1)
  doRemoveItem(moveitem.uid)
  doCreateItem(moveitem.itemid,poscentro1)
elseif inArea(position,gol2[1], gol2[2]) then
  doBroadcastMessage("Gol do time 2!")
  setGlobalStorageValue(20001,getGlobalStorageValue(20001) + 1)
  doRemoveItem(moveitem.uid)
  doCreateItem(moveitem.itemid,poscentro2)
end
return true
end

function inArea(p,pos1,pos2)
        if p.x >= pos1.x and p.x <= pos2.x then
            if p.y >= pos1.y and p.y <= pos2.y then
              if p.z == pos1.z then
                return true
              end
            end
        end
return false
end
b) Następnie w movements.xml dopsujemy:

Kod:
<movevent type="AddItem" tileitem="0" itemid="2160" event="script" value="fut.lua"/>
I mamy gotowy skrypt.

Screen:

[Action]System Piłki Nożnej Imagemhhv

Boisko musicie zrobić sami w Map Edytorze. Pozdrawiam.
Sedron
Sedron
Admin

Liczba postów : 97
Join date : 11/11/2012

https://tibiamod.forumpl.net

Powrót do góry Go down

Powrót do góry

- Similar topics

 
Permissions in this forum:
Nie możesz odpowiadać w tematach