Ir para conteúdo

[TalkAction] Give a Present!


Nogard

Posts Recomendados

Há algo bem bacana em alguns jogos famosos, que lhe permite presentear um amigo com certos itens. Como em League of Legends, não é bom dar de cara com uma skin ou um champion de presente? Agora você pode ter algo similar em seu servidor.

 

 

 

 

 

talkactions.xml:

<talkaction words="/giveto" event="script" value="arquivo.lua"/>

 

arquivo.lua:

--Give a present!--function onSay (cid, words, param)    local  s = string.explode(param, ",")  if (param == "") then     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Param required.")       return true             end              if not isPlayer(getPlayerByNameWildcard(s[1])) then         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")           return true               end                              if s[1] == getCreatureName(cid) then                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give yourself.")               return true                     end                                             if   s[3] == nil or s[3] == "" or s[2] == nil then                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Write the item and value.")                return true                       end                              --                                local arr = {        items = {2148,           -- Items possible to give         2160,          2463},         }                    local g = "Items that you can give:\n\n"..getItemNameById(arr.items[1]).."\nDescription: A coin made of gold, nice present.\n\n"..          getItemNameById(arr.items[2]).."\nDescription: ~~~~~~~~~\n\n"                    --[[-- For add more descriptions, copy this:                    ..getItemNameById(arr.items[Position of value in array]).."\n Description: ~~~~~~~~~\n\n"                      ]]--                                                 if not isNumber(s[2]) then                                               if isInArray(arr.items, getItemIdByName(s[2]))  then                                                  if (doPlayerRemoveItem(cid, getItemIdByName(s[2]), s[3]) == true) then                         local bag = doPlayerAddItem(getPlayerByName(s[1]), 1990, 1)                                        doAddContainerItem(bag, getItemIdByName(s[2]), s[3])          doSendAnimatedText(getCreaturePosition(cid), "Sucess!", COLOR_GREEN)           doPlayerSendTextMessage(getPlayerByNameWildcard(s[1]), MESSAGE_STATUS_CONSOLE_ORANGE, "You received "..s[3].." "..s[2].." from "..getCreatureName(cid)..".")            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You gave "..s[3].." "..s[2].." to "..s[1]..".")             doSendMagicEffect(getCreaturePosition(getPlayerByName(s[1])), 28)                            if s[4] ~= nil then                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Message: "..s[4].."\n                Respectfully, "..getCreatureName(cid)..".")                  else                               return true                   end                                              else     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You dont have this ammount.")       return true         end                     else               doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give this item. Please, check list.")                 doShowTextDialog(cid, 2105, g)                       return true                         end                    return true         end                  ---                                        if  isInArray(arr.items, s[2])  then                        if (doPlayerRemoveItem(cid, s[2], s[3])== true) then                        local bag = doPlayerAddItem(getPlayerByName(s[1]), 1990, 1)                   doAddContainerItem(bag, s[2], s[3])         doSendAnimatedText(getCreaturePosition(cid), "Sucess!", COLOR_GREEN)            doPlayerSendTextMessage(getPlayerByNameWildcard(s[1]), MESSAGE_STATUS_CONSOLE_ORANGE, "You received "..s[3].." "..getItemNameById(s[2]).." from "..getCreatureName(cid)..".")              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You gave "..s[3].." "..getItemNameById(s[2]).." to "..s[1]..".")                doSendMagicEffect(getCreaturePosition(getPlayerByName(s[1])), 28)                          if s[4] ~= nil then                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Message: "..s[4].."\n                Respectfully, "..getCreatureName(cid)..".")                 else                  return true                   end                                 else                  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You dont have this ammount.")                 return true                    end                                         else                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give this item. Please, check list.")                     doShowTextDialog(cid, 2105, g)                    return true                    end                                             return true            end 

 

 

Exemplos de uso, você tem a opção de adicionar uma frase que será visualizada por quem receber o presente:

 

 

sem frase: /giveto Player, gold coin (or item id), 41

 

15:25 You give 41 gold coin to Player.

15:25 You received 41 gold coin from Nogard.

 

 

 

com frase: /giveto Nogard, gold coin, 89, Merry Christmas! (:

 

20:31 You received 90 gold coin from Player.

20:31 Message: Merry Christmas! (:

Respectfully, Player.

 

 

 

Você também precisará configurar quais itens poderão ser enviados, como prevenção do envio de itens inúteis por qualquer um:

 

local arr = {        items = {2148,           -- Items possible to give         2160,          2463},         }

 

 

É isso.

 

 

 

 

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

  • 2 weeks later...
Em 20/07/2017 at 07:36, Nogard disse:

Há algo bem bacana em alguns jogos famosos, que lhe permite presentear um amigo com certos itens. Como em League of Legends, não é bom dar de cara com uma skin ou um champion de presente? Agora você pode ter algo similar em seu servidor.

 

 

 

 

 

talkactions.xml:

<talkaction words="/giveto" event="script" value="arquivo.lua"/>

 

arquivo.lua:

--Give a present!--function onSay (cid, words, param)    local  s = string.explode(param, ",")  if (param == "") then     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Param required.")       return true             end              if not isPlayer(getPlayerByNameWildcard(s[1])) then         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")           return true               end                              if s[1] == getCreatureName(cid) then                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give yourself.")               return true                     end                                             if   s[3] == nil or s[3] == "" or s[2] == nil then                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Write the item and value.")                return true                       end                              --                                local arr = {        items = {2148,           -- Items possible to give         2160,          2463},         }                    local g = "Items that you can give:\n\n"..getItemNameById(arr.items[1]).."\nDescription: A coin made of gold, nice present.\n\n"..          getItemNameById(arr.items[2]).."\nDescription: ~~~~~~~~~\n\n"                    --[[-- For add more descriptions, copy this:                    ..getItemNameById(arr.items[Position of value in array]).."\n Description: ~~~~~~~~~\n\n"                      ]]--                                                 if not isNumber(s[2]) then                                               if isInArray(arr.items, getItemIdByName(s[2]))  then                                                  if (doPlayerRemoveItem(cid, getItemIdByName(s[2]), s[3]) == true) then                         local bag = doPlayerAddItem(getPlayerByName(s[1]), 1990, 1)                                        doAddContainerItem(bag, getItemIdByName(s[2]), s[3])          doSendAnimatedText(getCreaturePosition(cid), "Sucess!", COLOR_GREEN)           doPlayerSendTextMessage(getPlayerByNameWildcard(s[1]), MESSAGE_STATUS_CONSOLE_ORANGE, "You received "..s[3].." "..s[2].." from "..getCreatureName(cid)..".")            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You gave "..s[3].." "..s[2].." to "..s[1]..".")             doSendMagicEffect(getCreaturePosition(getPlayerByName(s[1])), 28)                            if s[4] ~= nil then                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Message: "..s[4].."\n                Respectfully, "..getCreatureName(cid)..".")                  else                               return true                   end                                              else     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You dont have this ammount.")       return true         end                     else               doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give this item. Please, check list.")                 doShowTextDialog(cid, 2105, g)                       return true                         end                    return true         end                  ---                                        if  isInArray(arr.items, s[2])  then                        if (doPlayerRemoveItem(cid, s[2], s[3])== true) then                        local bag = doPlayerAddItem(getPlayerByName(s[1]), 1990, 1)                   doAddContainerItem(bag, s[2], s[3])         doSendAnimatedText(getCreaturePosition(cid), "Sucess!", COLOR_GREEN)            doPlayerSendTextMessage(getPlayerByNameWildcard(s[1]), MESSAGE_STATUS_CONSOLE_ORANGE, "You received "..s[3].." "..getItemNameById(s[2]).." from "..getCreatureName(cid)..".")              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You gave "..s[3].." "..getItemNameById(s[2]).." to "..s[1]..".")                doSendMagicEffect(getCreaturePosition(getPlayerByName(s[1])), 28)                          if s[4] ~= nil then                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Message: "..s[4].."\n                Respectfully, "..getCreatureName(cid)..".")                 else                  return true                   end                                 else                  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You dont have this ammount.")                 return true                    end                                         else                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give this item. Please, check list.")                     doShowTextDialog(cid, 2105, g)                    return true                    end                                             return true            end 

 

 

Exemplos de uso, você tem a opção de adicionar uma frase que será visualizada por quem receber o presente:

 

 

sem frase: /giveto Player, gold coin (or item id), 41

 

15:25 You give 41 gold coin to Player.

15:25 You received 41 gold coin from Nogard.

 

 

 

com frase: /giveto Nogard, gold coin, 89, Merry Christmas! (:

 

20:31 You received 90 gold coin from Player.

20:31 Message: Merry Christmas! (:

Respectfully, Player.

 

 

 

Você também precisará configurar quais itens poderão ser enviados, como prevenção do envio de itens inúteis por qualquer um:

 

local arr = {        items = {2148,           -- Items possible to give         2160,          2463},         }

 

 

É isso.

 

 

 

 

esses presentes vão pra onde? dp? player??

e se o player estiver offfline? recebe do mesmo jeito?

Link para o comentário
Compartilhar em outros sites

Em 2017-8-3 at 20:50, wevertonvrb disse:

esses presentes vão pra onde? dp? player??

e se o player estiver offfline? recebe do mesmo jeito?

 

Para o inventário dentro de uma bag. Não vão pro dp. Não recebe offline.

Link para o comentário
Compartilhar em outros sites

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...