Usa o do vodkart
em lib/functions vc adiciona:
function getPoints(cid)
local check = db.getResult("SELECT `points` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
return check:getDataInt("points") <= 0 and 0 or check:getDataInt("points") end
function addPoints(cid,amount)
db.executeQuery("UPDATE `players` SET `points` = "..getPoints(cid).."+"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end
function removePoints(cid,amount)
db.executeQuery("UPDATE `players` SET `points` = "..getPoints(cid).."-"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end
function setPoints(cid,value)
db.executeQuery("UPDATE `players` SET `points` = "..value.." WHERE `id` = "..getPlayerGUID(cid)) end
e na sua database vc executa:
ALTER TABLE `players` ADD `points` INT NOT NULL DEFAULT '0'
Caso não saiba executar você me fala que eu te ensino como.
getPoints(cid) -- checa qnto tem de pontos
addPoints(cid,amount) -- adc pontos ao jogador,por exemplo Vodkart tem 10 pontos e eu adiciono 30 vai ficar 40
removePoints(cid,amount) -- remove os pontos do jogador,minimo é 0
setPoints(cid,value) -- altera os pontos do jogador pra qual valor vc quiser
Talk:
Systempoints.lua
function onSay(cid, words, param)
if(words == "!points") then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem "..getPoints(cid).." Points.")
elseif(words == "!rankpoints") then
local max_players,str = 20,""
str = "--[ RANK POINTS ]--\n\n"
query = db.getResult("SELECT `name`, `points` FROM `players` WHERE `points` > -1 AND `id` > 6 AND `group_id` < 2 ORDER BY `points` DESC, `name` ASC;")
if (query:getID() ~= -1) then k = 1 while true do
str = str .. "\n " .. k .. ". " .. query:getDataString("name") .. " - [" .. query:getDataInt("points") .. "]"
k = k + 1
if not(query:next()) or k > max_players then break end end query:free()end
if str ~= "" then doShowTextDialog(cid,6500, str) end
elseif(words == "/addpoints") then
if getPlayerAccess(cid) == 5 then
local t = string.explode(param, ",")
if not t[1] or not t[2] then return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end
local player = getPlayerByName(t[1])
local points = t[2]
local pid = getPlayerByNameWildcard(t[1])
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "você adicionou "..points.." Points do jogador "..t[1])
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram adicionados "..points.." Points no seu character.")
addPoints(player,points)
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você agora tem "..getPoints(player).." Points.")
end
elseif(words == "/delpoints") then
if getPlayerAccess(cid) == 5 then
local t = string.explode(param, ",")
if not t[1] or not t[2] then return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end
local player = getPlayerByName(t[1])
local points = t[2]
local pid = getPlayerByNameWildcard(t[1])
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "você removeu "..points.." Points do jogador "..t[1])
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram removidos "..points.." Points do seu character.")
removePoints(player,points)
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você agora tem "..getPoints(player).." Points.")
end
elseif(words == "/setpoints") then
if getPlayerAccess(cid) == 5 then
local t = string.explode(param, ",")
if not t[1] or not t[2] then return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end
local player = getPlayerByName(t[1])
local points = t[2]
local pid = getPlayerByNameWildcard(t[1])
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Agora o jogador "..t[1].." tem "..points.." Points no seu character.")
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "agora você tem "..points.." Points do seu character.")
setPoints(player,points)
end
end
return TRUE
end
Talkactions.xml
<talkaction words="!points;!rankpoints;/addpoints;/delpoints;/setpoints" script="systempoints.lua"/>
Bau para comprar Item:
function onUse(cid, item, fromPosition, itemEx, toPosition) local points,item = 30,2494 if getPoints(cid) < points then return doPlayerSendTextMessage(cid, 20, "você precisa de "..points.." para comprar o item " .. getItemNameById(item)) end doPlayerAddItem(cid,item) removePoints(cid,points) doPlayerSendTextMessage(cid, 20, "você comprou o item " .. getItemNameById(item)) return true[/color][/size] [color=#282828][size=3]end
Tenta esse ai, no otserver do meu amigo pegou


info
Grupo: Campones
Registrado: 29/11/08
Posts: 36
Reputação: +1
Tentei usar esse sistema : http://www.xtibia.com/forum/topic/183310-premium-points-in-game/
Mas ele não pega, fiz tudo certo mas quando tento executar os comandos aparece que eu não posso executar está talkaction.
Obs : o comando "!points" não funciona nem aparece nenhuma mensagem.