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

Popup information (TFS 1.3, Client 8.6)

Lucifer

Active Member
Joined
Dec 27, 2014
Messages
145
Reaction score
33
Location
Sweden
Code:
function onSay(cid, words, param, channel)

    doPlayerPopupFYI(cid, ""..getPlayerName(cid).."'s Information:\n\nLevel: "..getPlayerLevel(cid).."\n\nMana: "..getPlayerMaxMana(cid).."\n\nHealth: "..getCreatureMaxHealth(cid).."\n\nMagic Level: "..getPlayerMagLevel(cid).."\n\nSkills:\nFist: "..getPlayerSkillLevel(cid, 0).."\nClub: "..getPlayerSkillLevel(cid, 1).."\nSword: "..getPlayerSkillLevel(cid, 2).."\nAxe: "..getPlayerSkillLevel(cid, 3).."\nDistance Fighting: "..getPlayerSkillLevel(cid, 4).."\nShielding: "..getPlayerSkillLevel(cid, 5).."\nFishing: "..getPlayerSkillLevel(cid, 6).."\n\n\n\nThis Script Was Last Updated (25/03/18 16:12)")
    return true


Hello friends! I'm trying to fix this which is on TFS 0.4 to TFS 1.3.
Nekiro gave me the first steps but he wants me to learn. I know you don't learn over a day, but the easiest way for me to learn is to get help/look how people do.
So if anyone could help me get this script to TFS 1.3 and maybe add some information for what you need that fuction would help me extremely much.
I don't want to be a scripter, I just want to be able to script small things to servers.

With help from @Nekiro i got this

Code:
function onSay(cid, words, param)
    player:sendPopupFYI(player:getName()) 
    return true
    end

Now I think I have the name (i think). But how do I make it show level now?
 
Solution
Please use string.format for gigantic strings such as this:
LUA:
function onSay(player, words, param)
    local playerInfo = {
        player:getName(),
        player:getLevel(),
        player:getMaxHealth(),
        player:getMaxMana(),
        player:getMagicLevel()
    }
    for skill = SKILL_FIST, SKILL_FISHING do
        playerInfo[#playerInfo+1] = player:getSkillLevel(skill)
    end
    local info = string.format("%s's Information:\n\nLevel: %d\n\nHealth: %d\n\nMana: %d\n\nMagic Level: %d\n\nSkills:\nFist: %d\n\nClub: %d\n\nSword: %d\n\nAxe: %d\n\nDistance: %d\n\nShielding: %d\n\nFishing: %d\n\n", unpack(playerInfo))
    player:popupFYI(info)
    return true
end
This is much more readable.
just use the compat.lua for reference:

LUA:
function onSay(player, words, param)
    player:popupFYI(""..player:getName().."'s Information:\n\nLevel: "..player:getLevel().."\n\nMana: "..player:getMaxMana().."\n\nHealth: "..getCreatureMaxHealth(cid).."\n\nMagic Level: "..getPlayerMagLevel(cid).."\n\nSkills:\nFist: "..getPlayerSkillLevel(cid, 0).."\nClub: "..getPlayerSkillLevel(cid, 1).."\nSword: "..getPlayerSkillLevel(cid, 2).."\nAxe: "..getPlayerSkillLevel(cid, 3).."\nDistance Fighting: "..getPlayerSkillLevel(cid, 4).."\nShielding: "..getPlayerSkillLevel(cid, 5).."\nFishing: "..getPlayerSkillLevel(cid, 6).."\n\n\n\nThis Script Was Last Updated (25/03/18 16:12)")
    return true
end
 
Please use string.format for gigantic strings such as this:
LUA:
function onSay(player, words, param)
    local playerInfo = {
        player:getName(),
        player:getLevel(),
        player:getMaxHealth(),
        player:getMaxMana(),
        player:getMagicLevel()
    }
    for skill = SKILL_FIST, SKILL_FISHING do
        playerInfo[#playerInfo+1] = player:getSkillLevel(skill)
    end
    local info = string.format("%s's Information:\n\nLevel: %d\n\nHealth: %d\n\nMana: %d\n\nMagic Level: %d\n\nSkills:\nFist: %d\n\nClub: %d\n\nSword: %d\n\nAxe: %d\n\nDistance: %d\n\nShielding: %d\n\nFishing: %d\n\n", unpack(playerInfo))
    player:popupFYI(info)
    return true
end
This is much more readable.
 
Solution
Thanks so much @Delusion
I try to understand what all things are for.

Has changed a bit on the script so it shows current hp / mana as well.
looks like this right now.

Code:
function onSay(player, words, param)
    local playerInfo = {
        player:getName(),
        player:getLevel(),
        player:getHealth(),
        player:getMaxHealth(),
        player:getMana(),
        player:getMaxMana(),
        player:getMagicLevel()
    }
    for skill = SKILL_FIST, SKILL_FISHING do
        playerInfo[#playerInfo+1] = player:getSkillLevel(skill)
    end
    local info = string.format("%s's Information:\n\nLevel: %d\nHealth: %d/%d\nMana: %d/%d\nMagic Level: %d\n\nSkills:\n\nFist Fighting: %d\nClub Fighting: %d\nSword Fighting: %d\nAxe Fighting: %d\nDistance Fighting: %d\nShielding: %d\nFishing: %d\n\n\n\nThis script was updated by Delusion", unpack(playerInfo))
    player:popupFYI(info)
    return true
end


Trying to understand the whole script but don't understand everything.

What I understand is

Code:
function onSay (player, words, param)

local playerInfo = {
Player: getName ();
Player: getLevel (),
Player: getHealth (),
Player: getMaxHealth (),
Player: Getmana (),
Player: getMaxMana (),
Player: getMagicLevel ()

   local info = string.format("%s's Information:\n\nLevel: %d\nHealth: %d/%d\nMana: %d/%d\nMagic Level: %d\n\nSkills:\n\nFist Fighting: %d\nClub Fighting: %d\nSword Fighting: %d\nAxe Fighting: %d\nDistance Fighting: %d\nShielding: %d\nFishing: %d\n\n\n\nThis script was updated by Delusion", unpack(playerInfo))
    player:popupFYI(info)
    return true
end

As you put it in that order, it pops up in the same order on popupFyi

But what I don't understand is how all other skills turn up when you just mentioned
Code:
SKILL_FIST, SKILL_FISHING

It has to do with this line, but does not understand this line
Code:
playerInfo [# playerInfo + 1] = player: getSkillLevel (skill)
 
Thanks so much @Delusion
I try to understand what all things are for.

Has changed a bit on the script so it shows current hp / mana as well.
looks like this right now.

Code:
function onSay(player, words, param)
    local playerInfo = {
        player:getName(),
        player:getLevel(),
        player:getHealth(),
        player:getMaxHealth(),
        player:getMana(),
        player:getMaxMana(),
        player:getMagicLevel()
    }
    for skill = SKILL_FIST, SKILL_FISHING do
        playerInfo[#playerInfo+1] = player:getSkillLevel(skill)
    end
    local info = string.format("%s's Information:\n\nLevel: %d\nHealth: %d/%d\nMana: %d/%d\nMagic Level: %d\n\nSkills:\n\nFist Fighting: %d\nClub Fighting: %d\nSword Fighting: %d\nAxe Fighting: %d\nDistance Fighting: %d\nShielding: %d\nFishing: %d\n\n\n\nThis script was updated by Delusion", unpack(playerInfo))
    player:popupFYI(info)
    return true
end


Trying to understand the whole script but don't understand everything.

What I understand is

Code:
function onSay (player, words, param)

local playerInfo = {
Player: getName ();
Player: getLevel (),
Player: getHealth (),
Player: getMaxHealth (),
Player: Getmana (),
Player: getMaxMana (),
Player: getMagicLevel ()

As you put it in that order, it pops up in the same order on popupFyi

But what I don't understand is how all other skills turn up when you just mentioned
SKILL_FIST, SKILL_FISHING

It has to do with this line, but does not understand this line
playerInfo [# playerInfo + 1] = player: getSkillLevel (skill)
It's a loop, since skills are in order you can loop through skills:
Code:
SKILL_FIST
SKILL_CLUB
SKILL_SWORD
SKILL_AXE
SKILL_DISTANCE
SKILL_SHIELD
SKILL_FISHING
Each of these represents the skill's number value (fist being 0, club 1, etc up to fishing) so it's just a normal for loop to get each skill level and insert it to the end of playerInfo.
 
It's a loop, since skills are in order you can loop through skills:
Code:
SKILL_FIST
SKILL_CLUB
SKILL_SWORD
SKILL_AXE
SKILL_DISTANCE
SKILL_SHIELD
SKILL_FISHING
Each of these represents the skill's number value (fist being 0, club 1, etc up to fishing) so it's just a normal for loop to get each skill level and insert it to the end of playerInfo.

so
Code:
[#playerInfo+1]
adds 1 more for each skill up to 6?
Like fist got 0, club 1, sword 2, ax 3, dist 4, shield 5, fish 6?
 
#playerInfo means "size of playerInfo", so when you insert the value in #playerInfo+1 you're appending it as the last (new) entry in the table
 
Please use string.format for gigantic strings such as this:
LUA:
function onSay(player, words, param)
    local playerInfo = {
        player:getName(),
        player:getLevel(),
        player:getMaxHealth(),
        player:getMaxMana(),
        player:getMagicLevel()
    }
    for skill = SKILL_FIST, SKILL_FISHING do
        playerInfo[#playerInfo+1] = player:getSkillLevel(skill)
    end
    local info = string.format("%s's Information:\n\nLevel: %d\n\nHealth: %d\n\nMana: %d\n\nMagic Level: %d\n\nSkills:\nFist: %d\n\nClub: %d\n\nSword: %d\n\nAxe: %d\n\nDistance: %d\n\nShielding: %d\n\nFishing: %d\n\n", unpack(playerInfo))
    player:popupFYI(info)
    return true
end
This is much more readable.
Your code is overly complicated for someone who wants to learn from it. You could include some comments, so he can learn what something is doing
 
Back
Top