• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Editing mute script

Grehy

Killroy
Joined
Nov 21, 2008
Messages
2,631
Reaction score
33
Location
United States
Trying to edit this to jail the player, and unjail them once their time is up;

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])mut
	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

I could easily have it send the player to xx pos when muted, but I have no idea how to send them back out when their time is up. Any help would be appreciated
 
Last edited:
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
[COLOR="Red"]
local templepos = {x=1000, y=1000, z=7}
local jailpos = {x=100, y=100, z=7}[/COLOR]

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)
[COLOR="Red"]		doTeleportThing(Player, jailpos, FALSE)
		addEvent(SendTemple, i * 60000)[/COLOR]
	end
	return TRUE
end

[COLOR="Red"]function SendTemple()
	doTeleportThing(Player, templepos, FALSE)
end[/COLOR]


note im not sure if this will work im guessing here
 
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
[COLOR="Red"]
local templepos = {x=1000, y=1000, z=7}
local jailpos = {x=100, y=100, z=7}[/COLOR]

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)
[COLOR="Red"]		doTeleportThing(Player, jailpos, FALSE)
		addEvent(SendTemple, i * 60000)[/COLOR]
	end
	return TRUE
end

[COLOR="Red"]function SendTemple()
	doTeleportThing(Player, templepos, FALSE)
end[/COLOR]


note im not sure if this will work im guessing here

[19/03/2010 15:00:25] data/talkactions/scripts/jail.lua:1: attempt to get length of local 'str' (a nil value)

Any ideas?
 
[19/03/2010 15:14:14] data/talkactions/scripts/jail.lua:31: unexpected symbol near '*'

Looks like there is an extra parenthesis there, I tried removing one on either side of the * 60000 but it gives me the same error with it, along with the original one

Anyone have any ideas for this?
 
Code:
local conditions = {}
for i = 1, 100 do
	table.insert(conditions, createConditionObject(CONDITION_MUTED))
	setConditionParam(conditions[i], CONDITION_PARAM_TICKS, i * 60000)
end

local templepos = {x=1000, y=1000, z=7}
local jailpos = {x=100, y=100, z=7}

function onSay(cid, words, param)
	if getPlayerGroupId(cid) < 2 then
		return false
	end
	local t = string.explode(param, ",")
	local target = getPlayerByName(t[1])
	t[2] = tonumber(t[2])
	if param == '' or not t[2] 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 not target 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[t[2]])
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have muted " .. getCreatureName(target) .. " for "..t[2].." minutes.")
		doSendMagicEffect(getThingPos(target), CONST_ME_SLEEP)
		doTeleportThing(target, jailpos)
		addEvent(doTeleportThing, t[2] * 60000, target, templepos)
	end
	return true
end
 
ugh

adding this to jail;

Code:
addEvent(doTeleportThing, t[2] * 60000, target, templepos)
		setPlayerStorageValue(tid, 9999)

Returning this error;

[19/03/2010 19:15:08] (luaDoCreatureSetStorage) Creature not found

And using this short test for unjail;

Code:
local templepos = {x= 971, y= 1492, z= 7}
local storage = 9999

function onSay(cid, words, param)
	if getPlayerGroupId(cid) < 2 then
		return false
	end
	
	if(getPlayerStorageValue(tid, storage) < 1)  then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is jailed.")
	end
	return true
end

Getting this large error;

[19/03/2010 19:16:03] [Error - TalkAction Interface]
[19/03/2010 19:16:03] data/talkactions/scripts/unjail.lua:onSay
[19/03/2010 19:16:03] Description:
[19/03/2010 19:16:03] (luaGetCreatureStorage) Creature not found

[19/03/2010 19:16:03] [Error - TalkAction Interface]
[19/03/2010 19:16:03] data/talkactions/scripts/unjail.lua:onSay
[19/03/2010 19:16:03] Description:
[19/03/2010 19:16:03] data/talkactions/scripts/unjail.lua:9: attempt to compare boolean with number
[19/03/2010 19:16:03] stack traceback:
[19/03/2010 19:16:03] data/talkactions/scripts/unjail.lua:9: in function <data/talkactions/scripts/unjail.lua:4>

So, how do I set that value properly in jail and check for it properly in unjail to unmute and temple the player?
 
Code:
local templepos = {x= 971, y= 1492, z= 7}
local storage = 9999

function onSay(cid, words, param, channel)
	local tid = getPlayerByNameWildcard(param)
	if getPlayerGroupId(cid) < 2 then
		return false
	elseif not tid then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Target player is not online.")
	elseif getPlayerStorageValue(tid, storage) < 1 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is not jailed.")
	elseif getPlayerStorageValue(tid, storage) > 0 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player has been unjailed.")
		doTeleportThing(tid, templepos)
		doSendMagicEffect(templepos, CONST_ME_TELEPORT)
		doRemoveCondition(tid, CONDITION_MUTED)
		setPlayerStorageValue(tid, storage, 0)
	end
	return true
end
 
Last edited:
Setting it in /jail I mean

Code:
setPlayerStorageValue(tid, storage, 1)

same error

edit: got it working using

Code:
setPlayerStorageValue(target, 9999, 1)

Thanks again for all the help with this, I really appreciate it
 
Back
Top