What's new

Talkactions system wyciszenia gracza - mute/unmute

Sooh

Advanced User
Joined
Jun 26, 2014
Messages
489
Reaction score
26
Age
28
Siemka, nudzi?o mi si? troszku i postanowi?em zrobi? ma?y system muta, przyda si? ka?demu kogo denerwuj? gracze spamuj?c na serwie.

tworzymy sobie 2 pliczki mute i unmute w talkactions
Code:
<talkaction log="yes" words="/mute" access="5" script="mute/add.lua"/>
<talkaction log="yes" words="/unmute" access="5" script="mute/remove.lua"/>

add.lua
Code:
function onSay(cid, words, param, channel)

	local system = "SYSTEM: MUTE"

	if param == "" then
		doPlayerPopupFYI(cid, system .. "\nPlease use command\n/mute character, time (minutes)");
	return true
	end

	local t = string.explode(param, ",")
	local player = getPlayerByName(t[1])

	if (isPlayer(player) == FALSE) then
		doPlayerPopupFYI(cid, system .. "\n" .. t[1] .. " was not found.");
	return true
	end

	if (t[2]) then
		minutes = t[2]
		else
		minutes = 15
	end
	
    local c = {}
    c.time = minutes
    c.player = player
	
	if (getCreatureCondition(c.player, CONDITION_MUTED)) then
		doPlayerPopupFYI(cid, system .. "\n" .. getPlayerName(player) .. " is already muted.");
	return true
	end
	
    doMutePlayer(c.player, c.time * 60)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have muted " .. c.player .. " for " .. minutes .. " minutes.")
    doPlayerSendTextMessage(c.player, MESSAGE_STATUS_CONSOLE_BLUE, "You have been muted for " .. minutes .. " minutes.")
	setPlayerStorageValue(c.player, configure["mute:storage"], os.time() + c.time * 60)

return true
end

remove.lua
Code:
function onSay(cid, words, param, channel)

	local system = "SYSTEM: MUTE"

	if param == "" then
		doPlayerPopupFYI(cid, system .. "\nPlease use command\n/mute character, time (minutes)");
	return true
	end

	local t = string.explode(param, ",")
	local player = getPlayerByName(t[1])

	if (isPlayer(player) == FALSE) then
		doPlayerPopupFYI(cid, system .. "\n" .. t[1] .. " was not found.");
	return true
	end

    local c = {}
    c.player = player
	
	if (not(getCreatureCondition(c.player, CONDITION_MUTED))) then
		doPlayerPopupFYI(cid, system .. "\n" .. getPlayerName(player) .. " is not muted.");
	return true
	end

    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have unmuted " .. c.player .. ".")
    doPlayerSendTextMessage(c.player, MESSAGE_STATUS_CONSOLE_BLUE, "You have been unmuted.")
	
    doRemoveCondition(c.player, CONDITION_MUTED)
	setPlayerStorageValue(c.player, configure["mute:storage"], 0)

return true
end

i jeszcze ma?y fix do creaturescripts dok?adnie do login.lua
fix polega na tym ?e jak gracz si? przeloguje to dostaje na nowo muta z brakuj?cym czasem ...

Code:
-- mute system
local m = getPlayerStorageValue(cid, configure["mute:storage"])
if (m > os.time()) then
	doMutePlayer(cid, m - os.time())
end

WA?NE configure["mute:storage"] nale?y podmieni? na sw?j storage np: 33500 u mnie to jest wczytywane z liba ;p

pozdro
 
Top