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

TFS 0.X Always war shield

Lurk

Active Member
Joined
Dec 4, 2017
Messages
336
Reaction score
48
hello, I want everyone in my server to always have the shield emblem on their character (that one of guild wars)
and I know that adding this on my login.lua
Lua:
if getPlayerGuildId(cid) > 0 then
             local guild = getPlayerGuildId(cid)
            doGuildAddEnemy(guild, enemy, 0, WAR_GUILD)
        else
end
will make the shield appear to everyone but doesn't seem like a good option since real guilds wouldn't be able to war against each other since they'd be already in war, and members wouldn't be able to quit theyr guilds since it's in war still. Any ideas?
 
So, I added this to my login.lua
Lua:
if getPlayerLevel(cid) > 0 then
            local guild = getPlayerGuildId(cid)
            local check = db.getResult("SELECT [ICODE]status[/ICODE] FROM [ICODE]guild_wars[/ICODE] WHERE [ICODE]guild_id[/ICODE] = "..guild..";")
            if check ~= 0 then
            else
            doCreatureSetGuildEmblem(cid, EMBLEM_GREEN)
            end
        else
    end
the idea is to not add nothing when the player is already at war since that would change his enemy shield collor. When the player logs in, there are no erros in console but the symbol ain't there. It is working without this check but I really need this check. Ideas?
 
Lua:
if getCreatureGuildEmblem(cid) ~= EMBLEM_NONE then
    doCreatureSetGuildEmblem(cid, EMBLEM_GREEN)
end

If it doesn't work, make sure the emblems are defined in your lib/constants file:
Lua:
EMBLEM_NONE = 0
EMBLEM_GREEN = 1
EMBLEM_RED = 2
EMBLEM_BLUE = 3
 
Last edited:
they are defined in my lib/constants, but the code you provided didn't work
there are no console errors, but when the player logs in there's no emblem
 
I changed the code to
Lua:
if getCreatureGuildEmblem(cid) ~= EMBLEM_NONE then
        print(getCreatureGuildEmblem(cid))
        print(doCreatureSetGuildEmblem(cid, EMBLEM_GREEEN))
        doCreatureSetGuildEmblem(cid, EMBLEM_GREEEN)
    end
and nothing was being printed. So I added the
Lua:
print(getCreatureGuildEmblem(cid))
outside the if and noticed that getCreatureGuildEmblem was returning 0 instead of EMBLEM_NONE. Changed the code to
Lua:
if getCreatureGuildEmblem(cid) == 0 then
        doCreatureSetGuildEmblem(cid, EMBLEM_GREEEN)
    end
and still didn't work..

edit: managed to make it to work
Lua:
if getCreatureGuildEmblem(cid) == 0 then
        doCreatureSetGuildEmblem(cid, EMBLEM_GREEN)
    end
there was an extra E in green...
 
Last edited:
I changed the code to
Lua:
if getCreatureGuildEmblem(cid) ~= EMBLEM_NONE then
        print(getCreatureGuildEmblem(cid))
        print(doCreatureSetGuildEmblem(cid, EMBLEM_GREEEN))
        doCreatureSetGuildEmblem(cid, EMBLEM_GREEEN)
    end
and nothing was being printed. So I added the
Lua:
print(getCreatureGuildEmblem(cid))
outside the if and noticed that getCreatureGuildEmblem was returning 0 instead of EMBLEM_NONE. Changed the code to
Lua:
if getCreatureGuildEmblem(cid) == 0 then
        doCreatureSetGuildEmblem(cid, EMBLEM_GREEEN)
    end
and still didn't work..
EMBLEM_NONE is equal to 0, they are one in the same.
I made a typo by mistake, change GREEEN to GREEN.
 

Similar threads

Back
Top