Ir para conteúdo
  • Cadastre-se

(Resolvido)Erro na Talk e Action


Ir para solução Resolvido por Dwarfer,

Posts Recomendados

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

 

 

Link para o post
Compartilhar em outros sites
  • Solução
11 minutos atrás, 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í:

 

Spoiler

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:

 

Link para o post
Compartilhar em outros sites
11 minutos atrás, 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í:

 

  Ocultar conteúdo


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

 

 

 

11 minutos atrás, 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í:

 

  Ocultar conteúdo


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())

 

Link para o post
Compartilhar em outros sites
Spoiler

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:

 

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo