Olá galera do Tibia King, baixei o servidor de nosso "querido" [eauheauea -brinkz] brun123 e separei em alguns systems, aqui vai um:
[Postei nessa area pois fikei confuso em qual postar, pois o script envolve creaturescripts/npcs/actions/etc...]
Primeiro Passo:
va em pastadoseuot/data/creaturescripts/scripts e crie um arquivo .lua xamado: tvsys.lua e cole isso dentro:
function onJoinChannel(cid, channelId, users, isTv)
if channelId == 10 then
doShowPokemonStatistics(cid)
return false
end
if channelId == 11 then
doPlayerPopupFYI(cid, getHighscoreString(8))
return false
end
if channelId == 12 then
doPlayerPopupFYI(cid, getHighscoreString(6))
return false
end
if channelId >= 100 and channelId <= 10000 then
local owner = getPlayerByGUID(getChannelOwner(channelId))
if isChannelTv(channelId) then
if isCreature(owner) then
if owner ~= cid then
doPlayerWatchOther(cid, owner)
local plural = #users == 2 and "" or "s"
doPlayerSendChannelMessage(owner, "TV Channel", getCreatureName(cid)..' is now watching your channel (currently '..#users - (1)..' player'..plural..' watching this channel).', 15, channelId)
else
setPlayerStorageValue(cid, 99284, 1)
end
end
elseif owner == cid then
setPlayerStorageValue(cid, 99284, 2)
end
return true
end
return true
end
function onLeaveChannel(cid, channelId, users)
if channelId >= 100 and channelId <= 10000 then
local owner = getPlayerByGUID(getChannelOwner(channelId))
if isChannelTv(channelId) then
if owner ~= cid and getCreatureOutfit(cid).lookType == 814 then
doPlayerStopWatching(cid)
local plural = #users == 2 and "" or "s"
doPlayerSendChannelMessage(owner, "TV Channel", getCreatureName(cid)..' is not watching your channel anymore (currently '..#users - (1)..' player'..plural..' watching this channel).', 15, channelId)
elseif owner == cid then
setPlayerStorageValue(cid, 99284, -1)
doSendAnimatedText(getThingPos(cid), "CAM OFF", 180)
for stops = 1, #users do
if users[stops] ~= owner then
doPlayerStopWatching(users[stops])
end
end
end
elseif owner == cid then
setPlayerStorageValue(cid, 99284, -1)
end
return true
end
return true
end
function onWalk(cid, fromPosition, toPosition)
if getPlayerStorageValue(cid, 99284) <= 0 then return true end
local speed = getCreatureSpeed(cid)
local a = getWatchingPlayersFromPos(cid, fromPosition)
for b = 1, #a do
if getCreatureSpeed(a[b]) ~= speed then
doChangeSpeed(a[b], - getCreatureSpeed(a[b]))
doChangeSpeed(a[b], speed)
end
doTeleportThing(a[b], toPosition, true)
end
return true
end
local permited = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
"t", "u", "v", "x", "w", ",", "'", '"',
"y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", ".", "!", "@", "#", "$", "%", "&", "*", "(", ")",
"-", "_", "+", "/", ";", ":", "?", "^", "~", "{", "[", "}", "]", ">", "<", "£", "¢", "¬"}
function onTextEdit(cid, item, newText)
if item.itemid == 12330 then
if getPlayerStorageValue(cid, 99284) >= 1 then
doPlayerSendCancel(cid, "Voce ja esta no "ar" -")
return false
end
local channelName = getCreatureName(cid).."'s TV Channel"
if string.len(newText) <= 0 then
doPlayerSendCancel(cid, "Your channel is going to be shown as \""..getCreatureName(cid).."'s TV Channel\".")
elseif string.len(newText) > 25 then
doPlayerSendCancel(cid, "O nome de seu canal nao pode conter mais de 25 caracteres!")
return false
else
channelName = newText
end
setPlayerStorageValue(cid, 99284, 1)
setPlayerStorageValue(cid, 99285, "")
setPlayerStorageValue(cid, 99285, channelName)
doPlayerCreatePrivateChannel(cid, channelName)
doSendAnimatedText(getThingPos(cid), "NO AR!", COLOR_GRASS)
return false
end
return true
end
Agora va em pastadoseuot/data/creaturescripts e abra o Creaturescripts.xml e cole isso la:
<!-- TV SYSTEM -->
<event type="joinchannel" name="WatchTv" event="script" value="tvsys.lua">
<event type="leavechannel" name="StopWatchingTv" event="script" value="tvsys.lua">
<event type="walk" name="WalkTv" event="script" value="tvsys.lua">
<event type="textedit" name="RecordTv" event="script" value="tvsys.lua">
Agora crie um novo npc em pastadoseuot/data/npcs e ponha isso dentro dele:
<!--?xml version="1.0" encoding="UTF-8"?-->
<npc name="Frenzi " speed="0">
<health now="8150" max="8150">
<look type="614" head="94" body="94" legs="94" feet="94">
<parameters>
</parameters>
</look></health></npc>
Agora va em pastadoseuot/data/lib e crie um novo arquivo .lua xamado: tvsystem.lua e cole isso la:
function doPlayerWatchOther(cid, target)
if not isCreature(cid) then return true end
local hasOutfitCond = getCreatureCondition(cid, CONDITION_OUTFIT) and getCreatureOutfit(cid).lookType or -1
setPlayerStorageValue(cid, 99282, getCreatureSpeed(cid))
setPlayerStorageValue(cid, 99283, hasOutfitCond)
setPlayerStorageValue(cid, 99285, target)
doCreatureSetNick(cid, " ")
local o = getCreatureOutfit(cid)
local olddir = getCreatureLookDir(cid)
local oldpos = getThingPos(cid)
doTeleportThing(cid, getThingPos(target), false)
doCreatureSetHideHealth(cid, true)
doPlayerLock(cid)
local dir = "data/npc/TVNPC.xml"
local a = io.open(dir, "a+")
local b = a:read("*all")
a:close()
local npcname = 'name="'..getCreatureName(cid)..' "'
local npchealth = 'health now="'..getCreatureHealth(cid)..'" max="'..getCreatureMaxHealth(cid)..'"'
local npcoutfit = 'look type="'..o.lookType..'" head="'..o.lookHead..'" body="'..o.lookBody..'" legs="'..o.lookLegs..'" feet="'..o.lookFeet..'"'
b = string.gsub(b, 'name="(.-)"', npcname)
b = string.gsub(b, 'health now="(.-)" max="(.-)"', npchealth)
b = string.gsub(b, 'look type="(.-)" head="(.-)" body="(.-)" legs="(.-)" feet="(.-)"', npcoutfit)
local c = io.open(dir, "w")
c:write(b)
c:close()
o.lookType = 814
doCreatureSetOutfit(cid, o, -1)
local n = doCreateNpc("TVNPC", oldpos)
doCreatureSetLookDir(n, olddir)
setPlayerStorageValue(n, 9891, getPlayerSex(cid))
doPlayerSetVocation(cid, 1)
doChangeSpeed(cid, -getCreatureSpeed(cid))
doChangeSpeed(cid, getCreatureSpeed(target))
end
function doPlayerStopWatching(cid)
if not isCreature(cid) then return true end
doPlayerUnlock(cid)
doCreatureSetNick(cid, getCreatureName(cid))
local pos = {}
local speed = getPlayerStorageValue(cid, 99282)
local outfit = getPlayerStorageValue(cid, 99283)
if outfit >= 1 then
local newOutfit = getCreatureOutfit(cid)
newOutfit.lookType = outfit
doCreatureSetOutfit(cid, newOutfit, -1)
else
doCreatureRemoveCondition(cid, CONDITION_OUTFIT)
end
local npc = getCreatureByName(getCreatureName(cid).." ")
local olddir = 0
if isCreature(npc) then
olddir = getCreatureLookDir(npc)
local pos = getThingPos(npc)
doRemoveCreature(npc)
doTeleportThing(cid, pos, false)
end
doChangeSpeed(cid, -getCreatureSpeed(cid))
doChangeSpeed(cid, speed)
doCreatureSetHideHealth(cid, false)
doCreatureSetLookDir(cid, olddir)
doCreatureSetNick(cid, getCreatureName(cid))
setPlayerStorageValue(cid, 99285, -1)
end
function getWatchingPlayersFromPos(cid, pos)
local ret = {}
local cp = {}
cp.x = pos.x
cp.y = pos.y
cp.z = pos.z
for a = 0, 255 do
cp.stackpos = a
local b = getTileThingByPos(cp).uid
if isCreature(b) and getCreatureOutfit(b).lookType == 814 and getPlayerStorageValue(b, 99285) == cid then
table.insert(ret, b)
end
end
return ret
end
Agora va em pastadoseuot/data/xml e abra o arquivoVocations.xml e mude o que esta la por isso:
<!--?xml version="1.0" encoding="UTF-8"?-->
<vocations>
<vocation id="0" name="Pokemon Trainer" description="a pokemon trainer" needpremium="0" gaincap="0" gainhp="40" gainmana="0" gainhpticks="0" gainhpamount="0" gainmanaticks="0" gainmanaamount="0" manamultiplier="1.1" attackspeed="-1" soulmax="251" gainsoulticks="-1" fromvoc="1">
<formula meleedamage="0" distdamage="1.0" wanddamage="1.0" magdamage="1.0" maghealingdamage="1.0" defense="1.0" magdefense="1.0" armor="1.0">
<skill fist="0" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0">
</skill></formula></vocation>
<vocation id="1" name="Pokemon Trainer" description="a pokemon trainer" needpremium="0" gaincap="0" gainhp="40" gainmana="0" gainhpticks="0" gainhpamount="0" gainmanaticks="0" gainmanaamount="0" manamultiplier="1.1" attackspeed="-1" soulmax="251" gainsoulticks="-1" fromvoc="1" lessloss="0">
<formula meleedamage="0" distdamage="1.0" wanddamage="1.0" magdamage="1.0" maghealingdamage="1.0" defense="1.0" magdefense="1.0" armor="1.0">
<skill fist="0" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0">
</skill></formula></vocation>
<vocation id="2" name="TV" description="a pokemon trainer" needpremium="0" gaincap="0" gainhp="40" gainmana="0" gainhpticks="0" gainhpamount="0" gainmanaticks="0" gainmanaamount="0" manamultiplier="1.1" attackspeed="-1" soulmax="251" gainsoulticks="-1" fromvoc="1" lessloss="0">
<formula meleedamage="0" distdamage="1.0" wanddamage="1.0" magdamage="1.0" maghealingdamage="1.0" defense="1.0" magdefense="1.0" armor="1.0">
<skill fist="0" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0">
</skill></formula></vocation>
<vocation id="3" name="PC" description="a pokemon trainer" needpremium="0" gaincap="0" gainhp="40" gainmana="0" gainhpticks="0" gainhpamount="0" gainmanaticks="0" gainmanaamount="0" manamultiplier="1.1" attackspeed="-1" soulmax="251" gainsoulticks="-1" fromvoc="1" lessloss="0">
<formula meleedamage="0" distdamage="1.0" wanddamage="1.0" magdamage="1.0" maghealingdamage="1.0" defense="1.0" magdefense="1.0" armor="1.0">
<skill fist="0" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0">
</skill></formula></vocation>
<vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="5" gainmanaticks="6" gainmanaamount="5" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="4">
<formula meleedamage="1.0" distdamage="1.0" wanddamage="1.0" magdamage="1.0" maghealingdamage="1.0" defense="1.0" magdefense="1.0" armor="1.0">
<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0">
</skill></formula></vocation>
<vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
<formula meleedamage="1.0" distdamage="1.0" wanddamage="1.0" magdamage="1.0" maghealingdamage="1.0" defense="1.0" magdefense="1.0" armor="1.0">
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0">
</skill></formula></vocation>
<vocation id="6" name="Elder Druid" description="an elder druid" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="2" lessloss="30">
<formula meleedamage="1.0" distdamage="1.0" wanddamage="1.0" magdamage="1.0" maghealingdamage="1.0" defense="1.0" magdefense="1.0" armor="1.0">
<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0">
</skill></formula></vocation>
<vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="10" gainmanaticks="3" gainmanaamount="10" manamultiplier="1.4" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="3" lessloss="30">
<formula meleedamage="1.0" distdamage="1.0" wanddamage="1.0" magdamage="1.0" maghealingdamage="1.0" defense="1.0" magdefense="1.0" armor="1.0">
<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0">
</skill></formula></vocation>
<vocation id="8" name="Druid" description="a druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="5" gainmanaticks="3" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="2">
<formula meleedamage="1.0" distdamage="1.0" wanddamage="1.0" magdamage="1.0" maghealingdamage="1.0" defense="1.0" magdefense="1.0" armor="1.0">
<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0">
</skill></formula></vocation>
<!--
<vocation id="9" name="Epic Master Sorcerer" description="an epic master sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="5" lessloss="50">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="10" name="Epic Elder Druid" description="an epic elder druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="6" lessloss="50">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="11" name="Epic Royal Paladin" description="an epic royal paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="10" gainmanaticks="3" gainmanaamount="10" manamultiplier="1.4" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="7" lessloss="50">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="12" name="Epic Elite Knight" description="an epic elite knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="8" gainhpamount="10" gainmanaticks="4" gainmanaamount="10" manamultiplier="3.0" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="8" lessloss="50">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
-->
</vocations>
Agora va em pastadoseuot/data/actions/Actions.xml e cole isso la:
-- TV / CAM
<action itemid="11416-11418;11395-11398;11401-11404" event="script" value="television.lua">
<action itemid="12330" event="script" value="camera.lua">
Agora em pastadoseuot/data/actions/scripts crie um arquivo chamadotelevision.lua e outro chamado camera.lua e cole isso la:
TELEVISION:
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 99284) == 1 then
doPlayerSendCancel(cid, "Voce nao pode assistir TV pois voce esta com um canal aberto!")
return true
end
local a = getThingPos(cid)
if item.itemid >= 11416 and item.itemid <= 11418 then
if a.y <= topos.y then
doPlayerSendCancel(cid, "Porfavor fique na frente da televisao!")
doPlayerSetVocation(cid, 1)
return true
end
end
if item.itemid == 11418 then
if a.x < topos.x then
doPlayerSendCancel(cid, "Porfavor fique na frente da televisao!")
doPlayerSetVocation(cid, 1)
return true
end
elseif item.itemid == 11416 then
if a.x > topos.x then
doPlayerSendCancel(cid, "Porfavor fique na frente da televisao!")
doPlayerSetVocation(cid, 1)
return true
end
end
doPlayerSetVocation(cid, 2)
if not checkChannelsList(cid) then
doPlayerSendCancel(cid, "Nao há nenhum canal no ar neste momento!")
doPlayerSetVocation(cid, 1)
return true
end
if #getCreatureSummons(cid) >= 1 then
doReturnPokemon(cid, getCreatureSummons(cid)[1], getPlayerSlotItem(cid, 8), pokeballs[getPokeballType(getPlayerSlotItem(cid, 8).itemid)].effect)
end
openChannelDialog(cid)
return true
end
CAMERA:
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 99284) == 2 then
doPlayerSendCancel(cid, "voce deve fechar todas suas converças privadas para abrir um "Novo Canal"")
return true
end
if getPlayerStorageValue(cid, 99284) == 1 then
doPlayerSendCancel(cid, "Voce ja esta no "ar"! No canal: "..getPlayerStorageValue(cid, 99285).."")
return true
end
if not isPremium(cid) then
doPlayerSendCancel(cid, "Somente players VIP podem usar a camera de Tv!")
return true
end
doPlayerPopupFYI(cid, "Escolha o nome do canal:")
end
Prontinho! ao fazer a tv cam e clickar nela aparecera uma janela escrita: "Escolha o nome do canal:" e la voce apertara OK e uma nova janela se abrirá, e nessa nova janela devera colocar o "Nome do canal"
players free's que tentarem usar aparecerá isso: Somente players VIP podem usar a camera de Tv!
Demais msgs: Voce ja esta no "ar"! No canal: "nome do canal escolhido" [aparecera quando tentar abrir 2 canais]
voce deve fechar todas suas converças privadas para abrir um "Novo Canal"[aparecera Quando estiver com a janela de converas privates e tentar abrir um canal de tv]
"Porfavor fique na frente da televisao!" [aparecera quando tentar assistir tv de longe]
"Voce nao pode assistir TV pois voce esta com um canal aberto!" [aparecera quando tentar assistir tv com um canal aberto]
"Nao há nenhum canal no ar neste momento!" [aparecera quando tentar assistir TV e nao houver nenhum canal disponivel]
Storages Usados:
99282
99283
99284
Créditos:
Brun123 [Por disponibilizar o system em seu servidor "demo version"]
Brunoo Angel [deu uma traduzida/modificada no script]
MasterCraft [Ajudou o Brun123 com o servidor "demo version"]