• 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.

Fixed Guild War System for Website [include all]-[will not count frags] (TFS 0.3+)

Status
Not open for further replies.
Ok I've got 2 mistakes !! First if someone is killed by 2 people the script counts 2 frags not one! And second one is if 2 guilds are in fight and one guild will be deleted whole system fuck up
 
/war-challenge problem suggestion

when i say /war-challenge map1 after 15 sec in console show this:
Code:
[31/07/2009 00:43:28] Lua Script Error: [TalkAction Interface] 
[31/07/2009 00:43:28] in a timer event called from: 
[31/07/2009 00:43:28] data/talkactions/scripts/GuildWar.lua:onSay

[31/07/2009 00:43:28] luaAddEvent(). callback parameter should be a function.

I think you should change AddEvent for a function

Sorry for my english
 
when i say /war-challenge map1 after 15 sec in console show this:
Code:
[31/07/2009 00:43:28] Lua Script Error: [TalkAction Interface] 
[31/07/2009 00:43:28] in a timer event called from: 
[31/07/2009 00:43:28] data/talkactions/scripts/GuildWar.lua:onSay

[31/07/2009 00:43:28] luaAddEvent(). callback parameter should be a function.

I think you should change AddEvent for a function

Sorry for my english

Which tfs do you use?
 
i use tfs 0.3.3

I solve this problem.

Put this code in GuildWar.lua on talkactions/scripts
Code:
dofile("./GuildWar.lua")

Maps = {
	["map1"] = 
		{
			Guild1Pos = {x=2163, y=487, z=7},
			Guild2Pos = {x=2186, y=490, z=7}
		},
	["map2"] =
		{
			Guild1Pos = {x=2186, y=490, z=6},
			Guild2Pos = {x=1000, y=1003, z=6}			
		}
	}

function onSay(cid, words, param)
	if getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER then
		local myGuild = getPlayerGuildId(cid)
		if words == "/war-invite" then
			if GuildIsInPEace(myGuild) == true then
				if param ~= "" then
					if guildExist(param) ~= LUA_ERROR then
						local invitedGuild = getGuildId(param)
						if invitedGuild ~= LUA_ERROR then
							if invitedGuild ~= myGuild then
								if GuildIsInPEace(invitedGuild) == true then
									doInviteToWar(myGuild, invitedGuild)
									doBroadcastMessage(BroadCast[1][1] ..getPlayerGuildName(cid).. BroadCast[1][2] ..getGuildNameById(invitedGuild).. BroadCast[1][3], BroadCast_Type)
								else
									doPlayerSendCancel(cid, CancelMessagesWar[6])
								end
							else
								doPlayerSendCancel(cid, CancelMessagesWar[8])
							end
						else
							doPlayerSendCancel(cid, CancelMessagesWar[4])
						end
					else
						doPlayerSendCancel(cid, CancelMessagesWar[4])
					end
				else
					doPlayerSendCancel(cid, CancelMessagesWar[7])
				end
			else
				doPlayerSendCancel(cid, CancelMessagesWar[5])
			end
		elseif words == "/war-accept" then
			if getGuildWarInfo(myGuild).By ~= 0 then
				local enemyGuild = getGuildWarInfo(myGuild).By
				doBroadcastMessage(BroadCast[2][1] ..getPlayerGuildName(cid).. BroadCast[2][2] ..getGuildNameById(enemyGuild).. BroadCast[2][3], BroadCast_Type)
				WarAccept(myGuild, enemyGuild)
			else
				doPlayerSendCancel(cid, CancelMessagesWar[1])
			end
		elseif words == "/war-reject" then
			if getGuildWarInfo(myGuild).By ~= 0 then
				doBroadcastMessage(BroadCast[3][1] ..getPlayerGuildName(cid).. BroadCast[3][2] ..getGuildNameById(getGuildWarInfo(myGuild).By).. BroadCast[3][3], BroadCast_Type)
				cleanInfo(getGuildWarInfo(myGuild).By)
				cleanInfo(myGuild)
			else
				doPlayerSendCancel(cid, CancelMessagesWar[1])	
			end
		elseif words == "/war-cancel-invite" then
			if getGuildWarInfo(myGuild).To ~= 0 then
				if getGuildWarInfo(myGuild).With == 0 then
					doBroadcastMessage(BroadCast[4][1] ..getPlayerGuildName(cid).. BroadCast[4][2] ..getGuildNameById(getGuildWarInfo(myGuild).To).. BroadCast[4][3], BroadCast_Type)
					cleanInfo(getGuildWarInfo(myGuild).To)
					cleanInfo(myGuild)
				else
					doPlayerSendCancel(cid, CancelMessagesWar[3])
				end
			else
				doPlayerSendCancel(cid, CancelMessagesWar[1])	
			end
		elseif words == "/war-challenge" then
			local map = Maps[param]
			if map then
				if getGuildWarInfo(myGuild).With ~= 0 then
					local enemyGuild = getGuildWarInfo(myGuild).With
					
					teleportGuild(myGuild, Maps["map1"].Guild1Pos)
					teleportGuildEnemy(enemyGuild, Maps["map1"].Guild2Pos)
					putWarOn(myGuild, enemyGuild)
					
					doBroadcastMessage(BroadCast[5][1] ..getPlayerGuildName(cid).. BroadCast[5][2] ..getGuildNameById(enemyGuild).. BroadCast[5][3] .. param ..".", BroadCast_Type)
				else
					doPlayerSendCancel(cid, CancelMessagesWar[10])
				end
			else
				doPlayerSendCancel(cid, CancelMessagesWar[9])
			end
		elseif words == "/war-cancel" then
			local enemy = getGuildWarInfo(myGuild).With
			if enemy ~= 0 then
				if (os.time() - getGuildWarInfo(myGuild).T) >= (60 * DelayToCancel) then
					StopWar(myGuild, enemy)
					doBroadcastMessage(BroadCast[6][1] ..getGuildNameById(myGuild).. BroadCast[6][2] ..getGuildNameById(enemy).. BroadCast[6][3], BroadCast_Type)
				else
					doPlayerSendCancel(cid, CancelMessagesWar[11])
				end
			else
				doPlayerSendCancel(cid, CancelMessagesWar[10])
			end
		end
	else
		doPlayerSendCancel(cid, CancelMessagesWar[2])
	end
	local file = io.open("data/logs/Wars.txt", "a") 
	file:write("".. os.date("%d %B %Y %X ", os.time()) .." -->  "..getCreatureName(cid)..": "..words.." "..param.."\n") 
	file:close() 
	return TRUE
end

function teleportGuild(id, pos)
	local Members = getOnlineMembers(id)
	if #Members > 0 then
		for i = 1, #Members do
			if getTilePzInfo(getCreaturePosition(Members[i])) == TRUE then
				doTeleportThing(Members[i], pos, FALSE)
				doSendMagicEffect(pos, CONST_ME_TELEPORT)
				doSendMagicEffect(getCreaturePosition(Members[i]), CONST_ME_POFF)
			else
				doBroadcastMessage("You must be in Protection Zone (PZ).", BroadCast_Type)
			end
		end
	end
end

function teleportGuildEnemy(id, pos)
	local Members = getOnlineMembers(id)
	if #Members > 0 then
		for i = 1, #Members do
			if getTilePzInfo(getCreaturePosition(Members[i])) == TRUE then
				doTeleportThing(Members[i], pos, FALSE)
				doSendMagicEffect(pos, CONST_ME_TELEPORT)
				doSendMagicEffect(getCreaturePosition(Members[i]), CONST_ME_POFF)
			else
				doBroadcastMessage("You must be in Protection Zone (PZ).", BroadCast_Type)
			end
		end
	end
end

function putWarOn(myGuild, enemyGuild)
	db.executeQuery("UPDATE `guilds` SET `war_time`  = 1 WHERE `id` = ".. myGuild .."")
	db.executeQuery("UPDATE `guilds` SET `war_time`  = 1 WHERE `id` = ".. enemyGuild .."")
end

This is very simple solv and have a mistakes, but now command /war-challenge map1 is active :thumbup:

PS. all members online must be in protection zone to can be teleported
 
I'm not good scripter ;) i only test it on tfs 0.3.3 becouse i use this version.

Please give me rep if i help you
 
Thanks Adir for fix the challenge.

I won't do this system for 0.2 cos' I use 0.3.

It works on 0.3.5, yes.
 
when 1 player is killed by 2 characters for example
Killed at level 7 by GOD and by Asdx.
u have 2 frags on site count.
Could u fix it ?
Testermen

GOD

03/08/09 14:33:50
Testermen

Asdx

03/08/09 14:33:50
 
"The Following Errors Have Occurred:
Guild with ID 0 doesn't exist."

wtf??
 
Fix for multiple counting one death. Works on 0.3.5_SVN, dunno if previous versions have lastHit arg on onKill function.


Code:
dofile("./GuildWar.lua")

local PZ = createConditionObject(CONDITION_INFIGHT)
setConditionParam(PZ, CONDITION_PARAM_TICKS, getConfigInfo('whiteSkullTime'))

function onKill(cid, target, lastHit)
        if isPlayer(cid) == TRUE and isPlayer(target) == TRUE then
                local myGuild = getPlayerGuildId(cid)
                local enemyGuild = getPlayerGuildId(target)
                if myGuild ~= 0 and enemyGuild ~= 0 then
                        if enemyGuild == getGuildWarInfo(myGuild).With then
                                doAddCondition(cid, PZ)
                                if lastHit == TRUE then
                                    registerDeath(myGuild, enemyGuild, cid, target)
                                end
                                doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "This frag will not count!")
                        end
                end
        end
        return TRUE
end

Repp++ me.
 
Last edited:
Guys i need to add my "guild war" section. But it doesn't work. I add it to my index.php but it doesnt show up!, help me any!
 
Status
Not open for further replies.
Back
Top