Essa seção não deve ser usada para pedidos ou dúvidas, temos uma seção específica para isso. Por favor, preste mais atenção da próxima vez.
Movido para Pedidos e Dúvidas - Scripting.
info
Grupo: Marquês
Registrado: 16/06/07
Posts: 1.2k
Reputação: +377
Gênero: Masculino
Char no Tibia: Nenhum

info
Grupo: Marquês
Registrado: 03/02/13
Posts: 1.2k
Reputação: +254
Gênero: Masculino
Char no Tibia: Partiu Baladinha

Tentaivos assim, não estou em casa por isso não testei:
Talkactions:
function onSay(cid, words, param, channel)
local p = string.explode(param, ',')
if(param == "") then
doPlayerSendCancel(cid, "Command requires param.")
return true
end
if(words == "/name") then
if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then
return doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
elseif(isPlayerBanished(p[1], PLAYERBAN_LOCK)) then
return doPlayerSendCancel(cid, "Sorry, but " .. p[1] .. " is name locked.")
elseif(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1) then
return doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.")
end
return db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s name to " .. p[2] .. ".") and doPlayerSetStorageValue(cid, 14581, 1)
end
end
Creaturescripts/scripts crie um arquivo e renomeie para removeitem.lua
function onLogin(cid) local item_id = 2195 if getPlayerStorageValue(cid, 14581) == 1 then doPlayerRemoveItem(cid, item_id, 1) else return false end return true end
Tag no xml:
<event type="login" name="Removeitem" event="script" value="removeitem.lua"/>
info
Grupo: Conde
Registrado: 29/04/09
Posts: 904
Reputação: +389
Char no Tibia: Jabuti Selvagem

Vc deveria explicar melhor oque quer. Se for so remover um item quando usa o comando, acho que é só por um doPlayerRemoveItem(cid, xxx, 1) antes do ultimo end.
@Fawz pq fazer isso por creaturescripts? Oo
info
Grupo: Artesão
Registrado: 18/03/13
Posts: 149
Reputação: +19
Gênero: Masculino
Char no Tibia: Cachero

Eu queria assim...
eu falo /name Kevin, [ADM] Zerone...se eu tiver o item 2145 eu mudo o nome se eu não tiver da a mensagem que eu não tenho o item necessario, seria 5 diamonds (2145).
Obrigado.
info
Grupo: Conde
Registrado: 29/04/09
Posts: 904
Reputação: +389
Char no Tibia: Jabuti Selvagem

Testa
function onSay(cid, words, param, channel)
if not getPlayerItem(cid, 2145) >= 5 then
doPlayerSendCancel(cid, "Voce precisa de pelo menos 5 diamonds.")
return false
end
local p = string.explode(param, ',')
local item_id = 2195
if(param == "") then
doPlayerSendCancel(cid, "Command requires param.")
doPlayerRemoveItem(cid, item_id, 1)
return true
end
if(words == "/name") then
if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then
return doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
elseif(isPlayerBanished(p[1], PLAYERBAN_LOCK)) then
return doPlayerSendCancel(cid, "Sorry, but " .. p[1] .. " is name locked.")
elseif(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1) then
return doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.")
end
return db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s name to " .. p[2] .. ".")
doPlayerRemoveItem(cid, 2145, 5)
end
end
info
Grupo: Artesão
Registrado: 18/03/13
Posts: 149
Reputação: +19
Gênero: Masculino
Char no Tibia: Cachero

Testa
function onSay(cid, words, param, channel) if not getPlayerItem(cid, 2145) >= 5 then doPlayerSendCancel(cid, "Voce precisa de pelo menos 5 diamonds.") return false end local p = string.explode(param, ',') local item_id = 2195 if(param == "") then doPlayerSendCancel(cid, "Command requires param.") doPlayerRemoveItem(cid, item_id, 1) return true end if(words == "/name") then if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then return doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.") elseif(isPlayerBanished(p[1], PLAYERBAN_LOCK)) then return doPlayerSendCancel(cid, "Sorry, but " .. p[1] .. " is name locked.") elseif(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1) then return doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.") end return db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s name to " .. p[2] .. ".") doPlayerRemoveItem(cid, 2145, 5) end end
Nao funciono da erro no distro... data/talkactions/scripts/name.lua:22: 'end' expected (to close 'if' at line 13) near 'doPlayerRemoveItem'
info
Grupo: Conde
Registrado: 29/04/09
Posts: 904
Reputação: +389
Char no Tibia: Jabuti Selvagem

Foi mal eu tinha feito pelo celular.
function onSay(cid, words, param, channel)
if not getPlayerItem(cid, 2145) >= 5 then
doPlayerSendCancel(cid, "Voce precisa de pelo menos 5 diamonds.")
return false
end
local p = string.explode(param, ',')
local item_id = 2195
if(param == "") then
doPlayerSendCancel(cid, "Command requires param.")
doPlayerRemoveItem(cid, item_id, 1)
return true
end
if(words == "/name") then
if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then
return doPlyyereenCaancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
elseif(isPlayerBanished(p[1], PLAYERBAN_LOCK)) then
return doPlayerSendCancel(cid, "Sorry, but " .. p[1] .. " is name locked.")
elseif(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1) then
return doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.")
end
doPlayerRemoveItem(cid, 2145, 5)
return db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s name to " .. p[2] .. ".")
end
end
info
Grupo: Artesão
Registrado: 18/03/13
Posts: 149
Reputação: +19
Gênero: Masculino
Char no Tibia: Cachero

Foi mal eu tinha feito pelo celular.
function onSay(cid, words, param, channel) if not getPlayerItem(cid, 2145) >= 5 then doPlayerSendCancel(cid, "Voce precisa de pelo menos 5 diamonds.") return false end local p = string.explode(param, ',') local item_id = 2195 if(param == "") then doPlayerSendCancel(cid, "Command requires param.") doPlayerRemoveItem(cid, item_id, 1) return true end if(words == "/name") then if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then return doPlyyereenCaancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.") elseif(isPlayerBanished(p[1], PLAYERBAN_LOCK)) then return doPlayerSendCancel(cid, "Sorry, but " .. p[1] .. " is name locked.") elseif(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1) then return doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.") end doPlayerRemoveItem(cid, 2145, 5) return db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s name to " .. p[2] .. ".") end end
info
Grupo: Conde
Registrado: 29/04/09
Posts: 904
Reputação: +389
Char no Tibia: Jabuti Selvagem

no lugar de getPlayerItem bota getPlayerItemCount, erro meu
info
Grupo: Artesão
Registrado: 18/03/13
Posts: 149
Reputação: +19
Gênero: Masculino
Char no Tibia: Cachero

Ja fiz como vc falo agr da esse erro na distro...
info
Grupo: Marquês
Registrado: 03/02/13
Posts: 1.2k
Reputação: +254
Gênero: Masculino
Char no Tibia: Partiu Baladinha

Eu achei que ele queria que assim que o god, adm, tutor ou seja lá quem usasse o comando, seria removido do jogador que foi mudado o nome, não de quem usou... meio sem lógica alguém do nada mudar seu nome...
Tenta assim:
function onSay(cid, words, param, channel)
if not getPlayerItem(cid, 2145) >= 5 then
doPlayerSendCancel(cid, "Voce precisa de pelo menos 5 diamonds.")
return false
end
local p = string.explode(param, ',')
local item_id = 2195
if(param == "") then
doPlayerSendCancel(cid, "Command requires param.")
doPlayerRemoveItem(cid, item_id, 1)
return true
end
if(words == "/name") then
if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then
return doPlyyereenCaancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
elseif(isPlayerBanished(p[1], PLAYERBAN_LOCK)) then
return doPlayerSendCancel(cid, "Sorry, but " .. p[1] .. " is name locked.")
elseif(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1) then
return doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.")
end
if doPlayerRemoveItem(cid, 2145, 5) then
return db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s name to " .. p[2] .. ".")
end
end
return true
end
Editado Outubro 31 por Fawz
Não to em casa, então n testei
function onSay(cid, words, param, channel)
local p = string.explode(param, ',')
local item_id = 2195
local item_count = 1 --Mude aqui a qnt de diamonds q vai remover do player.
if getPlayerItemCount(cid, item_id) < 5 then
return doPlayerSendCancel(cid, "vc precisa de 5 diamonds.")
end
if(param == "") then
doPlayerSendCancel(cid, "Command requires param.")
return true
end
if(words == "/name") then
if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then
return doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
elseif(isPlayerBanished(p[1], PLAYERBAN_LOCK)) then
return doPlayerSendCancel(cid, "Sorry, but " .. p[1] .. " is name locked.")
elseif(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1) then
return doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.")
end
doPlayerRemoveItem(cid, item_id, item_count)
db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s name to " .. p[2] .. ".")
end
end
Editado Outubro 31 por zipter98
info
Grupo: Conde
Registrado: 29/04/09
Posts: 904
Reputação: +389
Char no Tibia: Jabuti Selvagem

@Fawz realemente eh estranho. E outra coisa só pra nao deixar passa, do jeito q vc fez ele perderia o item toda vez que logasse.





info
Grupo: Artesão
Registrado: 18/03/13
Posts: 149
Reputação: +19
Gênero: Masculino
Char no Tibia: Cachero
Galera estou com esse script, mas eu ja tentei mudar para ele remover um item mas nao consigo, poderiam me ajudar?
function onSay(cid, words, param, channel)