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

TalkAction Mute Target

Status
Not open for further replies.

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,901
Reaction score
26
Location
Canada
Well, after a struggle to get the mute system to work by the help of Cyktotitan we got a pretty cool mute script xD!
Works on 0.2

Lua:
string.explode = function (str, sep)
	local pos, t = 1, {}
	if #sep == 0 or #str == 0 then
		return
	end

	for s, e in function() return str:find(sep, pos) end do
		table.insert(t, str:sub(pos, s - 1):trim())
		pos = e + 1
	end

	table.insert(t, str:sub(pos):trim())
	return t
end

local conditions = {}
for i = 1, 100 do
        table.insert(conditions, createConditionObject(CONDITION_MUTED))
        setConditionParam(conditions[i], CONDITION_PARAM_TICKS, i * 60 * 1000)
end


function onSay(cid, words, param)
	local t = string.explode(param, ",")
	local target = getPlayerByNameWildcard(t[1])

	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires a players name and number.") 
		return TRUE
	end
	if(getPlayerGroupId(target) > 1) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot Mute another Staff member.")
		return TRUE
	end
	if(not target) then
		target = getCreatureByName(param)
		if(not target) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is not online.")
			return TRUE
		end
	end

	doAddCondition(target, conditions[tonumber(t[2])])
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have muted "..getCreatureName(target).." for "..t[2]..".")
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP) 
	return TRUE
end

Code:
/mute Name, Duration -- (Duration is in Minutes)
 
Last edited:
In 0.3.5~ you can use:
Code:
doMutePlayer(cid, time)
 
Its bugged. Cause you cant add a condition. Its bugged so we had to go to the extreme to make it work xd
 
Yeah, someone should report the bug.
 
I get an error on this one saying something about trying to index local t( a value that is nil)

any help?

I'm running TFS 0.2.5
 
Code:
string.explode = function (str, sep) local pos, t = 1, {} if #sep == 0 or #str == 0 then return end for s, e in function() return str:find(sep, pos) end do table.insert(t, str:sub(pos, s - 1):trim()) pos = e + 1 end table.insert(t, str:sub(pos):trim()) return t end
local conditions = {}
for i = 1, 100 do
	table.insert(conditions, createConditionObject(CONDITION_MUTED))
	setConditionParam(conditions[i], CONDITION_PARAM_TICKS, i * 60000)
end

function onSay(cid, words, param)
	if getPlayerGroupId(cid) < 2 then
		return FALSE
	end
	local t = string.explode(param, ",")
	local target = getPlayerByName(t[1])
	if param == '' then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires a player name and a number of minutes.")
	elseif getPlayerGroupId(target) > 1 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot mute another staff member.")
	elseif isPlayer(target) ~= TRUE then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is not online.")
	elseif t[2] > #conditions then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot mute players for more than " .. #conditions .. " minutes.")
	else
		doAddCondition(target, conditions[tonumber(t[2])])
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have muted " .. getCreatureName(target) .. " for "..t[2].." minutes.")
		doSendMagicEffect(getThingPos(target), CONST_ME_SLEEP)
	end
	return TRUE
end
 
[23/03/2010 03:06:00] [Error - TalkAction Interface]
[23/03/2010 03:06:00] data/talkactions/scripts/mute.lua:eek:nSay
[23/03/2010 03:06:00] Description:
[23/03/2010 03:06:00] data/talkactions/scripts/mute.lua:13: attempt to index local 't' (a nil value)


Cyko thats on your script. any help?
 
[23/03/2010 03:06:00] [Error - TalkAction Interface]
[23/03/2010 03:06:00] data/talkactions/scripts/mute.lua:eek:nSay
[23/03/2010 03:06:00] Description:
[23/03/2010 03:06:00] data/talkactions/scripts/mute.lua:13: attempt to index local 't' (a nil value)


Cyko thats on your script. any help?
I don't get it, maybe you haven't specified any param?
 
If your talking about not specifying a param in game then thats not the problem cuz i just doesn't work at all. i have tried /mute /mute name /mute name time. it doesnt do anything. i have looked all throught the script and cant find anything wrong
 
[23/03/2010 13:09:06] [Error - TalkAction Interface]
[23/03/2010 13:09:06] data/talkactions/scripts/Staff/staff.lua:eek:nSay
[23/03/2010 13:09:06] Description:
[23/03/2010 13:09:06] data/talkactions/scripts/mute.lua:1: bad argument #2 to 'insert' (number expected, got string)
[23/03/2010 13:09:06] stack traceback:
[23/03/2010 13:09:06] [C]: in function 'insert'
[23/03/2010 13:09:06] data/talkactions/scripts/mute.lua:1: in function 'explode'
[23/03/2010 13:09:06] data/talkactions/scripts/Staff/staff.lua:4: in function <data/talkactions/scripts/Staff/staff.lua:1>


Also the mute script bugged all other talkactions o.0 when i removed it the all were fixed.
 
Any way to make this work with 0.3.6?
 
Status
Not open for further replies.
Back
Top