Ir para conteúdo
Entre para seguir isso  
Gpwjhlkdcf

Tópico do POG!!

Recommended Posts

Gpwjhlkdcf    21
Gpwjhlkdcf

Tópico do POG

 

POG = Programação Orientada a Gambiarras (Clique aqui e saiba mais!)

 

Postem aqui seus POGs e comentem sobre o POG dos outros, e tentem não floodar. Exceto o Flatronez. 90% deste tópico será de posts dele.

 

Vou começar com um POG que eu acabei de fazer:

function onCastSpell(cid, var)
 for i, v in pairs(var) do
     if type(v) == "table" then
         for x, y in pairs(v) do
             if type(y) == "table" then
               doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Multiple tables!")
             else
               doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, i.." | y: "..x..", "..y)
             end
         end
     else
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "v: "..i..", "..v)
     end
 end
 return doSendMagicEffect(var.pos, CONST_ME_POFF)
end

 

Motivo disto? Eu queria saber quais mistérios a variavel "var" guardava consigo, pois eu já estava ficando frustrado! O POG funcionou, veja só o resultado in-game: :D

16:57 pos | y: y, 136

16:57 pos | y: x, 140

16:57 pos | y: stackpos, 0

16:57 pos | y: z, 7

16:57 v: type, 2

 

Postem os seus!

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Magus    2
Magus

function mapRoute(cid,f,t)
   local route,pos,inv = {f}

   if (f.x > t.x and f.y < t.y) then
       inv = true
       t.x,f.x,t.y,f.y = f.x,t.x,f.y,t.y
   end

   for x = f.x, t.x do
       for y = f.y, t.y do
           pos = {x=x,y=y,z=f.z}
           if (doTileQueryAdd(cid, pos) == 1) then
               table.insert(route, pos)
           end
       end
   end

   table.sort(route, function(a,
       local c = t.x + t.y
       return a.x + a.y - c < b.x + b.y - c
   end)

   local function posExists(pos)
       local comp = {
           __eq = function(v1,v2)
               return v1.x == v2.x and v1.y == v2.y and v1.z == v2.z
           end
       }
       setmetatable(pos, comp)
       for i, v in pairs(route) do
           setmetatable(v, comp)
           if (pos == v) then return i end
       end
       return
   end

   for i, v in pairs(route) do
       local ret = {
           a = {
               {x=v.x+1,y=v.y,z=v.z},
               {x=v.x,y=v.y+1,z=v.z},
               {x=v.x+1,y=v.y+1,z=v.z}
           },
           b = {
               {x=v.x-1,y=v.y,z=v.z},
               {x=v.x,y=v.y-1,z=v.z},
               {x=v.x-1,y=v.y-1,z=v.z}
           }
       }
       local ret = inv and ret.b or ret.a
       for t = 1, #ret do
           cont = posExists(ret[t])
           if cont then
               for i = i+1, cont-1 do route[i] = nil end
               break
           end
       end
   end

   return route
end

 

Não deu tão certo quanto eu esperava, haha. Faz tempo que tá parada aqui >_>

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Addicted    1
Addicted
function mapRoute(cid,f,t)
   local route,pos,inv = {f}

   if (f.x > t.x and f.y < t.y) then
       inv = true
       t.x,f.x,t.y,f.y = f.x,t.x,f.y,t.y
   end

   for x = f.x, t.x do
       for y = f.y, t.y do
           pos = {x=x,y=y,z=f.z}
           if (doTileQueryAdd(cid, pos) == 1) then
               table.insert(route, pos)
           end
       end
   end

   table.sort(route, function(a,
       local c = t.x + t.y
       return a.x + a.y - c < b.x + b.y - c
   end)

   local function posExists(pos)
       local comp = {
           __eq = function(v1,v2)
               return v1.x == v2.x and v1.y == v2.y and v1.z == v2.z
           end
       }
       setmetatable(pos, comp)
       for i, v in pairs(route) do
           setmetatable(v, comp)
           if (pos == v) then return i end
       end
       return
   end

   for i, v in pairs(route) do
       local ret = {
           a = {
               {x=v.x+1,y=v.y,z=v.z},
               {x=v.x,y=v.y+1,z=v.z},
               {x=v.x+1,y=v.y+1,z=v.z}
           },
           b = {
               {x=v.x-1,y=v.y,z=v.z},
               {x=v.x,y=v.y-1,z=v.z},
               {x=v.x-1,y=v.y-1,z=v.z}
           }
       }
       local ret = inv and ret.b or ret.a
       for t = 1, #ret do
           cont = posExists(ret[t])
           if cont then
               for i = i+1, cont-1 do route[i] = nil end
               break
           end
       end
   end

   return route
end

 

Não deu tão certo quanto eu esperava, haha. Faz tempo que tá parada aqui >_>

Eu achando que ia ficar anos lendo seus pogs. Só postou um né safado.

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Mock    32
Mock

Meu maior pog...

O meu IRC bot eu tentei fazer ele verificar se o ot tava on

porem nao consegi entao apelei pro pog. fui no apache abri ele criei uma pagina que veirfica ots e pronto :D

oia o code ai:

(SO FIZ PQ JA TAVA COM UM SOCKET E ABERTO E N SEI PQ QDO EU ABRIA OTRO O SERVER N RESPONDIA ._.')

Pogpowered2.gif

function onIRCRecieve(msg,sender,msg_total,param)
if param == nil or string.len(param) <= 0 then
 botSendNotice(sender,"Mande o comando corretamente!")
return FALSE
end
botSendNotice(sender,'21,155[12Verificando aguarde...5]')

http = require("socket.http")
b, c, h = http.request("http://localhost:7172/teste/index.php?subtopic="..param.."")
if b == "offline" then
   botSendMsg("0,1415<1> Server 15%0,18"..param.."0:1371710,1415%0,512[4Offline12]0,140,1415<1>")
return TRUE
end
botSendMsg("0,1415<1> Server 15%0,18"..param.."0:1371710,1415%0,312[9Online12]0,140,1415<1>")
b = string.explode(b,'€')
print(b[1],b[2])
for i=1,7 do
   b[i] = b[i] or "Information falied"
   string.gsub(b[i],"\n","")
   string.gsub(b[i],"/n","")
end
botSendMsg(b[1]..", "..b[2]..", "..b[3]..", "..b[4]..", "..b[5]..", "..b[6]..".")
botSendMsg(b[7])
return TRUE
end

Pogpowered2.gif

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Gpwjhlkdcf    21
Gpwjhlkdcf
Meu maior pog...

O meu IRC bot eu tentei fazer ele verificar se o ot tava on

porem nao consegi entao apelei pro pog. fui no apache abri ele criei uma pagina que veirfica ots e pronto :D

oia o code ai:

function onIRCRecieve(msg,sender,msg_total,param)
if param == nil or string.len(param) <= 0 then
 botSendNotice(sender,"Mande o comando corretamente!")
return FALSE
end
botSendNotice(sender,'21,155[12Verificando aguarde...5]')

http = require("socket.http")
b, c, h = http.request("http://localhost:7172/teste/index.php?subtopic="..param.."")
if b == "offline" then
   botSendMsg("0,1415<1> Server 15%0,18"..param.."0:1371710,1415%0,512[4Offline12]0,140,1415<1>")
return TRUE
end
botSendMsg("0,1415<1> Server 15%0,18"..param.."0:1371710,1415%0,312[9Online12]0,140,1415<1>")
b = string.explode(b,'€')
print(b[1],b[2])
for i=1,7 do
   b[i] = b[i] or "Information falied"
   string.gsub(b[i],"\n","")
   string.gsub(b[i],"/n","")
end
botSendMsg(b[1]..", "..b[2]..", "..b[3]..", "..b[4]..", "..b[5]..", "..b[6]..".")
botSendMsg(b[7])
return TRUE
end

EPIC POG!

 

Esse merece: Pogpowered2.gif

 

Puts, esse humilhou o meu e o do Magus juntos... '-'

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Gpwjhlkdcf    21
Gpwjhlkdcf
Participem:

 

http://forums.otserv.com.br/group.php?groupid=310 ...

 

Se eu for postar pog meu aqui nem vai dar... Tudo que eu faço é na base da gambiarra.

 

Não tem problema, o Flatronez também.

Pode postar, o tópico tá aqui pra isso.

 

Aproveitando a oportunidade deste comentário, la vai mais um POG meu. Dessa vez é um POG pra ver se um POG funciona:

function isFunctional(func, ...)
 status, error = pcall(func, ...)
   if error then
     return false
   end
 return true
end

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Gpwjhlkdcf    21
Gpwjhlkdcf

Mais um POG fresquinho pra vocês:

 

A função getItemWeaponType não funciona com Bows, CrossBows, etc...

 

Então, apelemos para o POG:

function isRanged(item)
   if item.itemid > 0 and getItemShootRange(item.uid) > 0 then
       return true
   end
 return false
end

getItemWeaponType_ = getItemWeaponType
function getItemWeaponType(item)
   if isRanged(item) then
     return 5
   end
 return getItemWeaponType_(item)
end

 

Apreciem com moderação... :)

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Fadi    0
Fadi

Wow, "POG" é boa xD

 

local fluidContainers = {2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2023,1775,2031,2032,2033,2034,2574,2575,2576,2577}
function doPotion(cid, item, item2,frompos, base,ingredients, types, actionids, effect, finisheffect)
   local potid = 2562
   local failtype = 15
   local faileffect = 2
   for x = 0, table.maxn(fluidContainers) do
       if item2.itemid == fluidContainers[x] then
           if item2.type == 0 then
               if item.type ~= 0 then
                   doChangeTypeItem(item2.uid,item.type)
                   doChangeTypeItem(item.uid,0)
                   check = 1
               end
           else
               doPlayerPopupFYI(cid,"There is already something in this fluid container")
           end
       end
   end
   if item.itemid == potid then
       if item.type == base then
           if types.first ~= 0 then
               doSetItemActionId(item.uid,actionids.first)
               if item2.itemid == ingredients.first then
                   doRemoveItem(item2.uid,1)
                   doSendMagicEffect(frompos,effect)
                   doChangeTypeItem(item.uid,types.first)
                   if types.second ~= 0 then
                       doSetItemActionId(item.uid,actionids.first)
                   else
                       doSetItemActionId(item.uid,actionids.final)
                   end
               else
                   if check ~= 1 then
                       doPlayerPopupFYI(cid,"This is not the right ingredient")
                       doSendMagicEffect(frompos,faileffect)
                   end
               end
           elseif types.first == 0 and types.second ~= 0 then
               if item2.itemid == ingredients.second then
                   doRemoveItem(item2.uid,1)
                   doSendMagicEffect(frompos,effect)
                   doChangeTypeItem(item.uid,types.second)
                   doSetItemActionId(item.uid,actionids.final)
               else
                   if check ~= 1 then
                       doPlayerPopupFYI(cid,"This is not the right ingredient")
                       doSendMagicEffect(frompos,faileffect)
                   end
               end
           elseif types.first == 0 and types.second == 0 then
               if item2.itemid == ingredients.final then
                   doRemoveItem(item2.uid,1)
                   doSendMagicEffect(frompos,finisheffect)
                   doChangeTypeItem(item.uid,types.final)
                   doPlayerSendTextMessage(cid,22, "You have finished the potion!" )
               else
                   if check ~= 1 then
                       doPlayerPopupFYI(cid,"This is not the right ingredient")
                       doSendMagicEffect(frompos,faileffect)
                   end
               end
           end
       elseif item.type ~= types.base and item.actionid == actionids.first then
           if item2.itemid == ingredients.second then
               doRemoveItem(item2.uid,1)
               doSendMagicEffect(frompos,effect)
               doChangeTypeItem(item.uid,types.second)
               doSetItemActionId(item.uid,actionids.final)
           else
               if check ~= 1 then
                   doPlayerPopupFYI(cid,"This is not the right ingredient")
                   doSendMagicEffect(frompos,faileffect)
               end
           end
       elseif item.type ~= types.base and item.actionid == actionids.final then
           if item2.itemid == ingredients.final then
               doRemoveItem(item2.uid,1)
               doSendMagicEffect(frompos,finisheffect)
               doChangeTypeItem(item.uid,types.final)
               doPlayerSendTextMessage(cid, 22, "You have finished the potion!" )
           else
               if check ~= 1 then
                   doPlayerPopupFYI(cid,"This is not the right ingredient")
                   doSendMagicEffect(frompos,faileffect)
               end
           end
       end
   else
       print('Action object is not valid to this function')
   end
end

function onUse(cid, item, frompos, item2, topos)
ingredients = {first = 5879, second = 5881, final = 5883}
types = {first = 3, second = 4, final = 5}
actionids = {first = 60758, final = 60759}
base = 2
effect = 12
finaleffect = 21
doPotion(cid, item, item2, frompos, base, ingredients, types, actionids, effect, finaleffect)
end

 

Essa droga nunca funcionou direito u.u

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Eventide    7
Eventide

table.maxn foi abolida =(

Compartilhar este post


Link para o post
Compartilhar em outros sites
Nord    2
Nord

Fadi, sua doPotion nunca funcionou, eu fiz uma pra vc e nunca usa :o

Quanto eu não conhecia a função queryTileAddThing eu decidi fazer uma função pra ver se tal posição dava pra andar ou não e acabou saindo a isWalkable, eu demorei +- 1 semana pra fazer a primeira versão, essa é a versão atual dela:

function isWalkable(pos, creature, proj, pz)
pos.stackpos = 0
if getTileThingByPos(pos).uid == 0 then return FALSE end
if getTopCreature(pos).uid > 0 and creature == TRUE then return FALSE end
if getTileInfo(pos).protection == TRUE and (pz == 1 or pz == nil) then return FALSE end
local n = (proj == nil or proj == 0) and 3 or 2
for i = 0, 50 do
	pos.stackpos = i
	local tile = getTileThingByPos(pos)
	if tile.itemid ~= 0 and isCreature(tile.uid) == FALSE then
		if (hasProperty(tile.uid, n) == TRUE or hasProperty(tile.uid, 7) == TRUE) then
			return FALSE
		end
	end
end
return TRUE
end

 

Até hoje acredito que fiz essa função por estar realmente no aperto, na época eu precisei dela pra uma spell que empurrava players.

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Mock    32
Mock

Nord... Vc merece

Pog powered!

meu utimo pog:

http://www.lua.pastey.net/130403-5b9x

Editado por Mock

Compartilhar este post


Link para o post
Compartilhar em outros sites
Gpwjhlkdcf    21
Gpwjhlkdcf

OBS: O script NÃO é meu '-'

 

Observem que ele inocentemente cria seu próprio sistema de linhas, já que a droga do bloco de notas não possui um contador. Que droga em bloco de notas!

[...]

--[[4]] coisaid = 2556

--[[5]] coisapos = {x=xxx, y=yyy, z=z, stackpos=2}

--[[6]] coisa = getThingFromPos(coisapos)

--[[7]] storage = 1518

--[[8]]

--[[9]] if (item.itemid == 1945) then

--[[10]] if (getPlayerStorageValue(cid,storage) == -1) then

--[[11]] if (coisa.itemid == coisaid) then

--[[12]] doSendMagicEffect(coisa,1)

--[[13]] doTeleportThing(cid,npos)

[...]

Juro que chorei por 10 minutos a fio de tanto rir.

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Eventide    7
Eventide

ri litros desses 2 ultimos POGs, o do Mock é ainda mais cabuloso...(e desnecessário)

Compartilhar este post


Link para o post
Compartilhar em outros sites
Ramza    11
Ramza
OBS: O script NÃO é meu '-'

 

Observem que ele inocentemente cria seu próprio sistema de linhas, já que a droga do bloco de notas não possui um contador. Que droga em bloco de notas!

 

[...]
--[[4]]  coisaid = 2556
--[[5]]  coisapos = {x=xxx, y=yyy, z=z, stackpos=2}
--[[6]]  coisa = getThingFromPos(coisapos)
--[[7]]  storage = 1518
--[[8]]
--[[9]]     if (item.itemid == 1945) then
--[[10]]        if (getPlayerStorageValue(cid,storage) == -1) then
--[[11]]             if (coisa.itemid == coisaid) then
--[[12]]                 doSendMagicEffect(coisa,1)
--[[13]]                 doTeleportThing(cid,npos)
[...] 			 		

 

Juro que chorei por 10 minutos a fio de tanto rir.

Putz, esse merece ser revivido!

Ri por meia hora também disso, OMG!

Epic Gambiarra! DHUSADHUHDSAAHUDHUSAAHUDAHUDHASUDSAHDUSHDUD

Merece um beijo do notorious HDUSAHDUHAUSDSADASHDUSADHA

Editado por Mickfern

Compartilhar este post


Link para o post
Compartilhar em outros sites
Notorious    1
Notorious
Merece um beijo do notorious HDUSAHDUHAUSDSADASHDUSADHA

:viado:

Editado por Notorious

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×