Olá pessoal \o/.
Hoje vim trazer um script que fiz atoa, porém, bastante útil. O script funciona assim : você dá um item diretamente a um player pré-determinado, ao invés de ter que ir ao player, jogar no chão e ele ter que pegar. Pode-se usar o script através da seguinte maneira : "/presente player,itemid ou itemname,quantidade". Por exemplo : /presente Player,crystal coin,100 ou /presente Player,2160,100. Então, sem mais enrolação, vamos ao script :
Crie um arquivo chamando senditemtoplayer.lua e coloque isto dentro dele :
function onSay(cid, words, param) if (param == "") then doPlayerSendCancel(cid, "É necessário escrever o nome de um player, e um item") return TRUE end p = string.explode(param, ",") local player = getPlayerByName(p[1]) local ret = RETURNVALUE_NOERROR local tmp = getCreaturePosition(player) if player then else doPlayerSendCancel(cid, "Este player não existe.") return TRUE end local create = tonumber(p[2]) if not create then create = getItemIdByName(p[2], FALSE) if(create == LUA_ERROR) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Este item não existe.") return TRUE end end local countitem = 100 if (p[3]) then countitem = p[3] end local item = doCreateItemEx(create, countitem) if(p[4] and getBooleanFromString(p[4]) == TRUE) then if(p[5] and getBooleanFromString(p[5]) == TRUE) then tmp = getPlayerLookPos(player) end ret = doTileAddItemEx(tmp, item) else ret = doPlayerAddItemEx(player, item, TRUE) end if(ret ~= RETURNVALUE_NOERROR) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "O ID: " .. p[2].." não existe.") else doSendMagicEffect(getCreaturePosition(player), 13) doSendMagicEffect(getCreaturePosition(cid), 12) doCreatureSay(player, "Você recebeu um presente do ".. getCreatureName(cid) .. " ", TALKTYPE_ORANGE_1) -- Aqui é a mensagem que o player receberá ao receber o item. return TRUE end return true end
Vá em talkactions.xml e cole esta tag :
<talkaction log="yes" access="5" words="/presente" event="script" value="senditemtoplayer.lua"/>
Você pode livremente editar o acess mínimo, ou o que vai aparecer quando você der um item ao player.
Então, é isso pessoal, muito obrigado pela atenção a vocês que leram até aqui.