Hej.
Przedstawiam skrypt na komende "!gpoints", dzi?ki kt?remu Punkty na gildie b?d? rozdawane w pe?ni automatycznie.
Komendy tej mog? u?ywa? liderzy gildii.
W talkactions/scripts tworzymy plik "points.lua" i dodajemy do niego:
Natomiast w talkactions.xml dajemy:
Ostatnim krokiem b?dzie w bazie danych, do tabeli "guilds" da? kolumne "points".
Przedstawiam skrypt na komende "!gpoints", dzi?ki kt?remu Punkty na gildie b?d? rozdawane w pe?ni automatycznie.
Komendy tej mog? u?ywa? liderzy gildii.
W talkactions/scripts tworzymy plik "points.lua" i dodajemy do niego:
PHP:
----------------
local minPlayer = 15 -- Minimalna ilo?? graczy online w gildii.
local points = 130 -- Ilo?? punkt?w dla ka?dego cz?onka online.
local p_mL = 2 -- Mno?nik dla lidera[tego kt?ry u?ywa tej funkcji]. np. 130punkt?w * x = 260 dla lidera.
local active=true -- czy komenda !gpoints jest aktywna?
function getGStatus(id)
local db = db.getResult("SELECT * FROM `guilds` WHERE `id` = '".. id .."';")
local status = tonumber(db:getDataInt("points"))
db:free()
return status
end
function setGStatus(id)
db.executeQuery("UPDATE `guilds` SET `points` = 1 WHERE `id` = '".. id .."' LIMIT 1;")
return true
end
local function isLeader(cid)
local guild = getPlayerGuildId(cid)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
return false
end
return true
end
function checkIp(cid)
local guild = getPlayerGuildId(cid)
for _, sid in pairs(getPlayersOnline()) do
if guild == getPlayerGuildId(sid) then
if getPlayerIp(cid) == getPlayerIp(sid) then
return false
end
end
end
return true
end
local function getOPlayerInGuild(cid)
local players = {}
local guild = getPlayerGuildId(cid)
for _, sid in pairs(getPlayersOnline()) do
if guild == getPlayerGuildId(sid) then
table.insert(players, sid)
end
end
if players then
return players
else
return false
end
end
local function addPoints(cid, players)
for i=1, #players do
if checkIp(players[i]) == false then
doPlayerSendTextMessage(cid, 22, "There are mc players.["..getCreatureName(players[i]).."]")
return true
end
end
for i=1, #players do
local p = players[i]
if p==cid then
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + "..(points*p_mL).." WHERE `id` = " .. getPlayerAccountId(p) .. ";")
doPlayerSendTextMessage(p,22,'You get '..(points*p_mL)..' premium from Guild Points.ss')
else
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." WHERE `id` = " .. getPlayerAccountId(p) .. ";")
doPlayerSendTextMessage(p,22,'You get '..points..' premium from Guild Points.')
end
end
setGStatus(getPlayerGuildId(players[1]))
doBroadcastMessage(getPlayerGuildName(players[1]).." get points from Guild Points System!")
return true
end
---------------
function onSay(cid, words, param)
if not active then
return true
end
local guild = getPlayerGuildId(cid)
if not isLeader(cid) then
return true
end
if getGStatus(guild) > 0 then
doPlayerSendTextMessage(cid, 22, "Points for your guild has been added.")
return true
end
local players = #getOPlayerInGuild(cid)
if players < minPlayer then
doPlayerSendTextMessage(cid, 22, "There are only "..players.." player online! Req. "..minPlayer..".")
return true
end
addPoints(cid, getOPlayerInGuild(cid))
return true
end
Natomiast w talkactions.xml dajemy:
PHP:
<talkaction words="!gpoints" script="points.lua" />
Ostatnim krokiem b?dzie w bazie danych, do tabeli "guilds" da? kolumne "points".