margoh
{{ user.title }}
- Joined
- Apr 1, 2013
- Messages
- 806
- Solutions
- 18
- Reaction score
- 350
Hello,
I have cam/tv system for tibia version 8.54.
The problem is, when I try to record (i have changed item id to book) text window, where I have to put name of channel, appears. But when I enter the name of channel and press ok, nothing happens, it's not opening new channel with name that I have entered to text area. When I press again on book, text window appears, but with text that i have typed (it should delete all content from inside).
And now, my question is: How to make it fully working on clear TFS 0.3.6pl1?
I would be very grateful if someone was able to help.
Best regards,
margoh.
_________________________________________________
Here's the codes:
Camera:
Television:
Tvsys:
Tvsys.lib:
@ofc Repps for help++
---Update---
I found the issue. Now I need to add to my engine doPlayerCreatePrivateChannel, but idk how to do it. Can someone help me?
I have cam/tv system for tibia version 8.54.
The problem is, when I try to record (i have changed item id to book) text window, where I have to put name of channel, appears. But when I enter the name of channel and press ok, nothing happens, it's not opening new channel with name that I have entered to text area. When I press again on book, text window appears, but with text that i have typed (it should delete all content from inside).
And now, my question is: How to make it fully working on clear TFS 0.3.6pl1?
I would be very grateful if someone was able to help.
Best regards,
margoh.
_________________________________________________
Here's the codes:
Camera:
PHP:
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 99284) == 2 then
doPlayerSendCancel(cid, "You have to close your private chat to create a TV channel.")
return true
end
if getPlayerStorageValue(cid, 99284) == 1 then
doPlayerSendCancel(cid, "You are already on air! Currently on channel: "..getPlayerStorageValue(cid, 99285).."")
doPlayerSendChannel(cid, getPlayerChannelId(cid), getPlayerStorageValue(cid, 99285))
return true
end
doPlayerPopupFYI(cid, "Choose a channel name")
end
Television:
PHP:
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 99284) == 1 then
doPlayerSendCancel(cid, "You can't watch TV while recording.")
return true
end
local a = getThingPos(cid)
if item.itemid >= 11416 and item.itemid <= 11418 then
if a.y <= topos.y then
doPlayerSendCancel(cid, "Please, stay in front of the television.")
doPlayerSetVocation(cid, 1)
return true
end
end
if item.itemid == 11418 then
if a.x < topos.x then
doPlayerSendCancel(cid, "Please, stay in front of the television.")
doPlayerSetVocation(cid, 1)
return true
end
elseif item.itemid == 11416 then
if a.x > topos.x then
doPlayerSendCancel(cid, "Please, stay in front of the television.")
doPlayerSetVocation(cid, 1)
return true
end
end
doPlayerSetVocation(cid, 2)
if not checkChannelsList(cid) then
doPlayerSendCancel(cid, "There aren't any channels on air right now.")
doPlayerSetVocation(cid, 1)
return true
end
openChannelDialog(cid)
return true
end
Tvsys:
PHP:
function onJoinChannel(cid, channelId, users, isTv)
if channelId == 10 then
doShowPokemonStatistics(cid)
return false
end
if channelId == 11 then
if reloadHighscoresWhenUsingPc then
doReloadHighscores()
end
doPlayerPopupFYI(cid, getHighscoreString(8))
return false
end
if channelId == 12 then
if reloadHighscoresWhenUsingPc then
doReloadHighscores()
end
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 == 1 and "" or "s"
doPlayerSendChannelMessage(owner, "TV Channel", getCreatureName(cid)..' is now watching your channel (currently '..#users..' 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)
-- Código năo é mais necessário, feito em c++
-- Code deprecated, made in c++
--if not canWalkOnPos(toPosition, false, false, false, true, false) and getPlayerStorageValue(cid, 17000) >= 1 then
-- doTeleportThing(cid, fromPosition, false)
-- doPlayerSendCancel(cid, "Sorry, not possible.")
--end
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, "You are already on air!")
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, "Your channel name can't have more than 25 characters.")
return false
else
channelName = newText
end
setPlayerStorageValue(cid, 99284, 1)
setPlayerStorageValue(cid, 99285, "")
setPlayerStorageValue(cid, 99285, channelName)
doPlayerCreatePrivateChannel(cid, channelName)
doSendAnimatedText(getThingPos(cid), "ON AIR!", COLOR_GRASS)
return false
end
return true
end
Tvsys.lib:
PHP:
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)
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)
doTeleportThing(cid, getThingPos(target), false)
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 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)
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
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
@ofc Repps for help++
---Update---
I found the issue. Now I need to add to my engine doPlayerCreatePrivateChannel, but idk how to do it. Can someone help me?
Last edited: