Ratser
Retired // Making time for yoloswagmod
- Joined
- Feb 11, 2009
- Messages
- 482
- Reaction score
- 36
Lua:
local config = {
text = "You will be kicked in 2 seconds.",
continue = true, -- Do not change this
item = {
Id = 1111,
count = 1
},
maxTextLenght = 15,
blacklistParam = {"god", "cm", "gm", "tutor", "tester"},
newMethod = false,
delay = 2 * 1000
}
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return true
end
local paramTemp, oldName = '', getCreatureName(cid)
for word in string.gmatch(param, "%a+") do
paramTemp = "" .. paramTemp .. " " .. word .. ""
end
string.gsub(paramTemp, "%s*", "", 1)
param, text, continue, item = paramTemp, config.text, config.continue, config.item
if(getPlayerGUIDByName(param) ~= nil) then
text, continue = "That name is already in use.", false
elseif(getPlayerItemCount(cid, item.Id) < item.count) then
text, continue = "You do not have enough premium points.", false
elseif(not getTilePzInfo(getCreaturePosition(cid))) then
text, continue = "You must be inside a protection zone to use this command.", false
elseif(not tostring(param)) then
text, continue = "Invalid parameter.", false
elseif(string.len(tostring(param)) > config.maxTextLenght) then
text, continue = "You can use a maximum of " .. config.maxTextLenght .. " characters.", false
elseif(string.find(param:lower(), "[^%l%s]") ~= nil) then
text, continue = "You can not use symbols.", false
else
for blacklist = 1, table.maxn(config.blacklistParam) do
if(string.find(param:lower(), config.blacklistParam[blacklist]) ~= nil) then
text, continue = "Invalid name entry.", false
break
end
end
end
if(continue == false) then
doPlayerSendCancel(cid, text)
return true
end
doPlayerRemoveItem(cid, item.Id, item.count)
doPlayerSendTextMessage(cid, 25, text)
local guid = getPlayerGUID(cid)
if(config.newMethod == true) then
doPlayerChangeName(guid, oldName, param) -- for 0.3.7+ (is it necessary to kick the player when using this?)
else
db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. guid .. ";")
addEvent(function(cid, forceLogout)
if(isPlayer(cid)) then
doRemoveCreature(cid, forceLogout)
end
end, config.delay, cid, false)
end
return true
end