Postado Setembro 20, 2017 7 anos Qual é o erro torpe aqui na talk? local id = 9020 function onSay(cid, words, param, channel) local points = getPlayerPoints(cid, 45452) if points <= 0 then return true end doPlayerRemovePoints(cid, points) else doCreatureSay(cid, "You do not have donate points.", TALKTYPE_ORANGE_1) doPlayerAddPoints(cid, id, points) doCreatureSay(cid, "You converted points into coins", TALKTYPE_ORANGE_1) return true end function doPlayerRemovePoints(cid, amount) local current = getPlayerStorageValue(cid, 45452) if current - amount < 0 then return false else setPlayerStorageValue(cid, 45452, current - amount) end return true end E na Action: function onUse(cid, item, fromPosition, itemEx, toPosition) doPlayerAddEventPoints(cid, item.type) doRemoveItem(item.uid) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREATTACK) doSendAnimatedText(getPlayerPosition(cid), "d-coins", TEXTCOLOR_YELLOW) return true end function doPlayerAddEventPoints(cid, amount) local current = getPlayerStorageValue(cid, 45452) setPlayerStorageValue(cid, 45452, current + amount) return true end System
Postado Setembro 20, 2017 7 anos Solução Em 20/09/2017 em 01:36, JcA disse: Qual é o erro torpe aqui na talk? local id = 9020 function onSay(cid, words, param, channel) local points = getPlayerPoints(cid, 45452) if points <= 0 then return true end doPlayerRemovePoints(cid, points) else doCreatureSay(cid, "You do not have donate points.", TALKTYPE_ORANGE_1) doPlayerAddPoints(cid, id, points) doCreatureSay(cid, "You converted points into coins", TALKTYPE_ORANGE_1) return true end function doPlayerRemovePoints(cid, amount) local current = getPlayerStorageValue(cid, 45452) if current - amount < 0 then return false else setPlayerStorageValue(cid, 45452, current - amount) end return true end E na Action: function onUse(cid, item, fromPosition, itemEx, toPosition) doPlayerAddEventPoints(cid, item.type) doRemoveItem(item.uid) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREATTACK) doSendAnimatedText(getPlayerPosition(cid), "d-coins", TEXTCOLOR_YELLOW) return true end function doPlayerAddEventPoints(cid, amount) local current = getPlayerStorageValue(cid, 45452) setPlayerStorageValue(cid, 45452, current + amount) return true end System Que mistureba foi essa que você fez, cara? Você tá confundindo os scripts, pegando parte de um e colocando no outro. Para ESSE sistema que você colocou aí: Mostrar conteúdo oculto local id = 9020 function onSay(cid, words, param, channel) local points = getPlayerPoints(cid) if points <= 0 then return true end doPlayerAddItem(cid, id, points) doPlayerRemovePoints(cid, points) doCreatureSay(cid, "You converted points into coins", TALKTYPE_ORANGE_1) return true end ------- ACTION function onUse(cid, item, fromPosition, itemEx, toPosition) doPlayerAddPoints(cid, item.type) doRemoveItem(item.uid) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREATTACK) doSendAnimatedText(getPlayerPosition(cid), "d-coins", TEXTCOLOR_YELLOW) return true end Contato: Email: dwarfer@sapo.pt Discord: Dwarfer#2715
Postado Setembro 20, 2017 7 anos Autor Em 20/09/2017 em 01:51, Dwarfer disse: Que mistureba foi essa que você fez, cara? Você tá confundindo os scripts, pegando parte de um e colocando no outro. Para ESSE sistema que você colocou aí: Mostrar conteúdo oculto Mostrar conteúdo oculto local id = 9020 function onSay(cid, words, param, channel) local points = getPlayerPoints(cid) if points <= 0 then return true end doPlayerAddItem(cid, id, points) doPlayerRemovePoints(cid, points) doCreatureSay(cid, "You converted points into coins", TALKTYPE_ORANGE_1) return true end ------- ACTION function onUse(cid, item, fromPosition, itemEx, toPosition) doPlayerAddPoints(cid, item.type) doRemoveItem(item.uid) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREATTACK) doSendAnimatedText(getPlayerPosition(cid), "d-coins", TEXTCOLOR_YELLOW) return true end Em 20/09/2017 em 01:51, Dwarfer disse: Que mistureba foi essa que você fez, cara? Você tá confundindo os scripts, pegando parte de um e colocando no outro. Para ESSE sistema que você colocou aí: Mostrar conteúdo oculto Mostrar conteúdo oculto local id = 9020 function onSay(cid, words, param, channel) local points = getPlayerPoints(cid) if points <= 0 then return true end doPlayerAddItem(cid, id, points) doPlayerRemovePoints(cid, points) doCreatureSay(cid, "You converted points into coins", TALKTYPE_ORANGE_1) return true end ------- ACTION function onUse(cid, item, fromPosition, itemEx, toPosition) doPlayerAddPoints(cid, item.type) doRemoveItem(item.uid) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREATTACK) doSendAnimatedText(getPlayerPosition(cid), "d-coins", TEXTCOLOR_YELLOW) return true end Arte da improvisation, tu faz o npc aqui aceitar o item como meio de compra tb? 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 = { [10218] = {buyprice = 5}, -- [id do item] = {buyprice = preço} [10219] = {buyprice = 5}, [8300] = {buyprice = 5}, [8694] = {buyprice = 10}, [7697] = {buyprice = 10}, [3954] = {buyprice = 5}, -- [id do item] = {buyprice = preço} [11263] = {buyprice = 5}, [10141] = {buyprice = 5}, [2284] = {buyprice = 5}, [2263] = {buyprice = 5}, [9927] = {buyprice = 3}, -- [id do item] = {buyprice = preço} [9929] = {buyprice = 3}, [9928] = {buyprice = 3}, [2644] = {buyprice = 3}, [2527] = {buyprice = 3}, [7735] = {buyprice = 10}, -- [id do item] = {buyprice = preço} [12401] = {buyprice = 5}, [5907] = {buyprice = 5}, [7403] = {buyprice = 10}, [7436] = {buyprice = 10}, [2445] = {buyprice = 10} } local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] and doPlayerRemovePoints(cid, t[item].buyprice) then doPlayerAddItem(cid, item) selfSay("Here you go.", cid) else selfSay("You don't have "..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 Setembro 20, 2017 7 anos 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 moeda = 9020 -- id do item que será moeda local t = { [10218] = {buyprice = 5}, -- [id do item] = {buyprice = preço} [10219] = {buyprice = 5}, [8300] = {buyprice = 5}, [8694] = {buyprice = 10}, [7697] = {buyprice = 10}, [3954] = {buyprice = 5}, -- [id do item] = {buyprice = preço} [11263] = {buyprice = 5}, [10141] = {buyprice = 5}, [2284] = {buyprice = 5}, [2263] = {buyprice = 5}, [9927] = {buyprice = 3}, -- [id do item] = {buyprice = preço} [9929] = {buyprice = 3}, [9928] = {buyprice = 3}, [2644] = {buyprice = 3}, [2527] = {buyprice = 3}, [7735] = {buyprice = 10}, -- [id do item] = {buyprice = preço} [12401] = {buyprice = 5}, [5907] = {buyprice = 5}, [7403] = {buyprice = 10}, [7436] = {buyprice = 10}, [2445] = {buyprice = 10} } local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] then if doPlayerRemoveItem(cid, moeda, t[item].buyprice) or doPlayerRemovePoints(cid, t[item].buyprice) then doPlayerAddItem(cid, item) selfSay("Here you go.", cid) else selfSay("You don't have "..t[item].buyprice.." points.", cid) end 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()) Contato: Email: dwarfer@sapo.pt Discord: Dwarfer#2715
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.