Results 1 to 8 of 8

Thread: Division

  1. #1

    Default Division

    Is there a way to check if the result of division is a whole number?

    Making a freezetag mod so every x melts, the whole team gets melted. If the cvar is set to 15, then when Allies melt 15 people in one round, all allies will be thawed, when they melt 30 it will happen again, and again when they melt 45 people. My idea was something like this:

    if ((alliesmelt / local.MeltTheTeam) = whole number)
    {
    stuffsrv "!allies ftmelt"
    }

    Any ideas?

    I could always hard code a few options like

    if (alliesmelt = 15)
    do stuff
    ...

    But that's not as cool.

  2. #2

    Default

    You're looking for the modulus operator:

    https://en.wikipedia.org/wiki/Modulo_operation

    When you have a remainder of 0, you can run your melt command.

    Code:
    if (alliesmelt % local.MeltTheTeam == 0){
       stuffsrv "!allies ftmelt"
    }
    Browse MOHAA Servers Post GameSpy Era

    VISIT MOHREBORN.COM FOR LATEST INFORMATION



    Medal of Honor: Game Server Browser Fixer - Patches your MOHAA, MOHSH, and MOHBT game binaries to allow you to retrieve a list of game servers within the multi-player menu in-game even after GameSpy ceases operation!

    Medal of Honor: Query Launcher - Find, browse, organize, join, get your ping, and get more information regarding all Medal of Honor (AA, SH, & BT) servers from your PC at any time!
    Medal of Honor: Web Server Master List - Find and browse all Medal of Honor servers online using your browser!
    Add your Medal of Honor Server to the Master List
    YouTube Video for Medal of Honor: Query Launcher and MOHAASERVERS.TK!



    MOHAA Mods and Utilities
    OwN-3m-All's Mods
    Make Me Stock - A program that allows you to easily move-in and move-out non-stock mods and other files at the click of a button. Automates adding / removing mods without having to copy / move files manually.



    Quality Game Servers

    Rent dedicated Dallas Texas, Kansas City, Las Vegas Nevada, Chicago, Pennsylvania, and Sofia Bulgaria MOHAA and other game servers from We Be HostiN starting at $10 a month.


  3. #3

    Default

    Or, in your case, you may want to check for the following and then just reset the counter back to 0 when your event fires:

    Code:
    if ((alliesmelt / local.MeltTheTeam) >= 1)
    {
        stuffsrv "!allies ftmelt"
        alliesmelt = 0
    }
    Browse MOHAA Servers Post GameSpy Era

    VISIT MOHREBORN.COM FOR LATEST INFORMATION



    Medal of Honor: Game Server Browser Fixer - Patches your MOHAA, MOHSH, and MOHBT game binaries to allow you to retrieve a list of game servers within the multi-player menu in-game even after GameSpy ceases operation!

    Medal of Honor: Query Launcher - Find, browse, organize, join, get your ping, and get more information regarding all Medal of Honor (AA, SH, & BT) servers from your PC at any time!
    Medal of Honor: Web Server Master List - Find and browse all Medal of Honor servers online using your browser!
    Add your Medal of Honor Server to the Master List
    YouTube Video for Medal of Honor: Query Launcher and MOHAASERVERS.TK!



    MOHAA Mods and Utilities
    OwN-3m-All's Mods
    Make Me Stock - A program that allows you to easily move-in and move-out non-stock mods and other files at the click of a button. Automates adding / removing mods without having to copy / move files manually.



    Quality Game Servers

    Rent dedicated Dallas Texas, Kansas City, Las Vegas Nevada, Chicago, Pennsylvania, and Sofia Bulgaria MOHAA and other game servers from We Be HostiN starting at $10 a month.


  4. #4

    Default

    Like this?


    server cfg:

    set allies_melts "15"


    script:

    if(level.allies_melts == int(getcvar(allies_melts)))
    {

    local.add_number = int(getcvar(allies_melts) + 15)
    setcvar allies_melts local.add_number

    setcvar !allies ftmelt

    }


    Dont know if the line 7 and 10 will work that way because i dont have test the script

  5. #5
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    276

    Default

    Modulus operator '%' is the best way IMHO.

    The more common way you see in programming languages (I assume mohscript does this too)...
    Code:
    if (x/y == int(x/y)) {
    T

  6. #6
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,603

    Default

    I think mohaa rounds floats in comparison ,

  7. #7

    Default

    I have change a little and this way works because i tested:

    Server.cfg
    Code:
    seta allies_melts "15"
    Script

    while(1)
    {
    wait 3

    local.melts = getcvar(allies_melts)

    if(level.allies_melts == int(local.melts))
    {

    local.add_number = int(local.melts) + 15

    setcvar "allies_melts" local.add_number

    setcvar "!allies" "ftmelt"

    }

    }

    end

  8. #8

    Default

    Well, I like my division approach better than modulus in this case because what happens if two players are unfrozen at the same time? It increments the counter before it gets a chance to run the modulus operator, and so, it won't always reset / unmelt all the players, but the greater than 1 check will :P
    Browse MOHAA Servers Post GameSpy Era

    VISIT MOHREBORN.COM FOR LATEST INFORMATION



    Medal of Honor: Game Server Browser Fixer - Patches your MOHAA, MOHSH, and MOHBT game binaries to allow you to retrieve a list of game servers within the multi-player menu in-game even after GameSpy ceases operation!

    Medal of Honor: Query Launcher - Find, browse, organize, join, get your ping, and get more information regarding all Medal of Honor (AA, SH, & BT) servers from your PC at any time!
    Medal of Honor: Web Server Master List - Find and browse all Medal of Honor servers online using your browser!
    Add your Medal of Honor Server to the Master List
    YouTube Video for Medal of Honor: Query Launcher and MOHAASERVERS.TK!



    MOHAA Mods and Utilities
    OwN-3m-All's Mods
    Make Me Stock - A program that allows you to easily move-in and move-out non-stock mods and other files at the click of a button. Automates adding / removing mods without having to copy / move files manually.



    Quality Game Servers

    Rent dedicated Dallas Texas, Kansas City, Las Vegas Nevada, Chicago, Pennsylvania, and Sofia Bulgaria MOHAA and other game servers from We Be HostiN starting at $10 a month.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •