• 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!

Lua Cast System Viewers

rodias

New Member
Joined
Jan 1, 2013
Messages
4
Reaction score
0
Good evening. I'm having a problem with my cast system-related server. I am using TFS 0.4 (8.60) rev 3777. The problem is that on the site appears the people who are cast but the amount of players that are watching the cast does not appear, could anyone help me?

I've done a lot of research on the subject but I did not get any success.
I am sorry for my english.
 
Good evening. I'm having a problem with my cast system-related server. I am using TFS 0.4 (8.60) rev 3777. The problem is that on the site appears the people who are cast but the amount of players that are watching the cast does not appear, could anyone help me?

I've done a lot of research on the subject but I did not get any success.
I am sorry for my english.

Wait 24h before you bump your threads; Rules for the Support board

We need the source code since 0.4 didn't have a cast system implemented into the default source code.
Could be that the source isn't sending the info to your database, could be that your website expects info from another table or column.
Pretty much every cast system is diffrent.
 
Ok sorry bro!
The table is correct. The problem is that there is no db update by the server. I checked some topics that contained a lua script to update this information but did not succeed. If anyone can help me thank you!
 
Ok sorry bro!
The table is correct. The problem is that there is no db update by the server. I checked some topics that contained a lua script to update this information but did not succeed. If anyone can help me thank you!
Still, we need source code for your server (or relevant parts of it) to tell anything.

Without it I can only suggest this: make your server update the database :)
 
Depends on the server, so you have to look around if you don't wanna upload the source code.
Ex in this server (1.x but still) it's located in IOLoginData; forgottenserver/iologindata.cpp at a029b2f755091f1d0ac715e5880e55433189e5e3 · slavidodo/forgottenserver · GitHub


Good afternoon WibbenZ.


I'm having the same problem as rodias, and tried to solve it with a lot of researches and have already tried creating a script(you can see it below).

Code:
function onThink(cid, interval, lastExecution)
    local count = 0
    local p = getPlayersOnline(cid)
    for k,d in pairs(p) do
        if getPlayerCast(cid).status == true then
        local t = getCastViewers(cid)
            for _,v in pairs(t) do
                count = count + 1
            end
            db.query("UPDATE `players` SET `castViewers` =  '"..count.."' WHERE `id` = " .. getPlayerGUID(cid))
        end
    end
    return true
end

I tried to use doPlayerSetCastState(cid, true), getPlayerCast(cid) instead of getPlayerCast(cid).status == true and none of them worked.

Firstly, I the /cast talkaction was wrong, it wasn't updating the database, setting cast = 1 and the castDescription. I think the source was supposed to update the db, but it isn't, so I've just added a query in the cast.lua to update it.

Now the viewers are not being updated, the source isn't doing what it was supposed to, and none script could not help me.


You can look my sources(tfs 0.4 rev 3777) in the attached files.

I know that you are not able to help us everytime, and you have your own things to do, but I really need it asap :/

thanks
 

Attachments

Good afternoon WibbenZ.


I'm having the same problem as rodias, and tried to solve it with a lot of researches and have already tried creating a script(you can see it below).

Code:
function onThink(cid, interval, lastExecution)
    local count = 0
    local p = getPlayersOnline(cid)
    for k,d in pairs(p) do
        if getPlayerCast(cid).status == true then
        local t = getCastViewers(cid)
            for _,v in pairs(t) do
                count = count + 1
            end
            db.query("UPDATE `players` SET `castViewers` =  '"..count.."' WHERE `id` = " .. getPlayerGUID(cid))
        end
    end
    return true
end

I tried to use doPlayerSetCastState(cid, true), getPlayerCast(cid) instead of getPlayerCast(cid).status == true and none of them worked.

Firstly, I the /cast talkaction was wrong, it wasn't updating the database, setting cast = 1 and the castDescription. I think the source was supposed to update the db, but it isn't, so I've just added a query in the cast.lua to update it.

Now the viewers are not being updated, the source isn't doing what it was supposed to, and none script could not help me.


You can look my sources(tfs 0.4 rev 3777) in the attached files.

I know that you are not able to help us everytime, and you have your own things to do, but I really need it asap :/

thanks

Well I doubt you can find someone who is willing to track it down here, but as you said it's source related.
If you aren't willing to pay someone (create a thread in the jobs section) you should try to find another cast system.
 
Well I doubt you can find someone who is willing to track it down here, but as you said it's source related.
If you aren't willing to pay someone (create a thread in the jobs section) you should try to find another cast system.


Where can I find the cast source codes? Or it had not been released yet?
 
Where can I find the cast source codes? Or it had not been released yet?

What source code?
TFS 0.4 is discontinued since how many years? :p
You will have to test all the versions you can find and hopefully find one that works.

The only TFS versions that are supported with bug fixes etc atm is TFS 1.2 and TFS 1.3.
 
Try it:
Lua:
function onThink(cid, interval, lastExecution)
local count = 0
    for _, pid in pairs(getPlayersOnline())do
        local viewers = getCastViewers(pid)
            for _,v in pairs(viewers) do
                count = count + 1
            end
        db.executeQuery("UPDATE players SET castViewers='".. count .."' WHERE id="..getPlayerGUID(pid))
    end
    return true
end
 
Last edited:
What source code?
TFS 0.4 is discontinued since how many years? :p
You will have to test all the versions you can find and hopefully find one that works.

The only TFS versions that are supported with bug fixes etc atm is TFS 1.2 and TFS 1.3.
Does There Tfs 1.2/1.3 For Dev cpp ? .
 
Try it:
Lua:
function onThink(cid, interval, lastExecution)
local count = 0
    for _, pid in pairs(getPlayersOnline())do
        local viewers = getCastViewers(pid)
            for _,v in pairs(viewers) do
                count = count + 1
            end
        db.executeQuery("UPDATE players SET castViewers='".. count .."' WHERE id="..getPlayerGUID(pid))
    end
    return true
end


wtf man, this script worked... please let me know why is "pid" instead of "cid" in the getCastViewers function... And why not use cid in getPlayersOnline function..



thanks a lot... it worked!

Does There Tfs 1.2/1.3 For Dev cpp ? .
Nop
 
Last edited by a moderator:
This accumulates all the spectators and does not clean them
Code:
function onThink(cid, interval, lastExecution)
local count = 0
    for _, pid in pairs(getPlayersOnline())do
        local viewers = getCastViewers(pid)
            for _,v in pairs(viewers) do
                count = count + 1
            end
        db.executeQuery("UPDATE players SET castViewers='".. count .."' WHERE id="..getPlayerGUID(pid))
    end
    return true
end
The accumulator goes inside of for this clean spectators of other players
Code:
function onThink(cid, interval, lastExecution)
    for _, pid in pairs(getPlayersOnline())do
local count = 0
        local viewers = getCastViewers(pid)
            for _,v in pairs(viewers) do
                count = count + 1
            end
        db.executeQuery("UPDATE players SET castViewers='".. count .."' WHERE id="..getPlayerGUID(pid))
    end
    return true
end
Srry for me bad english
 
wtf man, this script worked... please let me know why is "pid" instead of "cid" in the getCastViewers function... And why not use cid in getPlayersOnline function..



thanks a lot... it worked!


Nop

pid - You can replace whatever you want. This is one element from the table with players (getPlayersOnline()).
getPlayersOnline - [LUA] 0.4 TFS Functions - here you can find all functions of TFS 0.4 its getPlayersOnline() not getPlayersOnline(cid)

Have a nice evening! :)
 
Try it:
Lua:
function onThink(cid, interval, lastExecution)
local count = 0
    for _, pid in pairs(getPlayersOnline())do
        local viewers = getCastViewers(pid)
            for _,v in pairs(viewers) do
                count = count + 1
            end
        db.executeQuery("UPDATE players SET castViewers='".. count .."' WHERE id="..getPlayerGUID(pid))
    end
    return true
end

where i add this code???
 
Back
Top