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

/ban - banned offline player

Laron25

New Member
Joined
Mar 28, 2010
Messages
127
Reaction score
2
Hi, I want to do that if the player is offline it also banned. Someone can help me?

PHP:
function onSay(cid, words, param)
	local t = string.explode(string.lower(param), ",")
	if not t[1] then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") return true
	end
        local player = getPlayerByNameWildcard(t[1]) 
        if(not player)then 
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.") return true 
        end
        local hours,comment = not tonumber(t[2]) and 24 or tonumber(t[2]),not t[3] and "No Reason" or t[3]
		doBroadcastMessage(getCreatureName(player).." was banned by "..getCreatureName(cid).." for "..comment)
			doAddAccountBanishment(getPlayerAccountId(player), target, os.time() + hours*3600*24, 5, 2,comment, 0)
			doRemoveCreature(player)
	return true
end

Thanks for help
LAron

PS: I have a query to the database

PHP:
db.getResult('SELECT `accounts`.`id` FROM `accounts`, `players` WHERE `accounts`.`id` = `players`.`account_id` AND `players`.`name` = ' .. db.escapeString(player) .. ';')
 
your db string should look somthing like this...

function getOfflinePlayerId(player)
local res = db.getResult('SELECT `id` FROM `accounts` WHERE `name`= ' .. db.escapeString(player) .. ';')
return res
end


function getOfflinePlayerName(player)
local res = db.getResult('SELECT `name` FROM `accounts` WHERE `name`= ' .. db.escapeString(player) .. ';')
return res
end


Then you can do
Lua:
if step then
doPlayerAddBanishment(getOfflinePlayerId(cid))
end
 
Back
Top