• 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.4] OnLook Show "Nickname" depending of storage.

secondlife

Member
Joined
Aug 1, 2009
Messages
298
Reaction score
23
Hi guys,
I'm trying to make a script that when giving the character a look, return a certain "nickname" depending on the storage.

Example:
If the player has 30001 storage, show Hunter when giving a look;
If the player has 30002 storage, show Assassin when giving a look;
If the player has 30003 storage, show Killer Spree when giving a look.

...
Here is my look.lua
Lua:
function onLook(cid, thing, position, lookDistance)
        function getKillsPlayer(cid)
            local Info = db.getResult("SELECT `frags` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
                local frags= Info:getDataInt("frags")
                    return frags
            end

        function getDeathsPlayer(cid)
            local Info = db.getResult("SELECT `deaths` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
                local deaths= Info:getDataInt("deaths")
                    return deaths
            end
        if isPlayer(thing.uid) then
local kdr = getKillsPlayer(thing.uid)/getDeathsPlayer(thing.uid)
                doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and "\nShe" or "\nHe") .. " has Killed: ["..getKillsPlayer(thing.uid).."] Players."..(getPlayerSex(thing.uid) == 0 and "\nShe" or "\nHe") .. " has Died: ["..getDeathsPlayer(thing.uid).."] Times.\nThe Kdr(Kill Death Ratio) is: ["..kdr.."].")
            end
        if(thing.uid == cid) then
local kdr = getKillsPlayer(thing.uid)/getDeathsPlayer(thing.uid)
                doPlayerSetSpecialDescription(thing.uid, "\nYou have Killed: ["..getKillsPlayer(thing.uid).."] Players.\nYou have Died: ["..getDeathsPlayer(thing.uid).."] Times.\nYou Kdr(Kill Death Ratio) is: ["..kdr.."].")
            end
            return true
        end

Like this:
14:51 You see Giddeon (Level 8). He is a elite knight (Hunter).

If the player doesn't have any of the storages, he doesn't need to show anything, only:
14:51 You see Giddeon (Level 8). He is a elite knight.

Can someone help me?
Many thanks!
 
Solution
If he is only supposed to have 1 nickname.
Lua:
local nickname = ""
if getCreatureStorage(thing.uid, 30001) > 0 then
    nickname = "(Hunter)"
elseif getCreatureStorage(thing.uid, 30002) > 0 then
    nickname = "(Assassin)"
elseif getCreatureStorage(thing.uid, 30003) > 0 then
    nickname = "(Killer Spree)"
end
If he can get multiple nicknames
Lua:
local nickname = ""
if getCreatureStorage(thing.uid, 30001) > 0 then
    nickname = "(Hunter)"
end
if getCreatureStorage(thing.uid, 30002) > 0 then
    nickname= nickname .. "(Assassin)"
end
if getCreatureStorage(thing.uid, 30003) > 0 then
    nickname = nickname .. "(Killer Spree)"
end
In both cases add nickname into the character special description. lines 15/19
Or re-create the " You see...
If he is only supposed to have 1 nickname.
Lua:
local nickname = ""
if getCreatureStorage(thing.uid, 30001) > 0 then
    nickname = "(Hunter)"
elseif getCreatureStorage(thing.uid, 30002) > 0 then
    nickname = "(Assassin)"
elseif getCreatureStorage(thing.uid, 30003) > 0 then
    nickname = "(Killer Spree)"
end
If he can get multiple nicknames
Lua:
local nickname = ""
if getCreatureStorage(thing.uid, 30001) > 0 then
    nickname = "(Hunter)"
end
if getCreatureStorage(thing.uid, 30002) > 0 then
    nickname= nickname .. "(Assassin)"
end
if getCreatureStorage(thing.uid, 30003) > 0 then
    nickname = nickname .. "(Killer Spree)"
end
In both cases add nickname into the character special description. lines 15/19
Or re-create the " You see Giddeon (Level 8). He is a elite knight." and append it to the end of that, and return false onLook function so that the default look function doesn't show up.
 
Solution
Back
Top