TalkAction Mute Target

Status
Not open for further replies.

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,876
Best answers
0
Reaction score
19
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:

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
158
In 0.3.5~ you can use:
Code:
doMutePlayer(cid, time)
 
OP
Sync

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,876
Best answers
0
Reaction score
19
Location
Canada
Its bugged. Cause you cant add a condition. Its bugged so we had to go to the extreme to make it work xd
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
Yeah, someone should report the bug.
 

Singed

New Member
Joined
Apr 20, 2009
Messages
112
Best answers
1
Reaction score
2
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
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
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
 

Xaiman

New Member
Joined
Feb 27, 2010
Messages
94
Best answers
0
Reaction score
0
[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?
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
[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?
 

Xaiman

New Member
Joined
Feb 27, 2010
Messages
94
Best answers
0
Reaction score
0
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
 

Xaiman

New Member
Joined
Feb 27, 2010
Messages
94
Best answers
0
Reaction score
0
[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.
 

Boza

New Member
Joined
Feb 16, 2010
Messages
184
Best answers
0
Reaction score
0
Any way to make this work with 0.3.6?
 
Status
Not open for further replies.
Top