• 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 doPlayerSetSpecialDescription Question

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,737
Solutions
7
Reaction score
541
Location
Canada
When using "doPlayerSetSpecialDescription" - can you only use it once? Because it seems like if I have multiple onLook scripts that set a special description - only the last one loaded will set the description. My work around right now has been to convert all seperate onLook scripts into a merged script like presented below; but I just wanted to ask, is there a way to load multiple specialDescriptions/onLook scripts in 0.4? For example, one for VIP Check; one for Frag Check; one for Guild Information.

Code:
function onLook(cid, thing, position, lookDistance)

function getDeathsAndKills(cid, type) -- by vodka
    local query,d = db.getResult("SELECT `player_id` FROM "..(tostring(type) == "kill" and "`player_killers`" or "`player_deaths`").." WHERE `player_id` = "..getPlayerGUID(cid)),0
        if (query:getID() ~= -1) then
            repeat
                d = d+1
            until not query:next()
            query:free()
        end
    return d 
end

    if isPlayer(thing.uid) then
        -- Yes Guild/Yes VIP
        if getPlayerGuildId(thing.uid) > 0 and getPlayerVipDays(cid) >= 1 then
                doPlayerSetSpecialDescription(thing.uid, " [VIP Player]. Guild has " .. #getGuildMembers(getPlayerGuildId(thing.uid)) .. " members, and " .. #getGuildMembersOnline(getPlayerGuildId(thing.uid)) .. " of them online. [Kills: ("..getDeathsAndKills(thing.uid, "kill")..") / Deaths: ("..getDeathsAndKills(thing.uid, "death")..")]")
        -- No Guild/Yes VIP
        elseif getPlayerGuildId(thing.uid) == 0 and getPlayerVipDays(cid) >= 1 then
                doPlayerSetSpecialDescription(thing.uid, " [VIP Player]. [Kills: ("..getDeathsAndKills(thing.uid, "kill")..") / Deaths: ("..getDeathsAndKills(thing.uid, "death")..")]")
        -- Yes Guild/No VIP
        elseif getPlayerGuildId(thing.uid) > 0 and getPlayerVipDays(cid) <= 1 then
                doPlayerSetSpecialDescription(thing.uid, " [Non-VIP]. Guild has " .. #getGuildMembers(getPlayerGuildId(thing.uid)) .. " members, and " .. #getGuildMembersOnline(getPlayerGuildId(thing.uid)) .. " of them online. [Kills: ("..getDeathsAndKills(thing.uid, "kill")..") / Deaths: ("..getDeathsAndKills(thing.uid, "death")..")]")
        -- No Guild/No VIP
        elseif getPlayerGuildId(thing.uid) == 0 and getPlayerVipDays(cid) <= 1 then
                doPlayerSetSpecialDescription(thing.uid, " [Non-VIP]. [Kills: ("..getDeathsAndKills(thing.uid, "kill")..") / Deaths: ("..getDeathsAndKills(thing.uid, "death")..")]")
        end
    end
    return true
end
 
Solution
That doesn't answer my question if it can be written in seperate lua files? You did read my post right? I wasnt asking a different way to style the code - my script works, I'm asking if you can only set a custom description once because when I have three seperate scripts that use customDescription and each one rewrites over the last one. Thanks for the random script though?
A better question is why are you setting their special description over and over?
You could just as simply use doPlayerSendTextMessage(cid, MessageClasses, message) and achieve the same thing.

I think we have the problem of trying to use a hammer for every situation.

Why do you want to use doPlayerSetSpecialDescription in an onLook function...
Lua:
 local text = "" 

text = text .. "first part."
text = text .. " second part." 

print(text)
 
Lua:
 local text = ""

text = text .. "first part."
text = text .. " second part."

print(text)

That doesn't answer my question if it can be written in seperate lua files? You did read my post right? I wasnt asking a different way to style the code - my script works, I'm asking if you can only set a custom description once because when I have three seperate scripts that use customDescription and each one rewrites over the last one. Thanks for the random script though?
 
That doesn't answer my question if it can be written in seperate lua files? You did read my post right? I wasnt asking a different way to style the code - my script works, I'm asking if you can only set a custom description once because when I have three seperate scripts that use customDescription and each one rewrites over the last one. Thanks for the random script though?
A better question is why are you setting their special description over and over?
You could just as simply use doPlayerSendTextMessage(cid, MessageClasses, message) and achieve the same thing.

I think we have the problem of trying to use a hammer for every situation.

Why do you want to use doPlayerSetSpecialDescription in an onLook function?
-------------

Beyond that.. my 'random script' is very useful.
It's not a separate 'style' of code.
You will achieve the same thing as your script, without requiring infinite if statements to cover every possible scenario.

Here, let me show you.
Lua:
local function getDeathsAndKills(cid, type) -- by vodka
    local query,d = db.getResult("SELECT `player_id` FROM "..(tostring(type) == "kill" and "`player_killers`" or "`player_deaths`").." WHERE `player_id` = "..getPlayerGUID(cid)),0
        if (query:getID() ~= -1) then
            repeat
                d = d+1
            until not query:next()
            query:free()
        end
    return d
end

function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) then
        local text = ""
        text = text .. " " .. (getPlayerVipDays(cid) >= 1 and "[VIP Player]." or "[Non-VIP].")
        text = text .. " " .. (getPlayerGuildId(thing.uid) > 0 and "Guild has " .. #getGuildMembers(getPlayerGuildId(thing.uid)) .. " members, and " .. #getGuildMembersOnline(getPlayerGuildId(thing.uid)) .. " of them online." or "")
        text = text .. "[Kills: ("..getDeathsAndKills(thing.uid, "kill")..") / Deaths: ("..getDeathsAndKills(thing.uid, "death")..")]"
        doPlayerSetSpecialDescription(thing.uid, text)
    end
    return true
end
 
Solution
@Xikini - Ah okay, last night when I realized the special description was only working from the last script to load in the system; I just rewrote them all together - I didnt think of changing the function since I wanted to know why it was wasnt working and acting the way it was. But you are 100% right, there is no reason to use it if we can set the text the way you did since the special description function is causing issues. Thank you for clearing that up, I will avoid using that function more than once.
 
Back
Top