Ir para conteúdo
  • 0

Pluzetti

Pergunta

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)

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] .. ".")
end
end

Item ID= 2145
Link para o comentário
Compartilhar em outros sites

Posts Recomendados

  • 0

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.

Link para o comentário
Compartilhar em outros sites

  • 0

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"/>
Link para o comentário
Compartilhar em outros sites

  • 0

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.

Link para o comentário
Compartilhar em outros sites

  • 0

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
Link para o comentário
Compartilhar em outros sites

  • 0

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'

Link para o comentário
Compartilhar em outros sites

  • 0

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
Link para o comentário
Compartilhar em outros sites

  • 0

 

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
[31/10/2013 15:30:31] [Error - TalkAction Interface]
[31/10/2013 15:30:31] data/talkactions/scripts/name.lua:onSay
[31/10/2013 15:30:31] Description:
[31/10/2013 15:30:31] data/talkactions/scripts/name.lua:3: attempt to call global 'getPlayerItem' (a nil value)
[31/10/2013 15:30:31] stack traceback:
[31/10/2013 15:30:31] data/talkactions/scripts/name.lua:3: in function <data/talkactions/scripts/name.lua:1>
esse erro me passa seu face melhor pra resolver o erro.
Link para o comentário
Compartilhar em outros sites

  • 0

Ja fiz como vc falo agr da esse erro na distro...

 

 

[31/10/2013 16:18:48] [Error - TalkAction Interface]
[31/10/2013 16:18:48] data/talkactions/scripts/name.lua:onSay
[31/10/2013 16:18:48] Description:
[31/10/2013 16:18:48] data/talkactions/scripts/name.lua:3: attempt to compare number with boolean
[31/10/2013 16:18:48] stack traceback:
[31/10/2013 16:18:48] data/talkactions/scripts/name.lua:3: in function <data/talkactions/scripts/name.lua:1>
Link para o comentário
Compartilhar em outros sites

  • 0

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 por Fawz
Link para o comentário
Compartilhar em outros sites

  • 0

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 por zipter98
Link para o comentário
Compartilhar em outros sites

  • 0



function onSay(cid, words, param, channel)

 

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 getPlayerItemCount(cid, 2145) >= 5 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

else

doPlayerSendCancel(cid, "Voce precisa de pelo menos 5 diamonds.")

return true

end

end

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...