LucasFerraz
Systems Analyst
Ok Ratser = D
Is it 100%?Ok I did it like TGYoshi said (and learned how to use patterns in the process)...
Lua:local itemId, count, maxTextLenght, delay = 1111, 1, 15, 2 * 1000 local blacklistParam = {"god", "cm", "gm", "tutor", "tester"} function onSay(cid, words, param, channel) local text, continue = "You will be kicked in 2 seconds.", true local stringSpaceStart, stringSpaceEnd = string.find(param, "[%s]*") if(db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(param) .. ";"):getID() ~= -1) then text, continue = "That name is already in use.", false elseif(getPlayerItemCount(cid, itemId) < 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((stringSpaceEnd - stringSpaceStart) > 1) then text, continue = "Parameter contains too much spaces.", false elseif(string.len(tostring(param)) > maxTextLenght) then text, continue = "You can use a maximum of " .. 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(blacklistParam) do if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then text, continue = "Invalid name entry.", false break end end end if(continue == false) then doPlayerSendCancel(cid, text) return true end db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";") doPlayerRemoveItem(cid, itemId, count) doPlayerSendTextMessage(cid, 25, text) addEvent(function(cid, forceLogout) if(isPlayer(cid)) then doRemoveCreature(cid, forceLogout) end end, delay, cid, false) return true end
This function no work.. i think..elseif((stringSpaceEnd - stringSpaceStart) > 1) then
local itemId, count, maxTextLenght, delay = 1111, 1, 15, 2 * 1000
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
function onSay(cid, words, param, channel)
local text, continue = "You will be kicked in 2 seconds.", true
if(db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(param) .. ";"):getID() ~= -1) then
text, continue = "That name is already in use.", false
elseif(getPlayerItemCount(cid, itemId) < 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.find(param, "%s+") ~= nil) then
text, continue = "Parameter contains too many spaces.", false
elseif(string.len(tostring(param)) > maxTextLenght) then
text, continue = "You can use a maximum of " .. 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(blacklistParam) do
if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
text, continue = "Invalid name entry.", false
break
end
end
end
if(continue == false) then
doPlayerSendCancel(cid, text)
return true
end
db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
doPlayerRemoveItem(cid, itemId, count)
doPlayerSendTextMessage(cid, 25, text)
addEvent(function(cid, forceLogout)
if(isPlayer(cid)) then
doRemoveCreature(cid, forceLogout)
end
end, delay, cid, false)
return true
end
local itemId, count, maxTextLenght, delay = 1111, 1, 15, 2 * 1000
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
function onSay(cid, words, param, channel)
local text, continue = "You will be kicked in 2 seconds.", true
if(db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(param) .. ";"):getID() ~= -1) then
text, continue = "That name is already in use.", false
elseif(getPlayerItemCount(cid, itemId) < 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.find(param, "%s", 1) ~= nil) or (string.find(param, "%s", string.len(tostring(param)) ~= nil))) then
text, continue = "The first or last characters cannot be spaces.", false
elseif(string.find(param, "%a%s+") ~= nil) then
text, continue = "Parameter contains too many spaces in between letters.", false
elseif(string.len(tostring(param)) > maxTextLenght) then
text, continue = "You can use a maximum of " .. 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(blacklistParam) do
if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
text, continue = "Invalid name entry.", false
break
end
end
end
if(continue == false) then
doPlayerSendCancel(cid, text)
return true
end
db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
doPlayerRemoveItem(cid, itemId, count)
doPlayerSendTextMessage(cid, 25, text)
addEvent(function(cid, forceLogout)
if(isPlayer(cid)) then
doRemoveCreature(cid, forceLogout)
end
end, delay, cid, false)
return true
end
[Error - TalkAction Interface]
[26/8/2012 12:51:13] data/talkactions/scripts/changename.luanSay
[26/8/2012 12:51:13] Description:
[26/8/2012 12:51:13] data/talkactions/scripts/changename.lua:35: bad argument #3 to 'find' (number expected, got boolean)
[26/8/2012 12:51:13] stack traceback:
[26/8/2012 12:51:13] [C]: in function 'find'
[26/8/2012 12:51:13] data/talkactions/scripts/changename.lua:35: in function <data/talkactions/scripts/changename.lua:25>
elseif((string.find(param, "%s", 1) ~= nil) or (string.find(param, "%s", string.len(tostring(param)) ~= nil))) then
text, continue = "The first or last characters cannot be spaces.", false
Try this:
Lua:local itemId, count, maxTextLenght, delay = 1111, 1, 15, 2 * 1000 local blacklistParam = {"god", "cm", "gm", "tutor", "tester"} function onSay(cid, words, param, channel) local text, continue = "You will be kicked in 2 seconds.", true if(db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(param) .. ";"):getID() ~= -1) then text, continue = "That name is already in use.", false elseif(getPlayerItemCount(cid, itemId) < 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.find(param, "%s", 1) ~= nil) or (string.find(param, "%s", string.len(tostring(param)) ~= nil))) then text, continue = "The first or last characters cannot be spaces.", false elseif(string.find(param, "%a%s+") ~= nil) then text, continue = "Parameter contains too many spaces in between letters.", false elseif(string.len(tostring(param)) > maxTextLenght) then text, continue = "You can use a maximum of " .. 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(blacklistParam) do if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then text, continue = "Invalid name entry.", false break end end end if(continue == false) then doPlayerSendCancel(cid, text) return true end db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";") doPlayerRemoveItem(cid, itemId, count) doPlayerSendTextMessage(cid, 25, text) addEvent(function(cid, forceLogout) if(isPlayer(cid)) then doRemoveCreature(cid, forceLogout) end end, delay, cid, false) return true end
local itemId, count, maxTextLenght, delay = 2160, 1, 15, 2 * 1000
local blacklistParam = {"god", "cm", "gm", "tutor", "tester"}
local maxspaces = 2
function getSpaces(word)
_, count = string.gsub(word, " ", " ")
return count
end
function onSay(cid, words, param, channel)
local text, continue = "You will be kicked in 2 seconds.", true
if (not param or param:find("%a") == nil) then
text, continue = "You must put a correct name.", false
elseif(db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(param) .. ";"):getID() ~= -1) then
text, continue = "That name is already in use.", false
elseif(getPlayerItemCount(cid, itemId) < 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(getSpaces(param) > maxspaces) then
text, continue = "Parameter contains too much spaces.", false
elseif(string.len(tostring(param)) > maxTextLenght) then
text, continue = "You can use a maximum of " .. maxTextLenght .. " characters.", false
elseif(string.find(param:lower(), "[%p%d]") ~= nil) then
text, continue = "You can not use symbols.", false
else
for blacklist = 1, table.maxn(blacklistParam) do
if(string.find(param:lower(), blacklistParam[blacklist]) ~= nil) then
text, continue = "Invalid name entry.", false
break
end
end
end
if(continue == false) then
doPlayerSendCancel(cid, text)
return true
end
db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(param) .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
doPlayerRemoveItem(cid, itemId, count)
doPlayerSendTextMessage(cid, 25, text)
addEvent(function(cid, forceLogout)
if(isPlayer(cid)) then
doRemoveCreature(cid, forceLogout)
end
end, delay, cid, false)
return true
end