Sir Islam
Never Give Up
have fun for all
Request:
[TFS 1.0] namelock/ban reason
talkactions.xml
namelock.lua
how to use
/namelock name,reason
unlock.lua
/unlock name
if you use tfs 1.0
chnage
to
Request:
[TFS 1.0] namelock/ban reason
talkactions.xml
Code:
<talkaction words="/namelock" separator=" " script="namelock.lua" />
namelock.lua
Code:
function onSay(player, words, param)
if not player:getGroup():getAccess() then
return true
end
local name = param
local reason = ''
local separatorPos = param:find(',')
if separatorPos ~= nil then
name = param:sub(0, separatorPos - 1)
reason = string.trim(param:sub(separatorPos + 1))
end
local PlayerGUID = getPlayerGUIDByName(name)
if PlayerGUID == 0 then
return false
end
local timeNow = os.time()
db.query("INSERT INTO `player_namelocks`(`player_id`, `reason`, `namelocked_at`, `namelocked_by`) VALUES (".. PlayerGUID.."," .. db.escapeString(reason) .. ","..timeNow.."," .. player:getGuid() .. ")")
local target = Player(name)
if target ~= nil then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, target:getName() .. " has been Namelock.")
target:remove()
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, name .. " has been Namelock.")
end
end
how to use
/namelock name,reason
Code:
<talkaction words="/unlock" separator=" " script="unlock.lua"/
Code:
function onSay(player, words, param)
if not player:getGroup():getAccess() then
return true
end
local resultId = db.storeQuery("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(param))
if resultId == false then
return false
end
db.asyncQuery("DELETE FROM `player_namelocks` WHERE `player_id` = " .. result.getDataInt(resultId, "id"))
result.free(resultId)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, param .. " has been unlock.")
return false
end
/unlock name
if you use tfs 1.0
chnage
Code:
db.asyncQuery
db.query
Code:
db:query
Last edited: