FI

Talkaction

Por Fir3element, 30 de mai. de 2011 em Scripts

script
8
1.6k
30 de maio de 2011 às 12:44

Alguem pode me ajudar a colocar assim:

 

Vocation 1 compra club e shield.

Vocation 2 compra sword, axe e shield.

Vocation 3 compra distance e shield.

 

No script a baixo qualquer pessoa pode comprar skills, paladin comprando sword e talzz...

 

rep+ pra quem ajuda

 

function onSay(cid, words, param, channel)
       local w = {
               item = 9971,
               count = 10
       }

               local pid = getPlayerGUID(cid)

       local id = {
               ["club"] = 1,
               ["sword"]= 2,
               ["axe"] = 3,
               ["distance"] = 4,
               ["shield"] = 5
       }

       if (param == '') then
          doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Como usar: !comprar club.")
          return true
       end


               if(id[param:lower()]) then
                       if(getPlayerSkill(cid, id[param:lower()]) < 350) then
                               if doPlayerRemoveItem(cid,w.item,w.count) then
                                       doRemoveCreature(cid, true)
                                       db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. w.count .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. id[param:lower()] ..";")
                               else
                                       doPlayerSendCancel(cid, "You do not have the required item.")
                               end
                       else            
                               doPlayerSendCancel(cid, "Skill's limit reached.")
                       end
               else
                       doPlayerSendCancel(cid, "Unknown skill.")
               end
return true
end

joaohdJ
30 de maio de 2011 às 23:02

Tente assim:

 

function onSay(cid, words, param, channel)
       local w = {
               item = 9971,
               count = 10
       }

               local pid = getPlayerGUID(cid)

       local id = {
               ["club"] = {vocation = {1}, id = 1},
               ["sword"]= {vocation = {2}, id = 2},
               ["axe"] = {vocation = {vocation = {2}, id = 3},
               ["distance"] = {vocation = {3}, id = 4},
               ["shield"] = {vocation = {1, 2, 3} id = 5}
       }

       if (param == '') then
          doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Como usar: !comprar club.")
          return true
       end


               if(id[param:lower()]) then
                       if(getPlayerSkill(cid, id[param:lower()]) < 350) then
                             if(isInArray(id[param:lower()].vocation(getPlayerVocation(cid))) then
                               if doPlayerRemoveItem(cid,w.item,w.count) then
                                       doRemoveCreature(cid, true)
                                       db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. w.count .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. id[param:lower()].id ..";")
                               else
                                       doPlayerSendCancel(cid, "You do not have the required item.")
                               end
                             else
                                doPlayerSendCancel(cid, "Voce não pode comprar este skill.")
                             end 
                       else            
                               doPlayerSendCancel(cid, "Skill's limit reached.")
                       end
               else
                       doPlayerSendCancel(cid, "Unknown skill.")
               end
return true
end

 

flw

31 de maio de 2011 às 14:28

deu erro nessa linha

 

["shield"] = {vocation = {1, 2, 3} id = 5}

 

expected near ´id´

SkyDangerousS
31 de maio de 2011 às 16:02

Eu revi esse bug ai que você disse ,eu nao entendo muito de lua , então eu acho que esse era o bug a falta das ,

 

Atual

["shield"] = {vocation = {1, 2, 3} id = 5}

 

Troque por

["shield"] = {vocation = {1, 2, 3}, id = 5},

 

Repare que irá dar outro bug:

input:17: '}' expected (to close '{' at line 9) near 'if'

 

Jájá eu atualizo , eu acho que é isso , pelo menos aqui paro de dar erro

Editado Maio 31 por SkyDangerous

joaohdJ
31 de maio de 2011 às 17:20

Falha minha. Correção:

 

function onSay(cid, words, param, channel)
       local w = {
               item = 9971,
               count = 10
       }

               local pid = getPlayerGUID(cid)

       local id = {
               ["club"] = {vocation = {1}, id = 1},
               ["sword"]= {vocation = {2}, id = 2},
               ["axe"] = {vocation = {2}, id = 3},
               ["distance"] = {vocation = {3}, id = 4},
               ["shield"] = {vocation = {1, 2, 3}, id = 5}
       }

       if (param == '') then
          doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Como usar: !comprar club.")
          return true
       end


               if(id[param:lower()]) then
                       if(getPlayerSkill(cid, id[param:lower()]) < 350) then
                             if(isInArray(id[param:lower()].vocation(getPlayerVocation(cid))) then
                               if doPlayerRemoveItem(cid,w.item,w.count) then
                                       doRemoveCreature(cid, true)
                                       db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. w.count .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. id[param:lower()].id ..";")
                               else
                                       doPlayerSendCancel(cid, "You do not have the required item.")
                               end
                             else
                                doPlayerSendCancel(cid, "Voce não pode comprar este skill.")
                             end 
                       else            
                               doPlayerSendCancel(cid, "Skill's limit reached.")
                       end
               else
                       doPlayerSendCancel(cid, "Unknown skill.")
               end
return true
end

 

 

flw

1 mês depois...
19 de junho de 2011 às 10:25

fiquei fora por um tempo

 

deu erro na linha 25

 

expected near `then`

joaohdJ
19 de junho de 2011 às 20:43

Tente:

 

function onSay(cid, words, param, channel)
       local w = {
               item = 9971,
               count = 10
       }

               local pid = getPlayerGUID(cid)

       local id = {
               ["club"] = {vocation = {1}, id = 1},
               ["sword"]= {vocation = {2}, id = 2},
               ["axe"] = {vocation = {2}, id = 3},
               ["distance"] = {vocation = {3}, id = 4},
               ["shield"] = {vocation = {1, 2, 3}, id = 5}
       }

       if (param == '') then
          doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Como usar: !comprar club.")
          return true
       end


               if(id[param:lower()]) then
                       if(getPlayerSkill(cid, id[param:lower()]) < 350) then
                             if(isInArray(id[param:lower()].vocation(getPlayerVocation(cid)))) then
                               if doPlayerRemoveItem(cid,w.item,w.count) then
                                       doRemoveCreature(cid, true)
                                       db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. w.count .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. id[param:lower()].id ..";")
                               else
                                       doPlayerSendCancel(cid, "You do not have the required item.")
                               end
                             else
                                doPlayerSendCancel(cid, "Voce não pode comprar este skill.")
                             end 
                       else            
                               doPlayerSendCancel(cid, "Skill's limit reached.")
                       end
               else
                       doPlayerSendCancel(cid, "Unknown skill.")
               end
return true
end

 

flw

26 de junho de 2011 às 20:36

Deu um errozinho, separei as voc dos id e fiz me baseando na linha do id :)

 

valeu ai pela ajuda