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

Staff effect

Zadin

New Member
Joined
Apr 12, 2017
Messages
13
Reaction score
0
Hey all,

I want to have an effect for all staff members. I've no idea what kind of file (xml or txt) it have to be and where to put the file. Can someone help me maybe?

tfs 0.2.15

local group = getPlayerGroupId(cid)
local cid = getPlayerByName(name)

function onThink(interval, lastExecution)
for _, name in ipairs(getOnlinePlayers()) do
if group == 1 then
doSendAnimatedText(getPlayerPosition(cid), "Player", TEXTCOLOR_RED)
elseif group == 2 then
doSendAnimatedText(getPlayerPosition(cid), "Tutor", TEXTCOLOR_RED)
elseif group == 3 then
doSendAnimatedText(getPlayerPosition(cid), "Senior Tutor", TEXTCOLOR_RED)
elseif group == 4 then
doSendAnimatedText(getPlayerPosition(cid), "Game Master", TEXTCOLOR_RED)
elseif group == 5 then
doSendAnimatedText(getPlayerPosition(cid), "God", TEXTCOLOR_RED)
elseif group == 6 then
doSendAnimatedText(getPlayerPosition(cid), "Administrator", TEXTCOLOR_RED)
end
end
return true
end

/Zadin
 
Try this

Lua:
local group = getPlayerGroupId(cid)
local cid = getPlayerByName(name)

function onThink(interval, lastExecution)
for _, name in ipairs(getOnlinePlayers()) do
if group == 1 then
doCreatureSay(cid, "Player", 20)
elseif group == 2 then
doCreatureSay(cid, "Tutor", 20)
elseif group == 3 then
doCreatureSay(cid, "Senior Tutor", 20)
elseif group == 4 then
doCreatureSay(cid, "Gamemaster", 20)
elseif group == 5 then
doCreatureSay(cid, "God", 20)
elseif group == 6 then
doCreatureSay(cid, "Administrator", 20)
end
end
return true
end

EDIT: You put this in Globalevents..

in globalevents.XML

Code:
    <globalevent name="effect" interval="1" event="script" value="effect.lua"/>

and name the file, effect
 
Hey all,

I want to have an effect for all staff members. I've no idea what kind of file (xml or txt) it have to be and where to put the file. Can someone help me maybe?

tfs 0.2.15

local group = getPlayerGroupId(cid)
local cid = getPlayerByName(name)

function onThink(interval, lastExecution)
for _, name in ipairs(getOnlinePlayers()) do
if group == 1 then
doSendAnimatedText(getPlayerPosition(cid), "Player", TEXTCOLOR_RED)
elseif group == 2 then
doSendAnimatedText(getPlayerPosition(cid), "Tutor", TEXTCOLOR_RED)
elseif group == 3 then
doSendAnimatedText(getPlayerPosition(cid), "Senior Tutor", TEXTCOLOR_RED)
elseif group == 4 then
doSendAnimatedText(getPlayerPosition(cid), "Game Master", TEXTCOLOR_RED)
elseif group == 5 then
doSendAnimatedText(getPlayerPosition(cid), "God", TEXTCOLOR_RED)
elseif group == 6 then
doSendAnimatedText(getPlayerPosition(cid), "Administrator", TEXTCOLOR_RED)
end
end
return true
end

/Zadin

Try this

Lua:
local group = getPlayerGroupId(cid)
local cid = getPlayerByName(name)

function onThink(interval, lastExecution)
for _, name in ipairs(getOnlinePlayers()) do
if group == 1 then
doCreatureSay(cid, "Player", 20)
elseif group == 2 then
doCreatureSay(cid, "Tutor", 20)
elseif group == 3 then
doCreatureSay(cid, "Senior Tutor", 20)
elseif group == 4 then
doCreatureSay(cid, "Gamemaster", 20)
elseif group == 5 then
doCreatureSay(cid, "God", 20)
elseif group == 6 then
doCreatureSay(cid, "Administrator", 20)
end
end
return true
end

EDIT: You put this in Globalevents..

in globalevents.XML

Code:
    <globalevent name="effect" interval="1" event="script" value="effect.lua"/>

and name the file, effect

Thats the best code I have ever seen :>
First of all, you can't use cid and group like you guys do, cid dosn't exist when you call getPlayerGroupId and name dosn't exist when you call getPlayerByName.
Try this;
Lua:
local groups = {
    [1] = "Player",
    [2] = "Tutor",
    [3] = "Senior Tutor",
    [4] = "Gamemaster",
    [5] = "God",
    [6] = "Administrator"
}

function onThink(interval, lastExecution)
    for _, name in ipairs(getOnlinePlayers()) do
        local cid = getPlayerByName(name)
        local group = groups[getPlayerGroupId(cid)]
        if group then
            doCreatureSay(cid, group, 20)
        end
    end
    return true
end
 
iirc you can use getPlayersOnline(), which holds cid in each index, not name
also you shouldn't do animated text with this since animated text has a limit of 7(?) characters, meaning long text such as Senior Tutor will get cut off and only show Senior
Lua:
local groups = {
    [1] = "Player",
    [2] = "Tutor",
    [3] = "Senior Tutor",
    [4] = "Gamemaster",
    [5] = "God",
    [6] = "Administrator"
}

function onThink(interval, lastExecution)
    for _, cid in ipairs(getPlayersOnline()) do
        local group = groups[getPlayerGroupId(cid)]
        if group then
            doCreatureSay(cid, group, TALKTYPE_MONSTER)
        end
    end
    return true
end
 
iirc you can use getPlayersOnline(), which holds cid in each index, not name
also you shouldn't do animated text with this since animated text has a limit of 7(?) characters, meaning long text such as Senior Tutor will get cut off and only show Senior
Lua:
local groups = {
    [1] = "Player",
    [2] = "Tutor",
    [3] = "Senior Tutor",
    [4] = "Gamemaster",
    [5] = "God",
    [6] = "Administrator"
}

function onThink(interval, lastExecution)
    for _, cid in ipairs(getPlayersOnline()) do
        local group = groups[getPlayerGroupId(cid)]
        if group then
            doCreatureSay(cid, group, TALKTYPE_MONSTER)
        end
    end
    return true
end

Not according to the compat file ;o
forgottenserver/compat.lua at master · otland/forgottenserver · GitHub
 
getOnlinePlayers() is not the same as getPlayersOnline()
getPlayersOnline() is source implemented, uses [index] = creature id, different from [index] = creature name (which is what getOnlinePlayers() does)

Thats the reason why I hate 0.x, nothing makes sence ..
But good to know
 
I still have the same problem..

Is it registerd in your globalevents.xml file?
Do you have any errors in the console?
After
Lua:
function onThink(interval, lastExecution)
Add
Lua:
print("test")

Save the file and restart the server and check if the server printed "test"
 
Back
Top