Iaewww! Galerinha Ekz!! Eu estava com preguiça de fazer algo grande, então resolvi criar esse code, eu olhei nos outros e vi que eram muito mal feitos, então recriei pra postar pra vocês.
Como funciona?
Você diz !afk on e começa a sair mensagens em cima do player dizendo "Off-line", "Afk!", "Ausente!", etc (configurável) e fica imóvel (para players não moverem o player)
Para sair do modo ausente, ande com o personagem ou diga "!afk off"
NEW: Agora player não pode usar comando em área pvp e nem se tiver infight!
Player quando está com evento ativo não pode ser atacado!
Agora player não pode ser empurrado!
Code testado e funcionando 100%
Como instalar?
Vá em creaturescripts/scripts/login.lua abra ele e coloque isso:
registerCreatureEvent(cid, "AwayFromKeyboard1")
registerCreatureEvent(cid, "AwayFromKeyboard2")
setPlayerStorageValue(cid, 3123, -1)
Agora, em creaturescripts/scripts/ crie um arquivo chamado AwayFromKeyboard.lua e adicione isso:
function onPush(cid, target)
if cid ~= target then
if getPlayerStorageValue(target, 3123) ~= -1 then
doPlayerSendCancel(cid, "Você não pode empurrar esse player!")
return false
end
end
return true
end
function onCombat(cid, target)
if isPlayer(target) or isPlayer(cid) then
if getPlayerStorageValue(target, 3123) ~= -1 or getPlayerStorageValue(cid, 3123) ~= -1 then
return false
end
end
return true
end
Agora em creaturescripts.xml adicione isso:
<event type="push" name="AwayFromKeyboard1" event="script" value="AwayFromKeyboard.lua"/>
<event type="combat" name="AwayFromKeyboard2" event="script" value="AwayFromKeyboard.lua"/>
Vá em talkactions/scripts e crie um arquivo chamado AwayFromKeyboard.lua e adicione isso:
local msgss = {"AFK!", "OFF!", "Off-Line!", "Ausente!"}
local msgsss = {"On!", "Voltei!", "Online!", "On-Line!"}
function sendAfkMsg(cid, oldpos)
if isCreature(cid) then
oldpos1 = getCreaturePosition(cid)
if getPlayerStorageValue(cid, 3123) >= 1 and doComparePositions(oldpos, oldpos1) then
doSendAnimatedText(getCreaturePosition(cid), msgss[math.random(1, #msgss)], math.random(0, 256))
addEvent(sendAfkMsg, 1500, cid, oldpos1)
else
setPlayerStorageValue(cid, 3123, -1)
doSendAnimatedText(getCreaturePosition(cid), msgsss[math.random(1, #msgss)], math.random(0, 256))
end
end
end
function onSay(cid, words, param)
if param == "on" then
if getPlayerStorageValue(cid, 3123) >= 1 then
doPlayerSendTextMessage(cid, 27, "Você já está no modo afk!")
else
if getCreatureCondition(cid, CONDITION_INFIGHT) or getTileInfo(getThingPos(cid)).hardcore then
doPlayerSendTextMessage(cid, 27, "Você não pode usar esse comando enquanto estiver em fight ou em área PVP!")
return true
end
setPlayerStorageValue(cid, 3123, 1)
doPlayerSendTextMessage(cid, 27, "Você acaba de entrar no modo afk! Para sair diga ".. words .." off")
sendAfkMsg(cid, getCreaturePosition(cid))
end
elseif param == "off" then
if getPlayerStorageValue(cid, 3123) >= 1 then
setPlayerStorageValue(cid, 3123, -1)
doPlayerSendTextMessage(cid, 27, "Você acaba de sair do modo afk!")
doSendAnimatedText(getCreaturePosition(cid), msgsss[math.random(1, #msgss)], math.random(0, 256))
else
doPlayerSendTextMessage(cid, 27, "Você não está no modo afk para usar este comando!")
end
else
doPlayerSendTextMessage(cid, 27, "Você precisa declarar algum parâmetro (on/off)!")
end
return true
end
Pronto, para finalizar vá em talkactions.xml e adicione isso:
<talkaction hide="yes" words="!afk" event="script" value="AwayFromKeyboard.lua"/>
Espero que gostem do code
Créditos:
BielLucena1291 (Drazyn1291 - Eu) - Por fazer o script inteiro!
Os seguintes foram por dá ideias de melhorias!