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