Postado Dezembro 21, 2014 10 anos Bom, há algo bem bacana em alguns jogos famosos, que lhe permite presentear um amigo. Como em League of Legends, não é bom dar de cara com uma skin ou um champion de presente? "Mas cara, o trade é pra isso." Não, não, a proposta é que seja algo de surpresa, ainda mais com o natal logo aí. Anyway, é bem simples, porém funcional. Tag 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 /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. /giveto Nogard, gold coin, 89, Merry Christmas! (: 20:31 You received 90 gold coin from Player. 20:31 Message: Merry Christmas! (: Respectfully, Player. É isso, see ya. Editado Dezembro 23, 2014 10 anos por Nogard (veja o histórico de edições)
Postado Dezembro 21, 2014 10 anos é possivel pelo Id do item? Tipo /giveto Player, 1260, 100 Muito bom, gostei REP +
Postado Dezembro 22, 2014 10 anos Ótimo sistema, meus parabéns ! (e REP+ claro) Mas do modo que você o criou, o player poderia mandar qualquer tranqueira para qualquer um, causando assim algumas intrigas... Sugiro algumas prevenções como: -Avisar o nome do player que o presenteou (assim o jogador poderia se vingar hahaha) -Colocar que único item possível de presentear alguém seja dinheiro -Enviar o presente à uma lista que o presenteado poderia acessar (dizendo por exemplo /presentlist, e escolher apenas alguns itens para receber) -Colocar uma taxa para presentear alguém -Fazer uma lista de possíveis presentes através de um comando ou NPC, assim como no League of Legends citado acima Mas de qualquer maneira ficou esplêndido ! Abraços :D ****EDIT**** Peço perdão pela primeira sugestão, não havia lido direito... Abraços Editado Dezembro 22, 2014 10 anos por Rumplestiltiskin (veja o histórico de edições)
Postado Dezembro 22, 2014 10 anos Fantástico o script Nogard! Uma duvida, eu gostaria de "incrementar" o script fazendo com que ao mandar o presente ele vá dentro de um tipo de BP que no caso seria o Present(id 1990) Ai exemplo: /giveto Player, gold coin, 100 O player iria receber 100 gold coins dentro de um Present(id 1990) como eu faria isso? Editado Dezembro 22, 2014 10 anos por Markin (veja o histórico de edições)
Postado Dezembro 22, 2014 10 anos Autor @Dieguiin XP Agora dá sim. @Rumplestiltiskin Realmente, haha. Agora os itens são configuráveis, já evita esse problema. Caso o item não esteja na lista, aparece o informativo. @Markin Pra isso você usaria: bag = doPlayerAddItem(getPlayerByName(Parâmetro1), Bag Id, 1) doAddContainerItem(bag, parâmetro2, parâmetro3) Adicionei o que os três queriam, e uma mensagem opcional ao mandar o item;/giveto Nogard, gold coin, 89, Merry Christmas! (: 20:31 You received 90 gold coin from Player.20:31 Message: Merry Christmas! (: Respectfully, Player. Dessa vez não fiz tão na correria. --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
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.