Hallo Com!
Ich hatte diese Quest (die full) für jemanden geschrieben, der sich leider etwas vertan hatte mit seiner Beschreibung von dem, was er wollte, doch ich will nicht, dass das auch auf meiner Platte verstaubt, ohne Nutzen, deshalb gebe ich sie euch c:
Es ist ein Grundgerüst für eine PVP-Rangliste.
Einmal (half mysql) mit Speicherung in Questflags, ein mal (full MySQL) pur in MySQL.
Die halt-MySQL Rangliste updatet sich ca alle 6 Minuten, die full-MySQL Rangliste ist immer Up2Date - ist dafür aber auch belastender! Ansonsten aber komplett identisch. Die Rangliste wird Farbig, je nach Reich des Spielers.
Es ist nur ein kleines Delay von 4 Minuten eingebaut, was selbstverständlich keinen allzu guten Push-Schutz ergibt!
Die Punkte, die man erhält, können auf allerlei Kriterien ausgeweitet werden, wie etwa eigene TP etc.
Benötigt werden
npc.get_vid und mysql_query
Diese Quests sollen nur ein Grundgerüst darstellen, sind Standalone aber auch komplett lauffähig!
Full-MySQL:
PHP Code:
quest gkp begin
--[[
by Mijago
benötigt npc.get_vid, mysql_query
CREATE TABLE player.pvp_points (
`pid` int NULL ,
`points` int NULL ,
PRIMARY KEY (`pid`)
);
--]]
state start begin
when kill with npc.is_pc() begin
if get_time() - pc.getqf "gpoint_time" < 0 then
return
end
local data = {
me = {
lv = pc.get_level(),
em = pc.get_empire(),
},
opp = {}
}
local me = pc.select(npc.get_vid())
data.opp = {
lv = pc.get_level(),
em = pc.get_empire(),
pi = party.is_party(),
pl = party.is_leader(),
pn = party.get_near_count()
}
pc.select(me)
if math.abs(data.me.lv-data.opp.lv) > 15 then -- 15 LVL unterschied MAXIMAL
return
end
local points = data.opp.em ~= data.me.em and 3 or 1 -- 3 Punkte bei "Ausländischem" Gegner, 1 bei "Einheimischen"
if data.opp.pi and data.opp.pn > 0 then
-- +1 Punkt, wenn Gegner in einer Gruppe ist und mind. ein Mitglied in der nähe ist
points = points+1
end
if data.opp.pi and data.opp.pn > 0 and data.opp.pl then
-- +1 Punkt, wenn Gegner in einer Gruppe ist und mind. ein Mitglied in der nähe ist UND er Gildenleiter ist
points = points+1
end
notice("Du hast "..points.." PVP-Punkte erhalten!")
pc.setqf("gpoint_time",get_time()+4*60) -- 4m delay
mysql_query("insert into player.pvp_points VALUES("..pc.get_player_id()..","..points"..) ON DUPLICATE KEY UPDATE points=points+"..points)
end
when 9010.chat."PVP-Rangliste" begin
say_title"PVP-Rangliste"
say "Welche Rangliste möchtest du dir ansehen?"
local sel = select("Alle Reiche","Rotes Reich","Gelbes Reich","Blaues Reich","Keine")
if sel == 5 then return end
local query = "select player.name, player_index.empire,pvp_points.points from pvp_points INNER JOIN player.player ON player.id = pvp_points.pid INNER JOIN player.player_index ON player.account_id = player_index.id"
if sel > 1 then
query = query.." where player_index.empire == "..(sel-1)
end
local out = mysql_query(query.." ORDER BY points DESC LIMIT 100")-- Zur Sicherheit nur 100
if type(out) ~= "table" or type(out[1]) ~= "table" then
say "Es gab leider keine Resultate!"
return
end
local num,sel = 1,1
local max = table.getn(out)
repeat
for i = math.max(num,1),math.min(max,num+9) do
if out[i] then
local colors = ({{205, 92, 92},{255,215,0},{135, 206, 250}})[out[i][2]]
say('[COLOR r;'..(colors[1]/255)..'|g;'..(colors[2]/255)..'|b;'..(colors[3]/255)..']'..i.." - "..out[i][1]..": "..out[i][3])
else
say("-err-")
end
end
say_reward"Was möchtest du tun?"
if num +10 > max then
sel = select{"Zurück","Abbrechen"}
sel = sel == 2 and 3 or 1
elseif num == 1 then
sel = select("Weiter","Abbrechen")+1
else
sel = select("Zurück","Weiter","Abbrechen")
end
num = math.abs(num + (sel == 1 and -10 or 10))
until sel == 3
end
end
end
Half-MySQL:
PHP Code:
quest gkp begin
--[[
by Mijago
benötigt npc.get_vid, mysql_query
* Ressourcenschonender
* Rangliste Updatet nur ca alle 6 Minuten.
--]]
state start begin
when kill with npc.is_pc() begin
if get_time() - pc.getqf "gpoint_time" < 0 then
return
end
local data = {
me = {
lv = pc.get_level(),
em = pc.get_empire(),
},
opp = {}
}
local me = pc.select(npc.get_vid())
data.opp = {
lv = pc.get_level(),
em = pc.get_empire(),
pi = party.is_party(),
pl = party.is_leader(),
pn = party.get_near_count()
}
pc.select(me)
if math.abs(data.me.lv-data.opp.lv) > 15 then -- 15 LVL unterschied MAXIMAL
return
end
local points = data.opp.em ~= data.me.em and 3 or 1 -- 3 Punkte bei "Ausländischem" Gegner, 1 bei "Einheimischen"
if data.opp.pi and data.opp.pn > 0 then
-- +1 Punkt, wenn Gegner in einer Gruppe ist und mind. ein Mitglied in der nähe ist
points = points+1
end
if data.opp.pi and data.opp.pn > 0 and data.opp.pl then
-- +1 Punkt, wenn Gegner in einer Gruppe ist und mind. ein Mitglied in der nähe ist UND er Gildenleiter ist
points = points+1
end
notice("Du hast "..points.." PVP-Punkte erhalten!")
pc.setqf("pvp_points",pc.getqf("pvp_points")+points)
pc.setqf("gpoint_time",get_time()+4*60) -- 4m delay
end
when 9010.chat."PVP-Rangliste" begin
say_title"PVP-Rangliste"
say "Welche Rangliste möchtest du dir ansehen?"
local sel = select("Alle Reiche","Rotes Reich","Gelbes Reich","Blaues Reich","Keine")
if sel == 5 then return end
local query = "select player.name, player_index.empire,quest.lValue from quest INNER JOIN player.player ON player.id = quest.dwpid INNER JOIN player.player_index ON player.account_id = player_index.id where quest.szName = "..string.format("%q","gkp").." and szState = "..string.format("%q","pvp_points")
if sel > 1 then
query = query.." and player_index.empire == "..(sel-1)
end
local out = mysql_query(query.." ORDER BY points DESC LIMIT 100")-- Zur Sicherheit nur 100
if type(out) ~= "table" or type(out[1]) ~= "table" then
say "Es gab leider keine Resultate!"
return
end
local num,sel = 1,1
local max = table.getn(out)
repeat
for i = math.max(num,1),math.min(max,num+9) do
if out[i] then
local colors = ({{205, 92, 92},{255,215,0},{135, 206, 250}})[out[i][2]]
say('[COLOR r;'..(colors[1]/255)..'|g;'..(colors[2]/255)..'|b;'..(colors[3]/255)..']'..i.." - "..out[i][1]..": "..out[i][3])
else
say("-err-")
end
end
say_reward"Was möchtest du tun?"
if num +10 > max then
sel = select{"Zurück","Abbrechen"}
sel = sel == 2 and 3 or 1
elseif num == 1 then
sel = select("Weiter","Abbrechen")+1
else
sel = select("Zurück","Weiter","Abbrechen")
end
num = math.abs(num + (sel == 1 and -10 or 10))
until sel == 3
end
end
end
Viel Spaß damit!
Quote:
|
Ein dickes Danke an iSouli fürs Testen c:
|