lua script to count team and player frags:
Lua:
local fragtime = getconfiginfo('timetodecreasefrags')
function onkill(cid, target)
local team = 0
local id = 0
if isplayer(target) == true and getplayerguildid(cid) > 0 and getplayerguildid(target) > 0 then
local inwar_team1 = db.getresult("select * from `wars_list` where `team_1` like '%".. Getplayerguildid(cid) ..",%' and `team_2` like '%".. Getplayerguildid(target) ..",%';")
if(inwar_team1:getid() ~= -1) then
id = tonumber(inwar_team1:getdataint("id"))
team = 1
inwar_team1:free()
else
local inwar_team2 = db.getresult("select * from `wars_list` where `team_1` like '%".. Getplayerguildid(target) ..",%' and `team_2` like '%".. Getplayerguildid(cid) ..",%';")
if(inwar_team2:getid() ~= -1) then
id = tonumber(inwar_team1:getdataint("id"))
team = 2
inwar_team2:free()
end
end
if team > 0 then
db.executequery("insert into `war_deaths` (`war_id`, `team`, `from_guild`, `to_guild`, `player_id`, `killed_by`) values (" .. Id .. ", " .. Team .. ", " .. Getplayerguildid(cid) .. ", " .. Getplayerguildid(target) .. ", " .. Getplayerguid(target) .. ", " .. Getplayerguid(cid) .. ");")
doplayersetredskullticks(cid, getplayerredskullticks(cid)-fragtime)
end
end
return true
end
PHP:
create table if not exists `wars_list` (
`id` int(11) not null auto_increment,
`team_1` varchar(255) not null,
`team_2` varchar(255) not null,
primary key (`id`)
);
create table if not exists `war_deaths` (
`war_id` int(11) not null,
`team` int(11) not null,
`from_guild` int(11) not null default '0',
`to_guild` int(11) not null default '0',
`player_id` int(11) not null default '0',
`killed_by` int(11) not null default '0'
);
example of war:
PHP:
insert into `wars_list` (`id`, `team_1`, `team_2`) values
(1, '3,', '38,');
(guild id 3 vs. Guild id 38)
PHP:
insert into `wars_list` (`id`, `team_1`, `team_2`) values
(1, '3,6,', '38,23,');
(guild id 3 and guild id 6 vs. Guild id 38 and guild id 23 )
always "," at end of guilds list.
Script save info:
PHP:
insert into `war_deaths` (`war_id`, `team`, `from_guild`, `to_guild`, `player_id`, `killed_by`) values
(1, 1, 3, 38, 17797, 15422),
(1, 1, 3, 38, 17797, 15422);
1 - war id = 1
1 - frag for team 1
3 - killer was from guild id 3
38 - killed player was from guild id 38
17797 - id of killed player
15422 - id of killer
with this table you can generate any stats of war.. Like:
- top 5 fragers from 1 team (or 1 guild)
PHP:
select `players`.`name`, count(`war_deaths`.`killed_by`) frags from `war_deaths`, `players` where `war_deaths`.`war_id` = 1 and `players`.`id` = `war_deaths`.`killed_by` and `war_deaths`.`team` = 1 group by `war_deaths`.`killed_by` order by count(`war_deaths`.`killed_by`) desc
- number of frags of teams from 'war id 1'
PHP:
select `team`, count(`war_deaths`.`team`) frags from `war_deaths` where `war_deaths`.`war_id` = 1 group by `war_deaths`.`team` order by count(`war_deaths`.`team`) desc
script remove frags (can't get more then 1 frag if kill only enemy team members)
now someone must write php scripts to invite guilds and show stats on page.