local function getPlayerPPoints(cid)
local Info = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
local Points= Info:getDataInt("premium_points")
Info:free()
return Points
end
return LUA_ERROR
end
local function AddPlayerPPontos(cid, points)
local Info = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
db.executeQuery("UPDATE accounts SET premium_points = " .. getPlayerPPoints(cid) + points .. " WHERE id=" .. getPlayerAccountId(cid) .. ";")
Info:free()
return 1
end
end
local function RemoverPlayerPPontos(cid, points)
local Info = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
db.executeQuery("UPDATE accounts SET premium_points = " .. getPlayerPPoints(cid) - points .. " WHERE id=" .. getPlayerAccountId(cid) .. ";")
Info:free()
return 1
end
end
function onSay(cid, words, param)
local t = string.explode(param, ",")
local id = tonumber(t[1])
if words == "!depositar" then
local id = tonumber(t[1])
if (id == 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não é possível depositar 0 moedas!")
return true
end
if (id == null) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Por favor digite um valor.")
return true
end
if getPlayerItemCount(cid, 9971) >= id then
AddPlayerPPontos(cid, id)
doPlayerRemoveItem(cid, 9971, id)
doPlayerSendTextMessage(cid, 29, "Parabéns, você depositou ".. id .." barras de ouro com sucesso! Seu saldo no banco agora é de ".. getPlayerPPoints(cid) .." moedas, para sacar utilize o comando !sacar")
else
doPlayerSendTextMessage(cid, 29, "Você não possui a quantidade necessária para adicionar no seu saldo.")
return TRUE
end
----------------------------------------------------------------------
elseif words == "!sacar" then
local t = string.explode(param, ",")
local id = tonumber(t[1])
if (id == 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não é possível depositar 0 moedas!")
return true
end
if (id == null) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Por favor digite um valor.")
return true
end
if getPlayerPPoints(cid) >= id then
doPlayerAddItem(cid, 9971, id)
RemoverPlayerPPontos(cid, id)
doPlayerSendTextMessage(cid, 29, "Parabéns, você sacou ".. id .." barras de ouro com sucesso! Seu saldo no banco agora é de ".. getPlayerPPoints(cid) .." moedas.")
setPlayerStorageValue(cid,11548,os.time()+15)
return TRUE
else
doPlayerSendTextMessage(cid, 29, "Você não possui a quantidade necessária para sacar.")
end
------------------------------------------------------------------------
elseif words == "!saldo" then
if not param or param == "" then
doPlayerSendTextMessage(cid, 29, "O seu saldo no shopping é de: ".. getPlayerPPoints(cid) .." moedas.")
return true
end
-------------------------------------------------------------------------------------
elseif words == "!verpontos" then
if (not t[1]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Comando precisa de parametros")
return true
end
if(getPlayerGroupId(cid) >= 3) then
local player = getPlayerGUIDByName(t[1])
if (not player) then
doPlayerSendTextMessage(cid, 29, "Jogador não existe ou não está online")
return true
else
doPlayerSendTextMessage(cid, 29, "O jogador "..getCreatureName(t[1]) .." tem ".. getPlayerPPoints(t[1]).." moedas.")
return true
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não tem permição de usar esse comando")
return true
end
------------------------------------------------------------------------------------
elseif words == "!addpontos" then
local player = getPlayerGUIDByName(t[1])
if (not t[1]) and (not t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Comando precisa de parametros")
return true
end
if(getPlayerGroupId(cid) >= 3) then
if (not player) then
doPlayerSendTextMessage(cid, 29, "Jogador não existe ou não está online")
return true
else
AddPlayerPPontos(player,t[2])
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você adicionou "..t[2].." moedas para conta de "..t[1]..".")
return true
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não tem permição de usar esse comando")
return true
end
------------------------------------------------------------------------------------------------------------------------
elseif words == "!removerpontos" then
local player = getPlayerGUIDByName(t[1])
if (not t[1]) and (not t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Comando precisa de parametros")
return true
end
if(getPlayerGroupId(cid) >= 3) then
if (not player) then
doPlayerSendTextMessage(cid, 29, "Jogador não existe ou não está online")
return true
else
if(t[2] > getPlayerPPoints(player)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "O jogador "..t[1].." só tem ".. getPlayerPPoints(player).." moedas.")
return true
end
if(t[2] < 0) then
RemoverPlayerPPontos(player,getPlayerPPoints(player))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Foi removida todos as moedas do jogador "..t[1]..".")
else
RemoverPlayerPPontos(player,t[2])
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Foi removido "..t[2].." moedas do jogador "..t[1]..".")
return true
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não tem permição de usar esse comando")
return true
end
return TRUE
end
end