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

A couple talkaction guild commands.

Drakkhan

Illuria Project Lead
Joined
Oct 3, 2013
Messages
141
Reaction score
22
TFS 0.2.15 (Mystic Spirit) didn't have !invite functionality for my guildleader.. sooo.. I made a couple talkactions to replace that feature. Maybe someone else needs these? If nothing else, there's some informative use of functions! :)

This in global.lua:
Code:
GUILD_BASELINE = 9913000

This in talkactions.xml:
Code:
    <talkaction words="!join" script="joinguild.lua"/>
    <talkaction words="!invitetoguild" script="invite.lua"/>

New script "data/talkactions/scripts/invite.lua":
Code:
function onSay(cid, words, param)

    local GuildID = getPlayerGuildId(cid)
    if getPlayerGuildLevel(cid) == 3 then
        setPlayerStorageValue(getPlayerByName(param), (GUILD_BASELINE + GuildID), 1)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, string.format("%s is invited to the guild!", param))
    else
        doPlayerSendCancel(cid, string.format("The player could not be found."))
    end
end

New script "data/talkactions/scripts/joinguild.lua":
Code:
function onSay(cid, words, param)

    local playerGuildId = getPlayerGuildId(cid)
    local guildToJoin = param

    if(guildToJoin) then
        local guildToJoinId = getGuildId(guildToJoin)
        if(guildToJoinId) then
            if(playerGuildId > 0) then
                doPlayerSendCancel(cid, string.format("You are already in a guild."))
            else
                if getPlayerStorageValue(cid, (GUILD_BASELINE + guildToJoinId)) == 1 then
                    setPlayerStorageValue(cid, (GUILD_BASELINE + guildToJoinId), 2)
                    doPlayerSetGuildId(cid, guildToJoinId)
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, string.format("You have been accepted into %s", param))
                elseif getPlayerStorageValue(cid, (GUILD_BASELINE + guildToJoinId)) == 2 then
                    doPlayerSendCancel(cid, string.format("You are in the guild already."))
                else
                    doPlayerSendCancel(cid, string.format("You are not invited."))
                end
            end
        else
            doPlayerSendCancel(cid, string.format("There is no guild with that name."))
        end
      
    else
        doPlayerSendCancel(cid, string.format("You have failed."))
    end
end

And BOOM you have "!invitetoguild" and "!join" to replace "!invite" and "!joinguild"!!!

Regards,

Drakkhan
 
Is there any way to update this to latest tfs?
I tried to convert files to tfs 1.x but I dont know where can I store this
GUILD_BASELINE = 9913000
It's giving a nil value
code:


Lua:
local GUILD_BASELINE = 9913000
function onSay(player, words, param)
local GuildID = player:getGuild()
if player:getGuildLevel() == 3 then
Player(param):setStorageValue((GUILD_BASELINE + GuildID), 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has been invited to the guild!", param))
else
player:sendCancelMessage(string.format("The player could not be found."))
end
end


Code:
function onSay(player, words, param)

    local playerGuildId = player:getGuild()
    local guildToJoin = param

    if(guildToJoin) then
        local guildToJoinId = Guild(guildToJoin)
        if(guildToJoinId) then
            if(playerGuildId > 0) then
                player:sendCancelMessage(string.format("You are already in a guild."))
            else
                if player:getStorageValue(GUILD_BASELINE + guildToJoinId) == 1 then
                    player:setStorageValue(GUILD_BASELINE + guildToJoinId, 2)
                    player:setGuild(guildToJoinId)
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have been accepted into %s", param))
                elseif player:getStorageValue(GUILD_BASELINE + guildToJoinId) == 2 then
                    player:sendCancelMessage(string.format("You are in the guild already."))
                else
                    player:sendCancelMessage(string.format("You are not invited."))
                end
            end
        else
            player:sendCancelMessage(string.format("There is no guild with that name."))
        end
      
    else
        player:sendCancelMessage(string.format("You have failed."))
    end
end
 
Back
Top