Ir para conteúdo

Featured Replies

Postado

local config = {

 
item = {
 
Id = 1984,
 
count = 1,
 
},
 
maxTextLenght = 15,
 
blacklistParam = {"account manager", "god", "cm", "gm", "tutor", "tester"},
 
minWordLenght = 3,
 
delay = 2
 
}
 
 
 
function onSay(cid, words, param, channel)
 
local textCancel, t = config.text, string.explode(param, ",")
 
if(param == '') then
 
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
 
elseif((getPlayerGUIDByName(t[1]) ~= nil) and (not getBooleanFromString(t[2]))) then
 
textCancel = "That name is already in use."
 
elseif(getPlayerItemCount(cid, config.item.Id) < config.item.count) then
 
textCancel = "You do not fulfill the requirements."
 
elseif(not getTilePzInfo(getCreaturePosition(cid))) then
 
textCancel = "You must be inside a protection zone to use this command."
 
elseif(string.len(tostring(t[1])) >= config.maxTextLenght) then
 
textCancel = "You can only use a maximum of " .. config.maxTextLenght .. " characters."
 
elseif(string.find(t[1]:lower(), "[^%l%s]") ~= nil) then
 
textCancel = "You cannot use symbols."
 
else
 
for blacklist = 1, table.maxn(config.blacklistParam) do
 
if(string.find(t[1]:lower(), config.blacklistParam[blacklist]) ~= nil) then
 
textCancel = "Invalid name entry."
 
break
 
end
 
end
 
end
 
 
 
if(config.text ~= textCancel) then
 
doPlayerSendCancel(cid, textCancel)
 
return true
 
end
 
 
 
local paramTemp, space, oldName = '', '', getCreatureName(cid)
 
for word in string.gmatch(t[1], "%a+") do
 
if(string.len(word) < config.minWordLenght) then
 
doPlayerSendCancel(cid, "Each word must have a minimum of " .. config.minWordLenght .. " characters.")
 
return true
 
end
 
 
 
paramTemp = "" .. paramTemp .. "" .. space .. "" .. word .. ""
 
if(space == '') then
 
space = " "
 
end
 
end
 
 
 
local guid = getPlayerGUID(cid)
 
t[1] = paramTemp
 
doPlayerRemoveItem(cid, config.item.Id, config.item.count)
 
if(pcall(doPlayerChangeName, guid, oldName, t[1]) == false) then
 
db.executeQuery("INSERT INTO `player_namelocks` (`player_id`, `name`, `new_name`, `date`) VALUES (" .. guid .. ", " .. db.escapeString(oldName) .. ", " .. db.escapeString(t[1]) .. ", " .. os.time() .. ");")
 
db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(t[1]) .. " WHERE `id` = " .. guid .. " LIMIT 1;")
 
end
 
 
 
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your name has been changed successfully. You will be kicked in " .. config.delay .. " seconds.")
 
addEvent(function(cid, forceLogout)
 
if(isPlayer(cid)) then
 
doRemoveCreature(cid, forceLogout)
 
end
 
end, config.delay * 1000, cid, false)
 
 
 
return true
 
end

 
Pessoal tenho este script, ele é um script de troca de nome, fiz o comando assim !changename Nomenovo. Ele tira o item do player e não muda o nome, alguem pode me da uma ajuda para corrigir este erro por favor?
 
Agradeço desde já.

Editado por acesso123 (veja o histórico de edições)

Resolvido por Wakon

Ir para solução
  • Respostas 44
  • Visualizações 1.3k
  • Created
  • Última resposta

Top Posters In This Topic

Posted Images

Postado

Claro, ele tenta alterar os dados do player com ele on...


Tenta isso:

local config = {
 
item = { Id = 1984,
         count = 1,
       },
 
maxTextLenght = 15,
blacklistParam = {"account manager", "god", "cm", "gm", "tutor", "tester"},
minWordLenght = 3,
delay = 2,
               }
 
 
 
function onSay(cid, words, param, channel)
 

local textCancel, t = config.text, string.explode(param, ",")
 
   if(param == '') then
       return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
    elseif((getPlayerGUIDByName(t[1]) ~= nil) and (not getBooleanFromString(t[2]))) then
     textCancel = "That name is already in use."
    elseif(getPlayerItemCount(cid, config.item.Id) < config.item.count) then
     textCancel = "You do not fulfill the requirements."
    elseif(not getTilePzInfo(getCreaturePosition(cid))) then 
     textCancel = "You must be inside a protection zone to use this command." 
    elseif(string.len(tostring(t[1])) >= config.maxTextLenght) then
     textCancel = "You can only use a maximum of " .. config.maxTextLenght .. " characters."
    elseif(string.find(t[1]:lower(), "[^%l%s]") ~= nil) then
      textCancel = "You cannot use symbols."
    else
      for blacklist = 1, table.maxn(config.blacklistParam) do
        if(string.find(t[1]:lower(), config.blacklistParam[blacklist]) ~= nil) then
          textCancel = "Invalid name entry."
         break
        end
       end
    end
  if(config.text ~= textCancel) then
    doPlayerSendCancel(cid, textCancel)
   return true
  end
  
local paramTemp, space, oldName = '', '', getCreatureName(cid)
 
     for word in string.gmatch(t[1], "%a+") do
       if(string.len(word) < config.minWordLenght) then
         doPlayerSendCancel(cid, "Each word must have a minimum of " .. config.minWordLenght .. " characters.")
        return true
       end
 
 paramTemp = "" .. paramTemp .. "" .. space .. "" .. word .. ""
 
if(space == '') then
 space = " "
end
 
      end
 
local guid = getPlayerGUID(cid)
 t[1] = paramTemp
   
 
if(pcall(doPlayerChangeName, guid, oldName, t[1]) == false) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your name has been changed successfully. You will be kicked in " .. config.delay .. " seconds.")

addEvent(function(cid, forceLogout)
 
     if(isPlayer(cid)) then 
	   doPlayerRemoveItem(cid, config.item.Id, config.item.count)
       doRemoveCreature(cid, forceLogout)

db.executeQuery("INSERT INTO `player_namelocks` (`player_id`, `name`, `new_name`, `date`) VALUES (" .. guid .. ", " .. db.escapeString(oldName) .. ", " .. db.escapeString(t[1]) .. ", " .. os.time() .. ");")
db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(t[1]) .. " WHERE `id` = " .. guid .. " ;")

      end
 
end, config.delay * 1000, cid, false)
end
 
return true
 
end 

Editado por Caronte (veja o histórico de edições)

Se quiser sua dúvida tirada, mande PM com os links, e não com a dúvida (outros podem ter a mesma dúvida, e o fórum serve para ser usado).

 

Tópicos:


 

yNlhRVC.png

 

55px-Judo_yellow_belt.svg.png

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo