• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

War System For Websites (Now With Php Files)

kokorec

Tavon Online - Soon
Joined
May 3, 2008
Messages
287
Reaction score
0
Location
Turkey
This is quote from Gesior.I am added website php files but i am not try.i hope it will work

PHP:
Credits:
gesior.pl - Script
kokorec - Edited Some Things
Talaturen - Idea ; Thanks


LUA script to count team and player frags:
Code:
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_team2: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.
EDIT:
First page - informations about teams
war1gz2.jpg


REP+++??
 

Attachments

Last edited:
Where can I find php files?

#Edit:
"Now someone must write PHP scripts to invite guilds and show stats on page."

Ehe.
 
come on guys it shouldnt be too hard
make the php :eek:
 
and were i have to put all that?
would be great if someone can tell me with out spaming
 
Code:
02/2009 15:46:28] Lua Script Error: [CreatureScript Interface] 
[17/02/2009 15:46:28] data/creaturescripts/scripts/kill.lua:onKill

[17/02/2009 15:46:28] data/lib/database.lua:39: [Result:getDataInt]: Result not set!
[17/02/2009 15:46:28] stack traceback:
[17/02/2009 15:46:28] 	[C]: in function 'error'
[17/02/2009 15:46:28] 	data/lib/database.lua:39: in function 'getDataInt'
[17/02/2009 15:46:28] 	data/creaturescripts/scripts/kill.lua:15: in function <data/creaturescripts/scripts/kill.lua:3>

edit: to make it work without those errors 1st guild vs 2nd guild we have to make something like:
Code:
INSERT INTO `wars_list` (`id`, `team_1`, `team_2`) VALUES
(1, '1,', '2,');

and second time
Code:
INSERT INTO `wars_list` (`id`, `team_1`, `team_2`) VALUES
(2, '2,', '1,');

other way if we just make first one, when someone from guild with id 2 kill someone from guild id 1 errors apears in console and scripts dont work at all
 
Last edited:
fixed (in line 15 was "...inWar_team1:getDataInt...", not 2)lua script (its not final version of lua script):
PHP:
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_team2: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
No more errors. Invities system should not allow to make 2 wars where guild ID 1 fight against guild ID 2
and now to invite guild you must add:
INSERT INTO `wars_list` (`id`, `team_1`, `team_2`) VALUES
(2, ',2,', ',1,');
or:
INSERT INTO `wars_list` (`id`, `team_1`, `team_2`) VALUES
(2, ',2,5,', ',1,66,');
in old version it could load war of guild '151' as '1', because '151,' cointains '1,'
 
fixed lua script (its not final version of lua script):
PHP:
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_team2: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
No more errors. Invities system should not allow to make 2 wars where guild ID 1 fight against guild ID 2

Thanks:)
 

Similar threads

Back
Top