Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado

boa tarde galera do TK, to utilizando um sistema de loja vip adicionando points pelo site e comprando itens in-game pelo comando !vip (nome do item), só que ao comprar o item o script não ta removendo os pontos do player!!! alguem me ajuda porfavor. o meu script é esse ai:

 

local tab = {

["asgard key"] = {id = 134, count = 1, points = 1000},
["nightmare doll"] = {id = 117, count = 1, points = 5000},
["addon doll"] = {id = 116, count = 1, points = 3000},
["sd"] = {id = 2268, count = 100, points = 100},
["mp"] = {id = 7620, count = 100, points = 10},
["hp"] = {id = 7618, count = 100, points = 10},
["gsp"] = {id = 8472, count = 100, points = 110},
["uhp"] = {id = 8473, count = 100, points = 130},
["smp"] = {id = 7589, count = 100, points = 30},
["shp"] = {id = 7588, count = 100, points = 30},
["gmp"] = {id = 7590, count = 100, points = 60},
["ghp"] = {id = 7591, count = 100, points = 60},
["suprem vocation"] = {id = 142, count = 1, points = 30000},
["medal of honour"] = {id = 5785, count = 1, points = 5000},
["lunar staff"] = {id = 7424, count = 1, points = 10000},
["golden bow"] = {id = 7438, count = 1, points = 10000},
}
 
-- ["nome do item"] = {id = id do item, count = quantidade que vai comprar, points = preço.}
 
local config = {
pz = true,
battle = true,
premium = false
}
 
function onSay(cid, words, param)
if not param or param == "" then
return doPlayerSendTextMessage(cid, 27, "Voce possui "..getPoints(cid).." creditos.")
end
 
if param == 'lista' then
local str = ""
for name,points in pairs(tab) do
str = ("Item: " ..name.. ",\n Preço: " ..points.points.. "")
end
str = str .. ""
doPlayerPopupFYI(cid, str)
return TRUE
end
 
if config.pz == true and getTilePzInfo(getCreaturePosition(cid)) == FALSE then
doPlayerSendTextMessage(cid, 21,"Voce so pode comprar um item em protect zone.")
return TRUE
end
 
if config.premium == true and not isPremium(cid) then
doPlayerSendTextMessage(cid, 21, "Voce so pode comprar um item se for premium.")
return TRUE
end
 
if config.battle == true and getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE then
doPlayerSendTextMessage(cid, 21, "Voce so pode comprar um item sem battle.")
return TRUE
end
 
 
local tab = tab[param]
if tab then
if getPoints(cid) >= tab.points then
doItemSetAttribute(doPlayerAddItem(cid, tab.id, tab.count),"description","Esse item foi comprado por "..getPlayerName(cid)..".")
doPlayerSendTextMessage(cid, 27, "Voce comprou "..tab.count.." "..getItemNameById(tab.id).." por "..tab.points.." creditos, agora voce tem "..getPoints(cid).." creditos.")
doPlayerSendTextMessage(cid, 27, "Voce sera kickado.")
addEvent(addPoints, 100, cid, -tab.points)
end
end
return true
end
 
function getPoints(cid)
return tonumber(db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";"):getDataString("premium_points"))
end
 
function addPoints(cid, points)
 
local acc = getPlayerAccountId(cid)
local pp = getPoints(cid)
 
if isCreature(cid) then
doRemoveCreature(cid)
end
 
db.executeQuery("UPDATE `accounts` SET `premium_points` = ".. pp + points .." WHERE `id` = " .. acc .. ";")
end

 
acho que ta faltando a função removepoints mais não sei como adicionar ela no script pois sou iniciante em scripting alguem me ajuda!!

Editado por hempz (veja o histórico de edições)

Se Ajudei Clique no rep_up.png ao Lado, Não Custa nada :D!!

Postado

Tenta ae:

local tab = {

["asgard key"] = {id = 134, count = 1, points = 1000},
["nightmare doll"] = {id = 117, count = 1, points = 5000},
["addon doll"] = {id = 116, count = 1, points = 3000},
["sd"] = {id = 2268, count = 100, points = 100},
["mp"] = {id = 7620, count = 100, points = 10},
["hp"] = {id = 7618, count = 100, points = 10},
["gsp"] = {id = 8472, count = 100, points = 110},
["uhp"] = {id = 8473, count = 100, points = 130},
["smp"] = {id = 7589, count = 100, points = 30},
["shp"] = {id = 7588, count = 100, points = 30},
["gmp"] = {id = 7590, count = 100, points = 60},
["ghp"] = {id = 7591, count = 100, points = 60},
["suprem vocation"] = {id = 142, count = 1, points = 30000},
["medal of honour"] = {id = 5785, count = 1, points = 5000},
["lunar staff"] = {id = 7424, count = 1, points = 10000},
["golden bow"] = {id = 7438, count = 1, points = 10000},
}
 
-- ["nome do item"] = {id = id do item, count = quantidade que vai comprar, points = preço.}
 
local config = {
pz = true,
battle = true,
premium = false
}
 
function onSay(cid, words, param)
if not param or param == "" then
return doPlayerSendTextMessage(cid, 27, "Voce possui "..getPoints(cid).." creditos.")
end
 
if param == 'lista' then
local str = ""
for name,points in pairs(tab) do
str = ("Item: " ..name.. ",\n Preço: " ..points.points.. "")
end
str = str .. ""
doPlayerPopupFYI(cid, str)
return TRUE
end
 
if config.pz == true and getTilePzInfo(getCreaturePosition(cid)) == FALSE then
doPlayerSendTextMessage(cid, 21,"Voce so pode comprar um item em protect zone.")
return TRUE
end
 
if config.premium == true and not isPremium(cid) then
doPlayerSendTextMessage(cid, 21, "Voce so pode comprar um item se for premium.")
return TRUE
end
 
if config.battle == true and getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE then
doPlayerSendTextMessage(cid, 21, "Voce so pode comprar um item sem battle.")
return TRUE
end
 
 
local tab = tab[param]
if tab then
if getPoints(cid) >= tab.points then
doItemSetAttribute(doPlayerAddItem(cid, tab.id, tab.count),"description","Esse item foi comprado por "..getPlayerName(cid)..".")
doPlayerSendTextMessage(cid, 27, "Voce comprou "..tab.count.." "..getItemNameById(tab.id).." por "..tab.points.." creditos, agora voce tem "..getPoints(cid).." creditos.")
removePoints(cid,tab.points)
doPlayerSendTextMessage(cid, 27, "Voce sera kickado.")
addEvent(addPoints, 100, cid, -tab.points)
end
end
return true
end
 
function getPoints(cid)
return tonumber(db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";"):getDataString("premium_points"))
end
 
function addPoints(cid, points)
 
local acc = getPlayerAccountId(cid)
local pp = getPoints(cid)
 
if isCreature(cid) then
doRemoveCreature(cid)
end
 
db.executeQuery("UPDATE `accounts` SET `premium_points` = ".. pp + points .." WHERE `id` = " .. acc .. ";")
end

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

Postado
removePoints(cid,tab.points)

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo