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

error in who your enemy on war.lua

megazx

Graphic designer
Joined
Mar 4, 2013
Messages
443
Solutions
2
Reaction score
32
Location
Egypt
[28/04/2013 14:35:50] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/war.lua:4: 'end' expected (to close 'function' at line 1) near 'else'
[28/04/2013 14:35:50] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/war.lua)
[28/04/2013 14:35:50] data/creaturescripts/scripts/war.lua:4: 'end' expected (to close 'function' at line 1) near 'else'


PHP:
function onLogin(cid)
	if ( getCreatureGuildEmblem(cid,cid) == EMBLEM_NONE) then
	end
        else then
local guild, enemy, guildFrags, enemyFrags = getPlayerGuildId(cid)
local fightingGuilds = {}
local tmp = db.getResult("SELECT `guild_id`, `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `guild_id` = "..guild.." OR `enemy_id` = "..guild.." AND `status` = 1;")
if tmp:getID() ~= -1 then
	i = 1
	repeat
		if tmp:getDataInt("guild_id") == guild then
			enemy = tmp:getDataInt("enemy_id")
			guildFrags = tmp:getDataInt("guild_kills")
			enemyFrags = tmp:getDataInt("enemy_kills")
		else
			enemy = tmp:getDataInt("guild_id")
			guildFrags = tmp:getDataInt("enemy_kills")
			enemyFrags = tmp:getDataInt("guild_kills")
		end
		local enemyName, _tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
		if(_tmp:getID() ~= -1) then
			enemyName = _tmp:getDataString("name")
			_tmp:free()
 
		end
 
		fightingGuilds[i] = {}
		fightingGuilds[i].name = enemyName
		fightingGuilds[i].guildFrags = guildFrags
		fightingGuilds[i].enemyFrags = enemyFrags
		fightingGuilds[i].limit = tmp:getDataInt("frags")
 
		i = i + 1
	until not(tmp:next())
	tmp:free()
 
	table.sort(fightingGuilds, function (a, b)
		return (a.name < b.name)
	end)
 
	local warString = ""
 
	for k, v in pairs(fightingGuilds) do
		if (v.guildFrags < v.limit and v.enemyFrags < v.limit) then
			if not warString then
				warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
			else
				warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
			end
		end
	end
 
	if (warString ~= "") then 
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, warString .. ".")
	end
end
                 end
		return true
		end

- - - Updated - - -

i need help to fix it

- - - Updated - - -

bumb
 
Add it like this in login.lua, the red part.
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end
    
[COLOR=#ff0000]local guild, enemy, guildFrags, enemyFrags = getPlayerGuildId(cid)
local fightingGuilds = {}
local tmp = db.getResult("SELECT `guild_id`,  `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `status` = 1 and (`guild_id` = "..getPlayerGuildId(cid).." or  `enemy_id` = "..getPlayerGuildId(cid).. ")  ;")
warString = ""
if tmp:getID() ~= -1 then
    i = 1
 
    repeat
 
        if tmp:getDataInt("guild_id") == guild   then
            enemy = tmp:getDataInt("enemy_id")
            guildFrags = tmp:getDataInt("guild_kills")
            enemyFrags = tmp:getDataInt("enemy_kills")
        else
            enemy = tmp:getDataInt("guild_id")
            guildFrags = tmp:getDataInt("enemy_kills")
            enemyFrags = tmp:getDataInt("guild_kills")
        end
        local enemyName, _tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
        if(_tmp:getID() ~= -1) then
            enemyName = _tmp:getDataString("name")
            _tmp:free()
 
        end
 
        fightingGuilds[i] = {}
        fightingGuilds[i].name = enemyName
        fightingGuilds[i].guildFrags = guildFrags
        fightingGuilds[i].enemyFrags = enemyFrags
        fightingGuilds[i].limit = tmp:getDataInt("frags")
 
        i = i + 1
    until not(tmp:next())
    tmp:free()
 
    table.sort(fightingGuilds, function (a, b)
        return (a.name < b.name)
    end)
 
 
 
    for k, v in pairs(fightingGuilds) do
 
        if (v.guildFrags  < v.limit and v.enemyFrags < v.limit  ) then
            if (warString == "") then
                warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
            else
                warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
            end
        end
    end
 
end
 
if (warString ~= "") then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, warString .. ".")
end[/COLOR]

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        addEvent(valid(doCreatureSay), 500, cid, "Hello, it appears that your character has been locked for name violating rules, what new name would you like to have?", TALKTYPE_PRIVATE_NP, true, cid)
    elseif(accountManager == MANAGER_ACCOUNT) then
        addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to manage your account. If you would like to start over, type {cancel} anywhere.", TALKTYPE_PRIVATE_NP, true, cid)
    else
        addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to create an account or {recover} to recover an account.", TALKTYPE_PRIVATE_NP, true, cid)
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Idle")
    registerCreatureEvent(cid, "Mail")
    if(getPlayerOperatingSystem(cid) >= CLIENTOS_OTCLIENT_LINUX) then
        registerCreatureEvent(cid, "ExtendedOpcode")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "ThankYou")
    registerCreatureEvent(cid, "LevelUp")
    registerCreatureEvent(cid, "FragLook")
    registerCreatureEvent(cid, "InquisitionMonster")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "GuildEvents")
    registerCreatureEvent(cid, "AdvanceSave")
    return true
end
 
i wil try it thx

- - - Updated - - -

when i log in this error comes out


[28/04/2013 16:49:36] Paly has logged in.
[28/04/2013 16:49:36] mysql_real_query(): SELECT `guild_id`, `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `status` = 1 and (`guild_id` = 0 or `enemy_id` = 0) ; - MYSQL ERROR: Table 'realmap.guild_wars' doesn't exist (1146)
[28/04/2013 16:49:38] Paly has logged out.
 
Missing the table guild_wars in your database.

SQL:
CREATE TABLE IF NOT EXISTS `guild_wars` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `guild_id` INT NOT NULL,
  `enemy_id` INT NOT NULL,
  `begin` BIGINT NOT NULL DEFAULT '0',
  `end` BIGINT NOT NULL DEFAULT '0',
  `frags` INT UNSIGNED NOT NULL DEFAULT '0',
  `payment` BIGINT UNSIGNED NOT NULL DEFAULT '0',
  `guild_kills` INT UNSIGNED NOT NULL DEFAULT '0',
  `enemy_kills` INT UNSIGNED NOT NULL DEFAULT '0',
  `status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `status` (`status`),
  KEY `guild_id` (`guild_id`),
  KEY `enemy_id` (`enemy_id`)
) ENGINE=InnoDB;
 
ALTER TABLE `guild_wars`
  ADD CONSTRAINT `guild_wars_ibfk_1` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `guild_wars_ibfk_2` FOREIGN KEY (`enemy_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;
 
ALTER TABLE `guilds` ADD `balance` BIGINT UNSIGNED NOT NULL AFTER `motd`;
 
CREATE TABLE IF NOT EXISTS `guild_kills` (
  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `guild_id` INT NOT NULL,
  `war_id` INT NOT NULL,
  `death_id` INT NOT NULL
) ENGINE = InnoDB;
 
ALTER TABLE `guild_kills`
  ADD CONSTRAINT `guild_kills_ibfk_1` FOREIGN KEY (`war_id`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `guild_kills_ibfk_2` FOREIGN KEY (`death_id`) REFERENCES `player_deaths` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `guild_kills_ibfk_3` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;
 
ALTER TABLE `killers` ADD `war` INT NOT NULL DEFAULT 0;
 
[28/04/2013 17:05:47] > Optimizing table: guild_wars... [success]

- - - Updated - - -

i have no errors now

but there is no war signs on players in war

- - - Updated - - -

do i have to use the the first script in creaturescripts with the one in login.lua that u gave me
 
hay guys i need help

war system works but no guild sign and when invite war i cant put frag limt
 

Similar threads

Back
Top