CA

[Encerrado] Comprar outfit por comando

Por carlosr, 10 de ago. de 2018 em Tópicos Sem Resposta

13
2.4k
carlosrC
10 de agosto de 2018 às 19:33

Boa noite, uso Poketibia base DxP, queria um script para comprar outfit por comando, estou querendo para colocar no Diamond Shop do client eu só preciso da script do talkactions,  no client e xml eu sei configurar. Este código deu certo, ele add a outfit mas não remove o diamond que é o ID  2145, se alguém puder ajudar eu agradeço.

function onSay(cid, words, param)

local storage = 9999 -- mão mexa
local itemid = 2145 -- id do item que vai remover
local count = 10 -- quantidade do item que vai remover
local looktype = 2192 -- O Looktype da outift que vai ser vendida


if getPlayerStorageValue(cid, storage) >= 1 then
doPlayerSendTextMessage(cid, 22, "Desculpe voce ja comprou essa outift")
return true
end
if doPlayerRemoveItem(cid,itemid,count) then
doPlayerSendTextMessage(cid, 22, "Você não tem dinheiro suficiente")
return true
end
doPlayerAddOutfit(cid,looktype,3)
setPlayerStorageValue(cid, storage, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou a outift")
return true
end

 

10 de agosto de 2018 às 23:06

testa assim

 

Spoiler

function onSay(cid, words, param)

local storage = 9999 -- mão mexa
local itemid = 2145 -- id do item que vai remover
local count = 10 -- quantidade do item que vai remover
local looktype = 2192 -- O Looktype da outift que vai ser vendida


if getPlayerStorageValue(cid, storage) >= 1 then
doPlayerSendTextMessage(cid, 22, "Desculpe voce ja comprou essa outift")
elseif doPlayerRemoveItem(cid,itemid,count) then
doPlayerSendTextMessage(cid, 22, "Você não tem dinheiro suficiente")
elseif doPlayerAddOutfit(cid,looktype,3) then
setPlayerStorageValue(cid, storage, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou a outfit")
end 
return true
end

 

Editado Agosto 10 por Poke X Ice

MarshmelloM
11 de agosto de 2018 às 16:53

Vai no outfits.xml e me passa o ids que estão na parte "quests"

carlosrC
14 de agosto de 2018 às 20:10
Em 11/08/2018 em 16:53, Marshmello disse:

Vai no outfits.xml e me passa o ids que estão na parte "quests"

<outfit id="108" quest="123456">
<list gender="0" lookType="2191" name="Blastoise Robot"/>
<list gender="1" lookType="2191" name="Blastoise Robot"/>
</outfit>

<outfit id="109" quest="9999">
<list gender="0" lookType="2192" name="Magmar Robot"/>
<list gender="1" lookType="2192" name="Magmar Robot"/>
</outfit>
 

Em 10/08/2018 em 23:06, Poke X Ice disse:

testa assim

 

  Ocultar conteúdo

function onSay(cid, words, param)

local storage = 9999 -- mão mexa
local itemid = 2145 -- id do item que vai remover
local count = 10 -- quantidade do item que vai remover
local looktype = 2192 -- O Looktype da outift que vai ser vendida


if getPlayerStorageValue(cid, storage) >= 1 then
doPlayerSendTextMessage(cid, 22, "Desculpe voce ja comprou essa outift")
elseif doPlayerRemoveItem(cid,itemid,count) then
doPlayerSendTextMessage(cid, 22, "Você não tem dinheiro suficiente")
elseif doPlayerAddOutfit(cid,looktype,3) then
setPlayerStorageValue(cid, storage, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou a outfit")
end 
return true
end

 

Deu erro na distro

14 de agosto de 2018 às 20:53
42 minutos atrás, carlosr disse:

Deu erro na distro

poderia enviar o erro que deu na distro?

MarshmelloM
14 de agosto de 2018 às 22:44

@carlosr

Testa e me diz oque deu

Spoiler

local config = {

palavra1 = 'outfit',
palavra2 = 'outfit2',
sto1 = 123456,
sto2 = 9999,
item = 2145,
qnt = 10,
}

function onSay(cid, words, param)

if (param == palavra1) then
if getPlayerItemCount(cid,config.item) >= config.qnt then 
setPlayerStorageValue(cid, config.sto1, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveItem(cid, config.item,config.qnt)
elseif getPlayerStorageValue(cid, sto1) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 diamonds")
end
end

if (param == palavra2) then
if getPlayerItemCount(cid,config.item) >= config.qnt then 
setPlayerStorageValue(cid, config.sto2, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveItem(cid, config.item,config.qnt)
elseif getPlayerStorageValue(cid, sto2) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 diamonds")
end
end

return true

end

 

Editado Agosto 14 por Marshmello

carlosrC
15 de agosto de 2018 às 21:36
22 horas atrás, Marshmello disse:

@carlosr

Testa e me diz oque deu

  Ocultar conteúdo

local config = {

palavra1 = 'outfit',
palavra2 = 'outfit2',
sto1 = 123456,
sto2 = 9999,
item = 2145,
qnt = 10,
}

function onSay(cid, words, param)

if (param == palavra1) then
if getPlayerItemCount(cid,config.item) >= config.qnt then 
setPlayerStorageValue(cid, config.sto1, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveItem(cid, config.item,config.qnt)
elseif getPlayerStorageValue(cid, sto1) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 diamonds")
end
end

if (param == palavra2) then
if getPlayerItemCount(cid,config.item) >= config.qnt then 
setPlayerStorageValue(cid, config.sto2, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveItem(cid, config.item,config.qnt)
elseif getPlayerStorageValue(cid, sto2) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 diamonds")
end
end

return true

end

 

Não deu erro mas eu digito o comando e não da em nada

MarshmelloM
16 de agosto de 2018 às 02:44

@carlosr Erro meu Teste

Spoiler

local config = {

palavra1 = 'outfit',
palavra2 = 'outfit2',
sto1 = 123456,
sto2 = 9999,
item = 2145,
qnt = 10,
}

function onSay(cid, words, param)

if(param == config.palavra1) then
if getPlayerItemCount(cid,config.item) >= config.qnt then 
setPlayerStorageValue(cid, config.sto1, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveItem(cid, config.item,config.qnt)
elseif getPlayerStorageValue(cid, sto1) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 diamonds")
end
end

if (param == config.palavra2) then
if getPlayerItemCount(cid,config.item) >= config.qnt then 
setPlayerStorageValue(cid, config.sto2, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveItem(cid, config.item,config.qnt)
elseif getPlayerStorageValue(cid, sto2) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 diamonds")
end
end

return true

end

 

16 de agosto de 2018 às 17:57
15 horas atrás, Marshmello disse:

@carlosr Erro meu Teste

  Mostrar conteúdo oculto

local config = {

palavra1 = 'outfit',
palavra2 = 'outfit2',
sto1 = 123456,
sto2 = 9999,
item = 2145,
qnt = 10,
}

function onSay(cid, words, param)

if(param == config.palavra1) then
if getPlayerItemCount(cid,config.item) >= config.qnt then 
setPlayerStorageValue(cid, config.sto1, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveItem(cid, config.item,config.qnt)
elseif getPlayerStorageValue(cid, sto1) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 diamonds")
end
end

if (param == config.palavra2) then
if getPlayerItemCount(cid,config.item) >= config.qnt then 
setPlayerStorageValue(cid, config.sto2, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveItem(cid, config.item,config.qnt)
elseif getPlayerStorageValue(cid, sto2) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 diamonds")
end
end

return true

end

 

consegue adaptar pra vender por "pontos" no lugar do id 2145 ? 

MarshmelloM
17 de agosto de 2018 às 01:45
7 horas atrás, sidneirodrigues disse:

consegue adaptar pra vender por "pontos" no lugar do id 2145 ? 

Como assim , ao invez de combrar o diamond cobrar o premium pontos?

17 de agosto de 2018 às 13:28
11 horas atrás, Marshmello disse:

Como assim , ao invez de combrar o diamond cobrar o premium pontos?

Sim akeles premium point do shop de website , so que invez do nome "premium points" , no meu servidor se chama "pontos" 

MarshmelloM
17 de agosto de 2018 às 13:35

@sidneirodrigues

 

em 00-function(lib)

Spoiler

function getPlayerVipPoints(cid)
    local Info = db.getResult("SELECT premium_points FROM accounts WHERE id = " .. getPlayerAccountId(cid) .. "")
        if Info:getID() ~= LUA_ERROR then
        local Points= Info:getDataInt("premium_points")
        Info:free()
        return Points
    end
     return LUA_ERROR
end

function doPlayerAddVipPoints(cid, points)
    local dif = getPlayerVipPoints(cid) + points
    if dif >= 0 then
        db.executeQuery("UPDATE accounts SET premium_points = premium_points + " .. points .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
        return TRUE
    end
    return FALSE
end

function doPlayerRemoveVipPoints(cid, points)
    local dif = getPlayerVipPoints(cid) - points
    if dif >= 0 then
        db.executeQuery("UPDATE accounts SET premium_points = premium_points - " .. points .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
        return TRUE
    end
    return FALSE
end
 

 

Talkactions

Spoiler

local config = {

palavra1 = 'outfit',
palavra2 = 'outfit2',
sto1 = 123456,
sto2 = 9999,
item = 2145,
qnt1 = 10,
qnt2 = 10,
}

function onSay(cid, words, param)

if(param == config.palavra1) then
if getPlayerVipPoints(cid) >= config.qnt1 then 
setPlayerStorageValue(cid, config.sto1, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveVipPoints(cid,config.qnt1)
elseif getPlayerStorageValue(cid, sto1) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 pontos")
end
end

if (param == config.palavra2) then
if getPlayerVipPoints(cid) >= config.qnt2 then 
setPlayerStorageValue(cid, config.sto2, 1)
doPlayerSendTextMessage(cid, 22, "Você comprou uma outfit")
doPlayerRemoveVipPoints(cid,config.qnt2)
elseif getPlayerStorageValue(cid, sto2) == -1 then
doPlayerSendTextMessage(cid,19, "Você já comprou essa outfit")
else
doPlayerSendTextMessage(cid, 19," você não não tem 10 pontos")
end
end

return true

end

 

6 meses depois...
MarshmelloM
20 de fevereiro de 2019 às 16:23
A questão neste suporte foi encerrada por falta de respostas. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta.

+ Caso a dúvida não tenha sido resolvida você poderá criar outro tópico solicitando ajuda.
* Lembre-se que é permitido dar UP no tópico a cada 24 horas para assim o destacar e manter movimentado.