Postado Agosto 26, 2017 7 anos Um npc que venda itens determinados a partir de X quantidade de um sistema de points eventos. Um action que possa ser usado em um item para ganhar points, pontos de eventos, e que a quantidade seja aleatória, Podendo ganhar entre. (o item some com um efeito no char) 15, 30, 50, 75 e 100 pontos. (Eu não tenho um sistema de pontos de eventos, então se puder fazer uma coisa básica), até porque esse item só sera dado aos vencedores dos eventos Editado Agosto 26, 2017 7 anos por JcA (veja o histórico de edições)
Postado Agosto 26, 2017 7 anos Solução Action: Mostrar conteúdo oculto local points = {15, 30, 50, 75, 100} function onUse(cid, item, fromPosition, itemEx, toPosition) if getPlayerStorageValue(cid, 92431) == -1 then setPlayerStorageValue(cid, 92431, 0) end doPlayerAddEventPoints(cid, points[math.random(1, #points)]) doRemoveItem(item.uid) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_STUN) return true end function doPlayerAddEventPoints(cid, amount) local current = getPlayerStorageValue(cid, 92431) setPlayerStorageValue(cid, 92431, current + amount) return true end Em actions.xml: <action itemid="ID_DO_ITEM" event="script" value="NOMEDOARQUIVO.lua"/> NPC: Mostrar conteúdo oculto local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid local shopWindow = {} local t = { [1111] = {buyprice = 1}, [2222] = {buyprice = 10}, [3333] = {buyprice = 3} } function doPlayerRemoveEventPoints(cid, amount) local current = getPlayerStorageValue(cid, 92431) if current - amount < 0 then return false else setPlayerStorageValue(cid, 92431, current - amount) end return true end local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] and doPlayerRemoveEventPoints(cid, t[item].buyprice) then doPlayerAddItem(cid, item) selfSay("Here you go.", cid) else selfSay("Você não tem "..t[item].buyprice.." points.", cid) end return true end if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then for var, ret in pairs(t) do table.insert(shopWindow, {id = var, subType = 0, buy = ret.buyprice, sell = 0, name = getItemNameById(var)}) end openShopWindow(cid, shopWindow, onBuy, onSell) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Agosto 27, 2017 7 anos Autor Em 26/08/2017 em 23:57, Dwarfer disse: Action: Mostrar conteúdo oculto Mostrar conteúdo oculto local points = {15, 30, 50, 75, 100} function onUse(cid, item, fromPosition, itemEx, toPosition) if getPlayerStorageValue(cid, 92431) == -1 then setPlayerStorageValue(cid, 92431, 0) end doPlayerAddEventPoints(cid, points[math.random(1, #points)]) doRemoveItem(item.uid) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_STUN) return true end function doPlayerAddEventPoints(cid, amount) local current = getPlayerStorageValue(cid, 92431) setPlayerStorageValue(cid, 92431, current + amount) return true end Em actions.xml: <action itemid="ID_DO_ITEM" event="script" value="NOMEDOARQUIVO.lua"/> NPC: Mostrar conteúdo oculto Mostrar conteúdo oculto local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid local shopWindow = {} local t = { [1111] = {buyprice = 1}, [2222] = {buyprice = 10}, [3333] = {buyprice = 3} } function doPlayerRemoveEventPoints(cid, amount) local current = getPlayerStorageValue(cid, 92431) if current - amount < 0 then return false else setPlayerStorageValue(cid, 92431, current - amount) end return true end local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] and doPlayerRemoveEventPoints(cid, t[item].buyprice) then doPlayerAddItem(cid, item) selfSay("Here you go.", cid) else selfSay("Você não tem "..t[item].buyprice.." points.", cid) end return true end if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then for var, ret in pairs(t) do table.insert(shopWindow, {id = var, subType = 0, buy = ret.buyprice, sell = 0, name = getItemNameById(var)}) end openShopWindow(cid, shopWindow, onBuy, onSell) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) @Dwarfer Funcionou, mas você poderia dar uma olhada? Eu esqueci de citar uma função, então incrementei uma linha que mostra uma mensagem exibindo a quantidade de pontos que ganha, porém só mostra que ganhou "5 pontos", sendo que não tem essa quantidade kkkkk local points = {15, 30, 50, 75, 100} function onUse(cid, item, fromPosition, itemEx, toPosition) if getPlayerStorageValue(cid, 92431) == -1 then setPlayerStorageValue(cid, 92431, 0) end doPlayerAddEventPoints(cid, points[math.random(1, #points)]) doCreatureSay(cid, "Parabéns! Você recebeu ".. #points .." Event Points!", TALKTYPE_ORANGE_1) doRemoveItem(item.uid) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_STUN) return true end function doPlayerAddEventPoints(cid, amount) local current = getPlayerStorageValue(cid, 92431) setPlayerStorageValue(cid, 92431, current + amount) return true end
Postado Agosto 27, 2017 7 anos local points = {15, 30, 50, 75, 100} function onUse(cid, item, fromPosition, itemEx, toPosition) if getPlayerStorageValue(cid, 92431) == -1 then setPlayerStorageValue(cid, 92431, 0) end rand = points[math.random(1, #points)] doPlayerAddEventPoints(cid, rand) doCreatureSay(cid, "Parabéns! Você recebeu " .. rand .. " Event Points!", TALKTYPE_ORANGE_1) doRemoveItem(item.uid) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_STUN) return true end function doPlayerAddEventPoints(cid, amount) local current = getPlayerStorageValue(cid, 92431) setPlayerStorageValue(cid, 92431, current + amount) return true end
Postado Setembro 3, 2017 7 anos @Dwarfer pode criar um comando /eventpoints para mostrar quantos pontos possuo? E um sistema que converte os pontos em item agrupado, que seria tipo o ID: 6527 que é agrupavel. !converteventpoints Então se eu tiver 15 pontos, vai virar 15 itens, e o mesmo serve pra comprar no npc? Editado Setembro 7, 2017 7 anos por mistermie (veja o histórico de edições)
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.