Ir para conteúdo

Featured Replies

Resolvido por Wise

Ir para solução
Postado
  • Solução
  Em 01/01/2015 em 12:50, jNo disse:

Talk ou por item

Tente:

removefrags.lua (data\talkactions\scripts):

function onSay(cid)
    price = 500 -- crystal coins
    time = 5 -- seconds to logout
    
    if getPlayerFrags(cid) > 0 then
        if not getCreatureCondition(cid, CONDITION_INFIGHT) or not isPlayerPzLocked(cid) then
            if doPlayerRemoveMoney(cid, price * 10000) then
                doCreatureSetNoMove(cid, true)
                db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = ".. getPlayerGUID(cid) ..")")
                doSendMagicEffect(getThingPos(cid), CONST_ME_STUN)
                addEvent(doRemoveCreature, time * 1000, cid, true)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You will be logged out within '..time..' seconds to complete the removal of your frags.')
            else
                doPlayerSendCancel(cid, 'You need '..price..' crystal coins to remove your frags.')
            end
        else
            doPlayerSendCancel(cid, 'You can\'t remove your frags when you\'re in battle or in fight.')
        end
    else
        doPlayerSendCancel(cid, 'You don\'t have any frag.')
    end
    
    return true
end

 

Tag - talkactions.xml (data\talkactions):

<talkaction words="!removefrags" event="script" value="removefrags.lua"/>

 

removefrags.lua (data\actions\scripts):

function onUse(cid, item, fromPos, toPos)
    time = 5 -- seconds to logout
    
    if getPlayerFrags(cid) > 0 then
        if not getCreatureCondition(cid, CONDITION_INFIGHT) or not isPlayerPzLocked(cid) then
            doCreatureSetNoMove(cid, true)
            db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = ".. getPlayerGUID(cid) ..")")
            doSendMagicEffect(toPos, CONST_ME_STUN)
            addEvent(doRemoveCreature, time * 1000, cid, true)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You will be logged out within '..time..' seconds to complete the removal of your frags.')
            doRemoveItem(item.uid)
        else
            doPlayerSendCancel(cid, 'You can\'t remove your frags when you\'re in battle or in fight.')
        end
    else
        doPlayerSendCancel(cid, 'You don\'t have any frag.')
    end
    
    return true
end

Tag - actions.xml (data\actions):

<action itemid="ITEMID" script="removefrags.lua"/>

 

PS: Já que há uma modificação nos dados (via database) do player, ele precisa fazer logout para atualizar. Então fiz pra que ele precise estar sem battle/pz locked para usar a talkaction/item, além de que ficará imóvel até ser "removido" do jogo.

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

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