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

[9.1+] Talking Signs

Summ

(\/)(;,,;)(\/) Y not?
Staff member
Global Moderator
Joined
Oct 15, 2008
Messages
4,152
Solutions
12
Reaction score
1,107
Location
Germany :O
QtNK8.png


rbw5B.png

globalevents.xml
XML:
	<globalevent name="talkingSigns" interval="2000" event="script" value="talking.lua"/>

globalevents/scripts/talking.lua
Lua:
local config = {
    positions = {
        {pos = {x = 851, y = 972, z = 7}, text = "Hello Sir! How are you?", effects = {CONST_ME_MAGIC_BLUE}},
        {pos = {x = 855, y = 972, z = 7}, text = "How are you?"}
    },
    effects = {CONST_ME_POFF, CONST_ME_TELEPORT, CONST_ME_MAGIC_RED}
}

function onThink(interval)
    local people = getPlayersOnline()
    if #people == 0 then
        return true
    end
    
    for _, info in pairs(config.positions) do
        doPlayerSay(people[1], info.text, TALKTYPE_MONSTER_SAY, false, 0, info.pos)
        if info.effects and #info.effects > 0 then
            doSendMagicEffect(info.pos, info.effects[math.random(#info.effects)])
        elseif config.effects and #config.effects > 0 then
            doSendMagicEffect(info.pos, config.effects[math.random(#config.effects)])
        end
    end
	return true
end


Config Explanation

Lua:
local config = {
    positions = {
        {pos = {x = 851, y = 972, z = 7}, text = "Hello Sir! How are you?", effects = {CONST_ME_MAGIC_BLUE}},
        {pos = {x = 855, y = 972, z = 7}, text = "How are you?"}
    },
    effects = {CONST_ME_POFF, CONST_ME_TELEPORT, CONST_ME_MAGIC_RED}
}

Add new signs just like:
>> {pos = {x = 851, y = 972, z = 7}, text = "Hello Sir! How are you?", effects = {CONST_ME_MAGIC_BLUE}},
If you leave those effects away it will choose a random effect from this table:
>> {CONST_ME_POFF, CONST_ME_TELEPORT, CONST_ME_MAGIC_RED}

Thx.
 
It works great.
Thanks for release :].
 
Good job! Just one note, I tested this on 8.6 and it can make the account manager keep saying 'I don't understand you~' spamming it - making the account manager almost useless. I changed your code a little to fix it.

Lua:
function notAccMan(people)
	local thing = 1
	for v, cid in ipairs(getOnlinePlayers()) do
		if cid == "Account Manager" then 
			thing = thing + 1
		else			
			return thing
		end
		if thing > #people then
			return false
		end
	end
end
 
function onThink(interval)
    local people = getPlayersOnline()
    if #people == 0 then
        return true
    end
	local thing = notAccMan(people)
	if thing == false then return true end
	for _, info in pairs(config.positions) do
       doPlayerSay(people[thing], info.text, TALKTYPE_MONSTER, false, 0, info.pos)
        if info.effects and #info.effects > 0 then
            doSendMagicEffect(info.pos, info.effects[math.random(#info.effects)])
        elseif config.effects and #config.effects > 0 then
            doSendMagicEffect(info.pos, config.effects[math.random(#config.effects)])
        end
    end
 
it doesnt work for me =\ why?? it needs to be in a teleport or it can be in any item?
 
It can be any position.
 
Any tip for 0.2? :)

Code:
[11/02/2013 20:52:52] Lua Script Error: [GlobalEvent Interface] 
[11/02/2013 20:52:53] data/globalevents/scripts/talking.lua:onThink
[11/02/2013 20:52:53] data/globalevents/scripts/talking.lua:10: attempt to call global 'getPlayersOnline' (a nil value)
[11/02/2013 20:52:53] stack traceback:
[11/02/2013 20:52:53] 	[C]: in function 'getPlayersOnline'
[11/02/2013 20:52:53] 	data/globalevents/scripts/talking.lua:10: in function <data/globalevents/scripts/talking.lua:9>
[11/02/2013 20:52:53] [Error - GlobalEvents::think] Failed to execute event: talkingSigns

Hmm, standing still in my mind right now.

Kind Regards,
Eldin.
 
Eldin, for 0.2 Im sure you change getPlayersOnline to getOnlinePlayers
Other than that, it doesnt work for me either. I cannot figoure out the problem.
 
Its messing with my account manager how do I stop it!!!!!


SOLVED BY MYSELF LOL MY DUMB MISTAKE FORGOT TO ADD A EXTRA END TO CLOSE FUNCTION!!!!!


HAVE THIS ERROR


[9/5/2013 7:58:42] [Error - GlobalEvents::think] Couldn't execute event:d
 
Last edited:
[03/06/2013 10:43:24] Lua Script Error: [GlobalEvent Interface]
[03/06/2013 10:43:24] data/globalevents/scripts/talking.lua:eek:nThink
[03/06/2013 10:43:24] data/globalevents/scripts/talking.lua:10: attempt to call global 'getPlayersOnline' (a nil value)
[03/06/2013 10:43:24] stack traceback:
[03/06/2013 10:43:24] [C]: in function 'getPlayersOnline'
[03/06/2013 10:43:24] data/globalevents/scripts/talking.lua:10: in function <data/globalevents/scripts/talking.lua:9>
[03/06/2013 10:43:25] [Error - GlobalEvents::think] Failed to execute event: talkingSigns

thats what i am getting
 
i get this error can someone help please?

[06/07/2013 18:35:38] Lua Script Error: [GlobalEvent Interface]
[06/07/2013 18:35:38] data/globalevents/scripts/talksign.lua:eek:nThink
[06/07/2013 18:35:38] data/globalevents/scripts/talksign.lua:10: attempt to call global 'getPlayersOnline' (a nil value)
[06/07/2013 18:35:38] stack traceback:
[06/07/2013 18:35:38] [C]: in function 'getPlayersOnline'
[06/07/2013 18:35:38] data/globalevents/scripts/talksign.lua:10: in function <data/globalevents/scripts/talksign.lua:9>
[06/07/2013 18:35:38] [Error - GlobalEvents::think] Failed to execute event: talksign
 
Back
Top