Lua Title system

Zazeros

Member
Joined
Feb 13, 2012
Messages
22
Reaction score
7
Hello. I'm using 0.4
I need something like this:
Player receive a storage and then gain a title below his name. I got this part, works just fine.

But, I need a talkaction where the player types !title and then show all his titles. He can also use "!title "something"" to change titles, if he have that title i.e, the name that appears below his name.
It it hard to do something like this?
 
Solution
@Xikini I only put the citzen there because in the old script there had to be something there.
There is a way to remove this thing? Like, if the player don't want any title, he can remove it?
In that case, yes.

talkaction /talkaction remove
Lua:
local activeTitleStorage = 45000 -- this storage is set to a title storage number

local titles = {
    [45001] = "soldier",
    [45002] = "warrior",
    [45003] = "duke",
    [45004] = "prince"
}

local function populateTitles(cid)
    local text = "remove"
    for v, k in pairs(titles) do
        if getCreatureStorage(cid, v) > 0 then
            text = text .. ", " .. k
        end
    end
    return text
end

function onSay(cid, words, param, channel)
    if param == "" then...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
Hello. I'm using 0.4
I need something like this:
Player receive a storage and then gain a title below his name. I got this part, works just fine.

But, I need a talkaction where the player types !title and then show all his titles. He can also use "!title "something"" to change titles, if he have that title i.e, the name that appears below his name.
It it hard to do something like this?
Untested, but should work.
Lua:
local activeTitleStorage = 45000 -- this storage is set to a title storage number

local titles = {
    -- [storage] = "Title"
    [45001] = "Title1",
    [45002] = "Title2", -- title is available if the storage is greater then 0
    [45003] = "Title3"
}

local function populateTitles(cid)
    local text = ""
    for v, k in pairs(titles) do
        if getCreatureStorage(cid, v) > 0 then
            if text ~= "" then
                text = text .. ", "
            end
            text = text .. k
        end
    end
    return text
end

function onSay(cid, words, param, channel)
    if param == "" then
        local text = populateTitles(cid)
        if text == "" then
            text = "No titles have been obtained yet."
        else
            text = "Available titles: " .. text .. "."
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, text)
        return true
    end
    local title = param:lower()
    for v, k in pairs(titles) do
        if title == k:lower() then
            if getCreatureStorage(cid, v) > 0 then
                doCreatureSetStorage(cid, activeTitleStorage, v)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Title has been updated.")
                return true
            end
            break
        end
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Title " .. param .. " is either unknown or has not be acquired.")
    return true
end
Lua:
--[[

    what you'll use in the onLook function
  
    local storageValue = getCreatureStorage(cid, activeTitleStorage)
    local title = titles[storageValue]
    if not title then
        title = "None"
    end
  
    print(title)

--]]
 
OP
Z

Zazeros

Member
Joined
Feb 13, 2012
Messages
22
Reaction score
7
@Xikini Oh, very nice. But now I don't know where to put the second script you told me.
Im using the script where shows your frags and I add some stuffs to tell the title, but now I got confused


Lua:
    local t = {

[-1]  = "a citzen",
[0]  = "a soldier",
[1]  = "a warrior",
[2]  = "a duke",
[3]  = "a prince"

}

function onLook(cid, thing, position, lookDistance)


local storage = 3546100
local get_description = t[getPlayerStorageValue(thing.uid, storage)]
local get_sex = (getPlayerSex(thing.uid) == 0 and "She" or "He")
local get_town = getTownName(getPlayerTown(thing.uid))
    

    
    if isPlayer(thing.uid) and thing.uid ~= cid then
        doPlayerSetSpecialDescription(thing.uid," [Frags: "..getPlayerFrags(thing.uid).."] \n ".. get_sex .." is ".. get_description ..".")
        return true
    elseif thing.uid == cid then
        doPlayerSetSpecialDescription(cid," [Frags: "..getPlayerFrags(cid).."] \n You are ".. get_description ..".")
        local string = 'You see yourself.'

If you want to see the full script, just tell me, but i think it is this part
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
@Xikini Oh, very nice. But now I don't know where to put the second script you told me.
Im using the script where shows your frags and I add some stuffs to tell the title, but now I got confused


Lua:
    local t = {

[-1]  = "a citzen",
[0]  = "a soldier",
[1]  = "a warrior",
[2]  = "a duke",
[3]  = "a prince"

}

function onLook(cid, thing, position, lookDistance)


local storage = 3546100
local get_description = t[getPlayerStorageValue(thing.uid, storage)]
local get_sex = (getPlayerSex(thing.uid) == 0 and "She" or "He")
local get_town = getTownName(getPlayerTown(thing.uid))
   

   
    if isPlayer(thing.uid) and thing.uid ~= cid then
        doPlayerSetSpecialDescription(thing.uid," [Frags: "..getPlayerFrags(thing.uid).."] \n ".. get_sex .." is ".. get_description ..".")
        return true
    elseif thing.uid == cid then
        doPlayerSetSpecialDescription(cid," [Frags: "..getPlayerFrags(cid).."] \n You are ".. get_description ..".")
        local string = 'You see yourself.'

If you want to see the full script, just tell me, but i think it is this part
I don't think it'll work the way you have it.

In order to differentiate between the titles you've obtained, it has to be separate storages.

Unless the titles are gained in order.. like you can't become a prince until you've also obtained soldier, warrior and duke already.
 
OP
Z

Zazeros

Member
Joined
Feb 13, 2012
Messages
22
Reaction score
7
Oh, I see. yeah, thinking about it, it has this problem. Any ideia how to adapt this part of the frag script to accept your glorious script?
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
Oh, I see. yeah, thinking about it, it has this problem. Any ideia how to adapt this part of the frag script to accept your glorious script?
I can edit the onLook script to work with the talkaction, if you post the full thing.
 
OP
Z

Zazeros

Member
Joined
Feb 13, 2012
Messages
22
Reaction score
7
@Xikini Here's the code. Thanks
Lua:
function getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}

    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end

    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    }
    return size.day + size.week + size.month
end

function onLogin(cid)
    registerCreatureEvent(cid, "fraglook")
    return true
end


    local t = {

[-1]  = "a citzen",
[0]  = "a soldier",
[1]  = "a warrior",
[2]  = "a duke",
[3]  = "a prince"

}

function onLook(cid, thing, position, lookDistance)


local storage = 3546100
local get_description = t[getPlayerStorageValue(thing.uid, storage)]
local get_sex = (getPlayerSex(thing.uid) == 0 and "She" or "He")
local get_town = getTownName(getPlayerTown(thing.uid))
    

    
    if isPlayer(thing.uid) and thing.uid ~= cid then
        doPlayerSetSpecialDescription(thing.uid," [Frags: "..getPlayerFrags(thing.uid).."] \n ".. get_sex .." is ".. get_description ..".")
        return true
    elseif thing.uid == cid then
        doPlayerSetSpecialDescription(cid," [Frags: "..getPlayerFrags(cid).."] \n You are ".. get_description ..".")
        local string = 'You see yourself.'
        if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
            string = string..' You are '.. getPlayerGroupName(cid) ..'.'
        elseif getPlayerVocation(cid) ~= 0 then
            string = string..' You are '.. getPlayerVocationName(cid) ..'.'
        else
            string = string..' You have no vocation.'
        end
        
        
        if getPlayerGuildId(cid) > 0 then
            string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
            string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
        end

        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
            string = string..'nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
            string = string..'nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
        end

        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
            string = string..'nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
        end
        
        string = string..getPlayerSpecialDescription(cid)..''
        
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string) 
        return false
    end
    return true
end
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
@Xikini Here's the code. Thanks
Lua:
function getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}

    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end

    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    }
    return size.day + size.week + size.month
end

function onLogin(cid)
    registerCreatureEvent(cid, "fraglook")
    return true
end


    local t = {

[-1]  = "a citzen",
[0]  = "a soldier",
[1]  = "a warrior",
[2]  = "a duke",
[3]  = "a prince"

}

function onLook(cid, thing, position, lookDistance)


local storage = 3546100
local get_description = t[getPlayerStorageValue(thing.uid, storage)]
local get_sex = (getPlayerSex(thing.uid) == 0 and "She" or "He")
local get_town = getTownName(getPlayerTown(thing.uid))
 

 
    if isPlayer(thing.uid) and thing.uid ~= cid then
        doPlayerSetSpecialDescription(thing.uid," [Frags: "..getPlayerFrags(thing.uid).."] \n ".. get_sex .." is ".. get_description ..".")
        return true
    elseif thing.uid == cid then
        doPlayerSetSpecialDescription(cid," [Frags: "..getPlayerFrags(cid).."] \n You are ".. get_description ..".")
        local string = 'You see yourself.'
        if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
            string = string..' You are '.. getPlayerGroupName(cid) ..'.'
        elseif getPlayerVocation(cid) ~= 0 then
            string = string..' You are '.. getPlayerVocationName(cid) ..'.'
        else
            string = string..' You have no vocation.'
        end
     
     
        if getPlayerGuildId(cid) > 0 then
            string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
            string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
        end

        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
            string = string..'nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
            string = string..'nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
        end

        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
            string = string..'nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
        end
     
        string = string..getPlayerSpecialDescription(cid)..''
     
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)
        return false
    end
    return true
end
I've added it in, under the assumption that citizen is the default title.

updated onLook function
Lua:
function getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}
  
    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end
  
    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    }
    return size.day + size.week + size.month
end

function onLogin(cid)
    registerCreatureEvent(cid, "fraglook")
    return true
end

local activeTitleStorage = 45000

local titles = {
    -- [45001] = "citizen", -- this appears to be the default title, if no title is assigned?
    [45001] = "soldier",
    [45002] = "warrior",
    [45003] = "duke",
    [45004] = "prince"
}

function onLook(cid, thing, position, lookDistance)
  
    local get_sex = (getPlayerSex(thing.uid) == 0 and "She" or "He")
    -- local get_town = getTownName(getPlayerTown(thing.uid)) -- not used?
  
    local activeTitle = getCreatureStorage(cid, activeTitleStorage)
    local title = titles[activeTitle]
    if not title then
        title = "citizen" -- default title
    end  
  
    if isPlayer(thing.uid) and thing.uid ~= cid then
        doPlayerSetSpecialDescription(thing.uid," [Frags: "..getPlayerFrags(thing.uid).."] \n ".. get_sex .." is a ".. title ..".")
        return true
    elseif thing.uid == cid then
        doPlayerSetSpecialDescription(cid," [Frags: "..getPlayerFrags(cid).."] \n You are a ".. title ..".")
        local string = 'You see yourself.'
        if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
            string = string..' You are '.. getPlayerGroupName(cid) ..'.'
        elseif getPlayerVocation(cid) ~= 0 then
            string = string..' You are '.. getPlayerVocationName(cid) ..'.'
        else
            string = string..' You have no vocation.'
        end
      
      
        if getPlayerGuildId(cid) > 0 then
            string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
            string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
        end
  
        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
            string = string..'nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
            string = string..'nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
        end
  
        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
            string = string..'nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
        end
      
        string = string..getPlayerSpecialDescription(cid)..''
      
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)
        return false
    end
    return true
end
and the updated talkaction
Lua:
local activeTitleStorage = 45000 -- this storage is set to a title storage number

local titles = {
    [45001] = "soldier",
    [45002] = "warrior",
    [45003] = "duke",
    [45004] = "prince"
}

local function populateTitles(cid)
    local text = "citizen"
    for v, k in pairs(titles) do
        if getCreatureStorage(cid, v) > 0 then
            text = text .. ", " .. k
        end
    end
    return text
end

function onSay(cid, words, param, channel)
    if param == "" then
        local text = populateTitles(cid)
        text = "Available titles: " .. text .. "."
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, text)
        return true
    end
    local title = param:lower()
    if title == "citizen" then
        doCreatureSetStorage(cid, activeTitleStorage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Title has been updated.")
        return true
    end
    for v, k in pairs(titles) do
        if title == k:lower() then
            if getCreatureStorage(cid, v) > 0 then
                doCreatureSetStorage(cid, activeTitleStorage, v)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Title has been updated.")
                return true
            end
            break
        end
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Title " .. param .. " is either unknown or has not been acquired.")
    return true
end
 
OP
Z

Zazeros

Member
Joined
Feb 13, 2012
Messages
22
Reaction score
7
@Xikini I only put the citzen there because in the old script there had to be something there.
There is a way to remove this thing? Like, if the player don't want any title, he can remove it?
That is, not abusing you and your goodwill

Edit: Im testing and if you look yourself, it will show your title, but if another player looks you, it will show "he is a citizen"
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
@Xikini I only put the citzen there because in the old script there had to be something there.
There is a way to remove this thing? Like, if the player don't want any title, he can remove it?
In that case, yes.

talkaction /talkaction remove
Lua:
local activeTitleStorage = 45000 -- this storage is set to a title storage number

local titles = {
    [45001] = "soldier",
    [45002] = "warrior",
    [45003] = "duke",
    [45004] = "prince"
}

local function populateTitles(cid)
    local text = "remove"
    for v, k in pairs(titles) do
        if getCreatureStorage(cid, v) > 0 then
            text = text .. ", " .. k
        end
    end
    return text
end

function onSay(cid, words, param, channel)
    if param == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Available titles: " .. populateTitles(cid) .. ".")
        return true
    end
    local title = param:lower()
    if title == "remove" then
        doCreatureSetStorage(cid, activeTitleStorage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Title has been updated.")
        return true
    end
    for v, k in pairs(titles) do
        if title == k:lower() then
            if getCreatureStorage(cid, v) > 0 then
                doCreatureSetStorage(cid, activeTitleStorage, v)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Title has been updated.")
                return true
            end
            break
        end
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Title '" .. param .. "' is either unknown or has not been acquired.")
    return true
end
and onLook function
Lua:
function getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}
 
    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end
 
    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    }
    return size.day + size.week + size.month
end

function onLogin(cid)
    registerCreatureEvent(cid, "fraglook")
    return true
end

local activeTitleStorage = 45000

local titles = {
    [45001] = "soldier",
    [45002] = "warrior",
    [45003] = "duke",
    [45004] = "prince"
}

function onLook(cid, thing, position, lookDistance)
 
    if isPlayer(thing.uid) then
 
        local get_sex = (getPlayerSex(thing.uid) == 0 and "She" or "He")
        -- local get_town = getTownName(getPlayerTown(thing.uid)) -- not used?
     
        local activeTitle = getCreatureStorage(thing.uid, activeTitleStorage)
        local title = titles[activeTitle]
        if not title then
            title = "none" -- default title
        end
     
        if thing.uid ~= cid then
            doPlayerSetSpecialDescription(thing.uid," [Frags: "..getPlayerFrags(thing.uid).."]" .. (title ~= "none" and " \n ".. get_sex .." is a ".. title .. "" or "") .. ".")
            return true
        else
            doPlayerSetSpecialDescription(cid," [Frags: "..getPlayerFrags(cid).."]" .. (title ~= "none" and " \n You are a ".. title .."" or "") .. ".")
            local string = 'You see yourself.'
            if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
                string = string..' You are '.. getPlayerGroupName(cid) ..'.'
            elseif getPlayerVocation(cid) ~= 0 then
                string = string..' You are '.. getPlayerVocationName(cid) ..'.'
            else
                string = string..' You have no vocation.'
            end
     
     
            if getPlayerGuildId(cid) > 0 then
                string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
                string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
            end
     
            if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
                string = string..'nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
                string = string..'nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
            end
     
            if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
                string = string..'nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
            end
     
            string = string..getPlayerSpecialDescription(cid)..''
     
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)
            return false
        end
    end
    return true
end
 
Solution
OP
Z

Zazeros

Member
Joined
Feb 13, 2012
Messages
22
Reaction score
7
@Xikini Dude, works perfectly. But now I wanna know who to remove the title? I need to say "!title remove"? it says "Title remove is either unknown or has not be acquired."
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
@Xikini Dude, works perfectly. But now I wanna know who to remove the title? I need to say "!title remove"? it says "Title remove is either unknown or has not be acquired."
Can you show me a screenshot of you using
!title
and
!title remove
 
OP
Z

Zazeros

Member
Joined
Feb 13, 2012
Messages
22
Reaction score
7
@Xikini Dude, worked perfectly. Are you a God? Thank you very much
Post automatically merged:

@Xikini Im sorry, but i found an error(?). If the title has space, like "the king" or something like that, it will not show up on look (but will show in the titles list)
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
@Xikini Im sorry, but i found an error(?). If the title has space, like "the king" or something like that, it will not show up on look (but will show in the titles list)
That shouldn't happen.
It's just a string.

Are you editing both tables? in the talkaction and the onLook script?

If you only edit the talkaction table, then the onLook script won't know what to display, since it's missing some of the new titles.
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
Oh no, I'm stupid. Sorry
It's all good.

You could move those local values into a global area so you have 1 table and 1 storage for both scripts to pull from

Just put it at the top of data/lib/000-constant.lua

like this.. and also remove both of these 2 things from the talkaction and onLook event.
Lua:
activeTitleStorage = 45000

titles = {
    [45001] = "soldier",
    [45002] = "warrior",
    [45003] = "duke",
    [45004] = "prince"
}
 
Top