• 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 From 0.3.6 to 0.4

Joined
Jun 19, 2009
Messages
1,852
Reaction score
5
Hello!

LUA:
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
            doAddBanishment(accId, lenght * 3600, 23, ACTION_BANISHMENT, comment, getPlayerGUID(cid), comment)
            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

From Gesior.pl

I had this script when I used 0.3.6 and it worked perfectly. But when I changed to 0.4, it doesn't work... can someone fix it? :)

Thanks, I'd really appreciate it!

Edit: when I say /ban, it works, it says "You must enter character name" but when I say /ban <charname> nothing happens
 
[22:51:49.802] data/talkactions/scripts/ban.lua:17: attempt to call global 'doAd
dBanishment' (a nil value)
[22:51:49.802] stack traceback:
[22:51:49.802] data/talkactions/scripts/ban.lua:17: in function <data/talkactio
ns/scripts/ban.lua:4>

in console
 
Code:
local comment = ""
local length = 1 -- ban time in hours

function onSay(cid, words, param)
	local param = string.explode(param, ",")
	if param[1] then
		local accId = getAccountIdByName(param[1])
		if accId > 0 then
			if param[2] and tonumber(param[2]) and tonumber(param[2]) > 0 then
				length = tonumber(param[2])
			end
			if param[3] then
				comment = param[3]
			end
			doAddAccountBanishment(accId, getPlayerGUIDByName(param[1]), length * 3600, 23, ACTION_BANISHMENT, comment, getPlayerGUID(cid))
			local player = getPlayerByNameWildcard(param[1])
			if isPlayer(player) then
				doRemoveCreature(player)
			end
		else
			doPlayerSendCancel(cid, "Player with name " .. param[1] .. " doesn't exist.")
		end
	else
		doPlayerSendCancel(cid, "You must enter a player name.")
	end
	return true
end
 
Back
Top