• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X [0.3.7] if openchannell - possible?

Dibis

Member
Joined
Dec 1, 2022
Messages
73
Reaction score
16
Location
POLAND
Hello.
In TFS have function: doPlayerOpenChannel(cid, channels)
Possible to create function etc:

if CHANNEL ID == NOT OPEN then
doPlayerOpenChannel(cid, channels)

I found this: Channels Leave but not working good.

Thanks for answer.
 
Hello.
In TFS have function: doPlayerOpenChannel(cid, channels)
Possible to create function etc:

if CHANNEL ID == NOT OPEN then
doPlayerOpenChannel(cid, channels)

I found this: Channels Leave but not working good.

Thanks for answer.
It looks like there is a problem with the script you provided. Here are a few issues that I see:
The function onLogin takes an argument cid, but there is no variable with that name in the function. It should be uid.The function registerCreatureEvent expects two arguments: a creature ID and the name of an event handler function. In this case, the second argument should be the name of the function that will be called when the event occurs, not the event itself. So it should be registerCreatureEvent(uid, "openchannel"). The function onLeaveChannel has a syntax error. The if statement is missing the then keyword. It should be if isPlayer(cid) then. Here is the corrected script:
Lua:
local channels = {10, 11}

function onLogin(uid)
  doPlayerOpenChannel(uid, channels)
  registerCreatureEvent(uid, "openchannel")
  return true
end

function onLeaveChannel(cid, channel, users)
  if isPlayer(cid) then
    doPlayerOpenChannel(cid, channels)
    return true
  end
end
 
Last edited:
Back
Top