Recent posts
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Recent posts

#1
HOW-TO's / Cannot sign up to Wiki
Last post by b_e - 30 August, 2026, 21:39:01
Would like to add quite a bit of info, but never get any registration emails.
#2
Finished Scripts / Re: TriviaMod v2.3.0
Last post by b_e - 24 August, 2026, 23:11:10
Also whacked this together so that you can see where I am coming from:
-- These all do the same: check if a number is a positiven integer between 1 and 100 (inclusive)
-- Return true if all above conditions are met
-- Return false on error, and a string describing the error

-- Early return version: this is the most readable and efficient
function check(n)
    if n < 0 then return false, "negative" end
    if n ~= math.floor(n) then return false, "not an integer" end
    if n >= 1 and n <= 100 then return true end
    return false, "out of range"  
end

-- Nested `if`: twice as many lines
function check_if(n)
    if n > 0 then
        if n == math.floor(n) then
            if n >= 1 and n <= 100 then
                return true
            else
                return false, "out of range"
            end
        else
            return false, "not an integer"
        end
    end
    return false, "negative"
end

-- Even if you collate into one if check, you are still on par with early return
-- but this is not as easy to interpret as the early return version
-- 
-- and there is a HUGE limitation: this way you cannot tell the caller what the 
-- problem is
function check_if2(n)
    if n > 0 and n == math.floor(n) and n >= 1 and n <= 100 then
        return true
    end
    return false, "not an integer or negative or outta range, dunno man"
end
#3
Finished Scripts / Re: TriviaMod v2.3.0
Last post by b_e - 24 August, 2026, 22:29:58
Hi!

Nice script.

I have just checked your code and while I have not evaluated the overall design, I could not help but notice that you are giving yourself a hard time: there is waaaaaay too much nesting.

Don't get me wrong, I'm sure your code works fine, but the above makes your code difficult to work with.

Since this platform is not too fit to post huge Lua chunks (and seems to allow no Markdown code either), I have decided to amend your code and implent early returns rather than nested if-then-else.

In general, if there are more than 4 lines after your if ... then statement, consider an early return.

Your original logic is completely unchanged, except for the added empty string check at the beginning. Please find attached the corrected file. I have implemented a timer reset local minifunction, but the sole purpose of that is to reuse the same chunk of yours at different spots.

Note that this is a proof of concept, it throws no syntax errors in the lua interpreter, but I have not tested it with PtokaX.

If you get my point, you can check your MainTimer and SendMsgToPlayers functions yourself, because I only rearranged ParseData :P

Also, instead of
string.lower(str)
just use
str:lower()


Likewise:
string.find(str) --> str:find
string.match(str) -->  str:match 
string.gsub(str) --> str:gsub

-- The nested str:gsub():gsub():gsub() syntax is super cool. :D
.
It is also good practice to keep line lengths at 80 columns max, so that your script can be edited even on terminals.

Hope you are not offended; trying to help so that you can enjoy coding more.

Keep up the good work!

#4
Finished Scripts / Re: TriviaMod v2.3.0
Last post by jim124 - 05 July, 2026, 07:46:16
nice work
#5
Finished Scripts / TriviaMod v2.3.0
Last post by Schumbot - 30 June, 2026, 23:20:04
    [size=18]TriviaMod v2.3.0 — Advanced Trivia Script for PtokaX[/size]

    Hi everyone,

    I am releasing TriviaMod v2.3.0, a heavily improved version of the classic Trivia script originally written by chill, then extended by NRJ (Quiz 1.6). This release is the result of a long rework session covering bugs, encoding, translation, and a set of new features.

    [size=14]Compatibility[/size]
    • PtokaX 0.4.x.x / 0.5.x.x
    • Lua 5.1 / 5.2 / 5.3 / 5.4
    • Windows (Windows-1252 encoding)

    [size=14]What is new compared to the original v1.02d[/size]

    Core fixes
    • Fixed math.randomseed() crash on Lua 5.4 (os.clock() returns a float — wrapped with math.floor())
    • Fixed unclosed string in Commands.lu (ShowReport, line 382) that prevented the script from loading at all
    • Fixed OnExit() crash when script failed to fully load
    • Fixed questions.txt path (was pointing to wrong directory)
    • Fixed duplicated line in !trivmytop stats display
    Question file flexibility
    • SplitLine() now auto-detects the number of separators per line — all three formats are handled transparently:
      {Category} Question *Answer       (no * after brace)
      {Category}*Question *Answer       (standard format)
      {Category} *Question *Answer      (extra space, also works)
      
      Lines with only one separator no longer get silently dropped when quesmode=1.
    • GetQuestion() extracts the {Cat} category directly from the question text when the Category field is empty.
    Visual improvements
    • All question display modes (QuestionMode=1, showquestion 1/2/3) now use the same framed layout with separators for a consistent look.
    • Correct answer reveal, timeout, and hints are all framed.
    • Startup version printed to the PtokaX console.

    New commands
    • !trivskip — skip current question (available to players)
    • !trivconfskip — enable/disable skip (admin)
    • !trivbreakskip — skip current break (admin)
    • !trivgrades — show the full rank table with point thresholds
    Rank system
    • 10 configurable ranks (tRankMembers) with a fixed point interval (RankInterval).
    • Default ranks: Novice / Apprentice / Curious / Scholar / Confirmed / Expert / Quiz Master / Sage / Legend / Grand Champion
    • Rank displayed in !trivscore and !trivmytop.
    • Automatic rank-up announcement when a player reaches a new rank.
    Team mode (optional)
    • Activate by filling tCfg.Teams with nickname prefixes:
      tCfg.Teams = { "[RED]", "[BLUE]", "[GREEN]" }
      
    • Players are automatically assigned to a team based on their nickname prefix — no login command required.
    • Separate team score table (TeamScores.tbl), persisted to disk.
    • !trivteamscore — show team ranking with rank badges.
    Team multiplier — System C
    • Players contribute to their team score with a multiplier based on their personal rank tier:
      Beginner     (ranks 1-3)   x1.0  — normal points
      Intermediate (ranks 4-6)   x1.5  — 50% bonus
      Elite        (ranks 7+)    x2.0  — double points
      
    • Multiplier announced after each correct answer.
    • Team rank-up notified when the team crosses a new threshold.
    • All coefficients are configurable in settings.lu (tTeamMulti).
    [size=14]Installation[/size]
    [list=1]
    • Extract the ZIP into your PtokaX scripts folder.
    • The structure must be:
    scripts/
      Trivia_Mod.lua
      TriviaMod/
        settings.lu
        questions.txt
        Data/
        Functions/
    
    • Edit TriviaMod/settings.lu to set your bot name, profiles, command prefix, rank names, team prefixes, etc.
    • Load Trivia_Mod.lua from the PtokaX script manager.
    • Check the PtokaX console — you should see: TriviaMod v2.3.0 loaded.
    [size=14]Question file format[/size]

    The script accepts three equivalent formats:
    {Category} Question text *Answer
    {Category}*Question text *Answer
    {Category} *Question text *Answer
    

    Multiple valid answers are separated by additional * characters:
    {Category} *Question *Answer1 *Answer2
    

    The {...} category tag is optional. Lines without it are read as plain Question *Answer entries.

    [size=14]Commands summary[/size]

    Players
    !trivhelp         — help
    !trivmytop        — your personal stats and rank
    !trivscore        — top scorers
    !trivstats        — top N player stats
    !trivtoptime      — top by average response time
    !trivtopanswers   — top by correct answer count
    !trivtopstreak    — top by streak
    !trivskip         — skip current question
    !trivhint         — request a hint
    !trivreport       — report an error in a question
    !trivgrades       — show rank table
    !trivteamscore    — show team ranking (if team mode active)
    !login / !logout  — join / leave the game (PM mode)
    

    Admin
    !trivstart        — start the quiz
    !trivstop         — stop the quiz
    !trivpause        — announce a break
    !trivcontinue     — resume after break
    !trivbreakskip    — skip current break
    !trivquestion N   — jump to question number N
    !trivconfskip     — toggle question skip on/off
    !trivhint         — toggle hints on/off
    !trivchangemode   — toggle sequential/random mode
    !trivmain / !trivpm — switch main chat / PM mode
    !trivaddquestion  — add a question live
    !trivshowreport   — show error reports
    !resetscores      — reset all scores
    

    [size=14]Credits[/size]
    • Original script : chill
    • Quiz 1.6 rework : NRJ
    • v1.02d base     : TriviaMod team
    • v2.x rework     : Raphaël (FR)
    Based on the original thread: http://mydc.ru/topic1377.html

    [size=14]Feedback[/size]

    Please report any bugs, suggestions or question file issues in this thread.
    Tested on PtokaX 0.5.x with Lua 5.4 on Windows.

    Enjoy the quiz! :)
    #6
    Offtopic / Re: Who's still around?
    Last post by jim124 - 24 June, 2026, 07:59:41
    im still here had to reset password doing some beta testing with a bot i made
    #7
    Offtopic / Re: Who's still around?
    Last post by nEgativE - 06 April, 2026, 05:46:00
     :shocking:
    #8
    FAQ section / Re: Ptokax server requirements
    Last post by the-master - 23 November, 2025, 10:47:10
    We used to run on old pc's, intel I version, 8 Gb ram worked fine for a 1000 users
    #9
    Offtopic / Re: Who's still around?
    Last post by the-master - 23 November, 2025, 10:38:30
    Lo0oL, seems old guys are present  :rolleyes:
    #10
    Offtopic / Re: Who's still around?
    Last post by Cêñoßy†ê - 23 October, 2025, 10:38:29
     :ninja:  :yes:
    SMF spam blocked by CleanTalk