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

[REQUEST] Ban script

Try that:

PHP:
local default_comment = ""
local default_lenght = 1 -- ban time in hours

function onSay(cid, words, param)
    local parametres = string.explode(param, ",")
    if(parametres[1] ~= nil) then
        local accId = getAccountIdByName(parametres[1])
        if(accId > 0) then
            local lenght = default_lenght
            local comment = default_comment
            if(parametres[2] ~= nil and tonumber(parametres[2]) > 0) then
                lenght = tonumber(parametres[2])
            end
            if(parametres[3] ~= nil) then
                comment = parametres[3]
            end
            local player = getPlayerByNameWildcard(parametres[1])
            if(isPlayer(player) == TRUE) then
                doRemoveCreature(player)
            end
        else
            doPlayerSendCancel(cid, "Player with name " .. parametres[1] .. " doesn't exist.")
        end
    else
        doPlayerSendCancel(cid, "You must enter name.")
    end
    return true
end

Or this other:

PHP:
--[[BY HERMES @ OTLAND
	REASONS (POPULAR):
		4-offensive-statement,
		5-spamming,
		6-advertising,
		10-bug-abuse,
		12-unofficial-soft
		13-hacking,
		14-multi-clienting,
		15-account-trading-or-sharing,
		16-threatening-gamemaster,
		18-false-report-to-gm,
		19-destructive-behavior,
		20-excessive-unjustified-player-killing
	USAGE:
		/ban playerName, banType, banLength, comment
	DEFAULT:
		length: time in seconds
		comment: default comment (if param is nil)
		reason: number, read text above
 
]]
 
local default = {
	length = 24 * 60 * 60,
	comment = "Stop the use of ilegal software!",
	reason = 12
}
 
function getPlayerTesti(cid)
    local Tiedot = db.getResult("SELECT `id` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
    if Tiedot:getID() ~= LUA_ERROR then
        local account = Tiedot:getDataInt("id")
        return account
    end
     return LUA_ERROR
end
 
function onSay(cid, words, param)
	local t = string.explode(param, ",")
	if(not t[1]) then
		doPlayerSendCancel(cid, "You must enter name.")
		return true
	end
 
	local player = getPlayerByName(t[1])
	if(not isPlayer(player)) then
		doPlayerSendCancel(cid, "Player with name `" .. t[1] .. "` not found.")
		return true
	end
 
	local action = t[2]
	if(not t[2] or (t[2] and type(t[2]) ~= 'string')) then
		doPlayerSendCancel(cid, "Wrong param.")
		return true
	end
 
	local length = (t[3] and tonumber(t[3]) > 0) and t[3] or default.length
	local comment = (t[4] and type(t[4]) == "string") and t[4] or default.comment
	if(isInArray({"account", "acc", "a"}, action)) then
		doAddAccountBanishment(getAccountIdByName(t[1]), getPlayerGUID(t[1]), os.time() + length, default.reason, comment, ACTION_BANISHMENT, comment, getPlayerGUID(cid))
		result = true
	--[[
	elseif(isInArray({"player", "p"}, action)) then
		--type missing
		doAddPlayerBanishment(getPlayerGUID(t[1]), type, os.time() + length, default.reason, ACTION_BANISHMENT, comment, getPlayerGUID(cid))
		result = true
	elseif(isInArray({}, action)) then
		--ip and mask missing
		doAddIpBanishment(ip, mask, os.time() + length, default.reason, comment, getPlayerGUID(cid))
		result = true
	elseif(isInArray({}, action)) then
		doAddNotation(getAccountIdByName(t[1]), getPlayerGUID(t[1]), default.reason, comment, getPlayerGUID(cid))
		result = true
	elseif(isInArray({}, action)) then
		--channelId missing
		doAddStatement(getPlayerGUID(t[1]), channelId, default.reason, comment, getPlayerGUID(cid))
		result = true
	]]
	end
 
	if(result) then
		db.executeQuery("INSERT INTO `bans` (`id` ,`type` ,`value` ,`param`, `active`, `expires`, `added`, `comment`, `reason`, `action`) VALUES ('id', '3', '".. getPlayerTesti(player) .."', '45', '1', '".. os.time() + length .."', '".. os.time() .."', '".. comment .."', '12', '2' );")
		doSendAnimatedText(getCreaturePosition(player), "BANISHED", TEXTCOLOR_RED)
		doRemoveCreature(player)
	end
	return true
end
 
Back
Top