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

Lua Jail + Mute command

Wartio

Any game ideas?
Joined
Apr 2, 2010
Messages
457
Reaction score
29
Location
Sweden
Hey guys

i need help with my jail and mute commands in my server, mute command works perfect but when a player is muted and he relog then the mute gets removed from the player..


i need help with:
Jail system i need help with to make it not possible to jail other staff members of group 2 or higher,

Mute command: make it not possible to mute staff members and when a player is muted and relog his mute wont get removed, also they must be able to do spells but not to write.


JAIL:
Code:
-- Default jail time in seconds --
default_jail = 30000
-- The permission you need to jail someone --
grouprequired = 4
-- StorageValue that the player gets --
jailedstoragevalue_time = 1338
jailedstoragevalue_bool = 1339
-- Set the position of the jail: --
jailpos = { x = 999, y = 999, z =15 }
-- Set the position once unjailed: --
unjailpos = { x = 1825, y = 1558, z =7 }
-- auto kicker, dont edit
jail_list = {}
jail_list_work = 0
function checkJailList(param)
    addEvent(checkJailList, 1000, {})
    for targetID,player in ipairs(jail_list) do
        if isPlayer(player) == TRUE then
            if getPlayerStorageValue(player, jailedstoragevalue_time) < os.time() then
                doTeleportThing(player, unjailpos, TRUE)
                setPlayerStorageValue(player, jailedstoragevalue_time, 0)
                setPlayerStorageValue(player, jailedstoragevalue_bool, 0)
                table.remove(jail_list,targetID)
                doPlayerSendTextMessage(player,MESSAGE_STATUS_CONSOLE_ORANGE,'You were kicked from jail! See you later :)')
            end
        else
            table.remove(jail_list,targetID)
        end
    end
end
function onSay(cid, words, param)
    if jail_list_work == 0 then
        jail_list_work = addEvent(checkJailList, 1000, {})
    end
    if param == '' and (words == '!unjail' or words == '/unjail') then
        if getPlayerStorageValue(cid, jailedstoragevalue_time) > os.time() then
            doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You are jailed until ' .. os.date("%H:%M:%S", getPlayerStorageValue(cid, jailedstoragevalue_time)) .. ' (now is: ' .. os.date("%H:%M:%S", os.time()) .. ').')
        else
            if getPlayerStorageValue(cid, jailedstoragevalue_bool) == 1 then
                table.insert(jail_list,cid)
                doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You will be kicked from jail in one second.')
            else
                doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You are not jailed.')
            end
        end
        return TRUE
    end
    local jail_time = -1
    for word in string.gmatch(tostring(param), "(%w+)") do
        if tostring(tonumber(word)) == word then
            jail_time = tonumber(word)
        end
    end
    local isplayer = getPlayerByName(param)
    if isPlayer(isplayer) ~= TRUE then
        isplayer = getPlayerByName(string.sub(param, string.len(jail_time)+1))
        if isPlayer(isplayer) ~= TRUE then
            isplayer = getPlayerByName(string.sub(param, string.len(jail_time)+2))
            if isPlayer(isplayer) ~= TRUE then
                isplayer = getPlayerByName(string.sub(param, string.len(jail_time)+3))
            end
        end
    end
    if jail_time ~= -1 then
        jail_time = jail_time * 60
    else
        jail_time = default_jail
    end
    if words == '!jail' or words == '/jail' then
        if getPlayerGroupId ( cid ) >= grouprequired then
            if isPlayer(isplayer) == TRUE then
                doTeleportThing(isplayer, jailpos, TRUE)
                setPlayerStorageValue(isplayer, jailedstoragevalue_time, os.time()+jail_time)
                setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 1)
                table.insert(jail_list,isplayer)
                doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You jailed '.. getCreatureName(isplayer) ..' until ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (now is: ' .. os.date("%H:%M:%S", os.time()) .. ').')
                doPlayerSendTextMessage ( isplayer, MESSAGE_INFO_DESCR, 'You have been jailed by '.. getCreatureName(cid) ..' until ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (now is: ' .. os.date("%H:%M:%S", os.time()) .. ').')
                return TRUE
            else
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player with this name doesn\'t exist or is offline.")
                return FALSE
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have access to unjail other players.")
            return FALSE
        end
    elseif words == '!unjail' or words == '/unjail' then
        if getPlayerGroupId ( cid ) >= grouprequired then
            if isPlayer(isplayer) == TRUE then
                doTeleportThing(isplayer, unjailpos, TRUE)
                setPlayerStorageValue(isplayer, jailedstoragevalue_time, 0)
                setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 0)
                table.remove(jail_list,targetID)
                doPlayerSendTextMessage(isplayer,MESSAGE_STATUS_CONSOLE_ORANGE,getCreatureName(cid) .. ' let you go out from jail! See you later :)')
                doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You unjailed '.. getCreatureName(isplayer) ..'.')
            else
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player with this name doesn\'t exist or is offline.")
                return FALSE
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have access to unjail other players.")
            return FALSE
        end
    end
    return FALSE
end


MUTE:
Code:
function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return true
    end

    local t = string.explode(param, ",")
    local pid = getPlayerByNameWildcard(t[1])
    if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " is not currently online.")
        return true
    end

    if(getPlayerAccess(cid) <= getPlayerAccess(pid) or getPlayerFlagValue(pid, PLAYERFLAG_CANNOTBEMUTED)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot perform action.")
        return true
    end

    local time = tonumber(t[2])
    if(not time or time <= 0) then
        time = -1
    end

    doMutePlayer(pid, time)
    return true
end
 
change
Code:
if getPlayerGroupId ( cid ) >= grouprequired then
to
Code:
if getPlayerGroupId ( cid ) >= grouprequired and getPlayerAccess(isplayer) < 2 then
should fix so you only can jail people with 0/1 access

as for the second one, i take it doMutePlayer works, but as you said, it resets if you relog
i cant test right now but something like this could fix it
Code:
doMutePlayer(pid, time)
setPlayerStorageValue(pid, "muteTime", .os.time()+time)
and in onLogin.lua
Code:
local time = getPlayerStorageValue(cid, "muteTime")
if  time > os.time() then
doMutePlayer(cid, time-os.time())
this should remute the player for the time left if you try to relog
 
post your updated mute/login.lua
also how does doMutePlayer work? is time milliseconds, seconds, etc?

whats wrong with the first one? it shouldnt be able to jail unless isplayer (which is the target) has access 0 or 1
 
Its in milliseconds,

I just updated the script, im using
https://otland.net/threads/cs-command-mute-fixed.153216/

but now i have 2 more problems.

Mute works, even if player relog hes still muted, but they cant use spells when muted

also i get this error :

7-DKWRs.png
 
Back
Top