Este script faz com que ao digitar o comando !guildpoints, a guild receba um tanto de pontos configuraveis com a condição de que não tenha IP's repetidos, que tenha o Level requisitado e a quantidade de jogadores necessários. Tudo configurável.
Execute essa query em seu mysql
ALTER TABLE `guilds` ADD `gotpoints` INT NOT NULL DEFAULT '0'
Configuração:
local ipsNeeded = QUANTIDADE DE PLAYERS NA GUILD
local minimumLevel = LEVEL NECESSÁRIO
local pointsForPlayer = PONTOS PRA CADA PLAYER
local pointsForLeader = PONTO PRO LIDER
O resto NÃO mexa.
Em talkactions.xml
<talkaction words="!guildpoints" script="guildpoints.lua" />
Em talkactions/scripts crie um arquivo guildpoints.lua
local playersNeeded = 15local ipsNeeded = 12
local minimumLevel = 150
local storageId = 47578
local playerGotPoints = 47579
local pointsForPlayer = 60
local pointsForLeader = 200
local exhaustionInSec = 60
local function sendPlayersList(cid, list)
for i, pid in ipairs(list) do
local level = getPlayerLevel(pid) < minimumLevel and " - " .. getPlayerLevel(cid) .. " level " or ""
local valid = getCreatureStorage(pid, storageId) > 1 and " - already received!" or ""
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(pid) .. level)
end
end
function doAddPoints(cid, points)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
function onSay(cid, words, param, channel)
if exhaustion.check(cid, 2000) == false then
exhaustion.set(cid, 2000, exhaustionInSec)
local gotpoints = db.getResult("SELECT `gotpoints` FROM `guilds` WHERE `id` = " .. getPlayerGuildId(cid) .. ";"):getDataInt("gotpoints")
if gotpoints == 0 then
if getCreatureStorage(cid, playerGotPoints) ~= 1 then
if(getPlayerGuildLevel(cid) == 3) then
local leaderGuild = getPlayerGuildId(cid)
local players = getPlayersOnline()
local guildMembersValid = {}
local guildMembersInvalid = {}
for i, pid in ipairs(players) do
if(leaderGuild == getPlayerGuildId(pid)) then
if(getPlayerLevel(pid) >= minimumLevel and tonumber(getCreatureStorage(pid, storageId)) < 2) then
table.insert(guildMembersValid, pid)
else
table.insert(guildMembersInvalid, pid)
end
end
end
if(#guildMembersValid >= playersNeeded) then
local IPs = {}
for _, v in ipairs(guildMembersValid) do
local ip = getPlayerIp(v)
if isInArray(IPs, ip) == false then
table.insert(IPs, ip)
end
end
if(#IPs >= ipsNeeded) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Players that received points:")
sendPlayersList(cid, guildMembersValid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Players that did not receive points:")
sendPlayersList(cid, guildMembersInvalid)
local accounts = {}
for i, pid in ipairs(guildMembersValid) do
table.insert(accounts, getPlayerAccountId(pid))
doCreatureSetStorage(pid, storageId, os.time())
end
db.executeQuery("UPDATE `guilds` SET `gotpoints` = 1 WHERE `id` = " .. getPlayerGuildId(cid) .. ";")
doAddPoints(cid, (pointsForLeader - pointsForPlayer))
setPlayerStorageValue(cid, playerGotPoints, 1)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points`+" .. pointsForPlayer .. " WHERE `id` IN (" .. table.concat(accounts, ',') .. ");")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, #guildMembersValid .. " players from your guild are valid (" .. playersNeeded .. " required), but you have together only " .. #IPs .. " IPs (" .. ipsNeeded .. " required)")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Valid players:")
sendPlayersList(cid, guildMembersValid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Invalid players:")
sendPlayersList(cid, guildMembersInvalid)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, #guildMembersValid .. " players from your guild are valid, " .. playersNeeded .. " required. Minimum level required is " .. minimumLevel)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Valid players:")
sendPlayersList(cid, guildMembersValid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Invalid players:")
sendPlayersList(cid, guildMembersInvalid)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Only guild leader can request points.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your guild have already recived points.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your guild have already recived points.")
end
else
doPlayerSendCancel(cid, "You can use this command only 1 time per 60 sec.")
end
return true
end
Seja feliz
Testado em 0.4
Creditos: Wake e Eu