Results 1 to 7 of 7

Thread: Question: How to force weapons select at beginning of new map

  1. #1

    Default Question: How to force weapons select at beginning of new map

    Hi all total newb but I try. I've been lurking here on and off for a while. I don't think I've posted...

    Anyway, what I'd like to do is to bring up the weapons screen in MOHAA at the beginning of a new map, like Spearhead does.

    I know how to force the weapons choice, and it works,but I'm not sure how to trigger it at a map change.
    for(local.i = 1; local.i <= $player.size; local.i++)
    {
    local.player = $player[local.i]

    if(local.i == 1 && local.player.dmteam == spectator)
    {
    // do nothing
    // because this might be a fake player
    // on a 'virgin' dedicated server
    // stufftexting will eventually crash the server
    }
    else
    {

    local.player stufftext ("pushmenu_weaponselect")
    }

    }
    Do I need to add this to the script for each and every map, or hopefully I can just add it once with the other scripts I run.

    Any help is appreciated.

  2. #2

    Default

    You have to save the mapname to a cvar and when the server change the map, you have to check what map he is running and if his different you execute the code.

  3. #3

    Default

    Quote Originally Posted by DoubleKill View Post
    You have to save the mapname to a cvar and when the server change the map, you have to check what map he is running and if his different you execute the code.
    That's not a bad idea, thanks.

    So would I do it after level waittill spawn, or level waittill roundstart, or what?

  4. #4

    Default

    The code you have is not enough for what you need.

    This is the steps you need:

    - Detect the player when he join the map first time because not every player join at the same time as the others.
    - Record the player when he join the map so the code dont trigger again when the server do the next round.

    To detect the player have spawn the first time you can use the spawn event but to record the player you have 3 ways, you can store him in a file, store all names in a cvar or set a new cvar with the player name.

    Seems storing in a file is more simple.

  5. #5

    Default

    I only want to do this for players who are already on a team, every time a new map starts. So when a new map comes up, they get a chance to pick the weapon they like for that map, and start playing with it right away.

    People who are in spec or join later in the round, nothing should happen.

    So what I think I need to do is figure out how to know when a new map has just started, so I can trigger this just as people spawn in.

    Edit: Think I got it...
    main:
    thread chooseweap
    end

    chooseweap:
    level.mapname = getcvar (mapname)
    level.lastmapname = getcvar (lastmapname)
    if (level.mapname != level.lastmapname)
    {
    for(local.i = 1; local.i <= $player.size; local.i++)
    {
    local.player = $player[local.i]

    if(local.i == 1 && local.player.dmteam == spectator)
    {
    // do nothing
    // because this might be a fake player
    // on a 'virgin' dedicated server
    // stufftexting will eventually crash the server
    }
    else
    {

    local.player stufftext ("pushmenu_weaponselect")
    }

    }

    }
    wait 30
    setcvar lastmapname level.mapname
    thread chooseweap // loop back

    end


    Last edited by HighonDeath; May 22nd, 2020 at 01:32 PM.

  6. #6

    Default

    Hey HOD. I'm pretty sure you could use the intermission event for this.

    Here's the link to the event: https://x-null.net/wiki/index.php?ti...m#Intermission

    The setup:

    Pick a .scr that's executed on every map load. Normally dmprecache.scr is a safe bet, but sometimes custom maps don't exec this. This example will use dmprecache.scr though.

    Open dmprecache.scr in your servermods.pk3 and add the following line:

    level waittil spawn
    exec global/intermission.scr


    Create a new .scr called intermission.scr and place it in the Global folder of your servermods.pk3. Add the following to the new .scr:


    main:
    local.result = registerev intermission global/intermission.scr::intermission
    end

    intermission local.type:

    if(local.type == 0)
    {
    exec global\yourweaponscript.scr
    }

    end


    That should execute your script every time the intermission screen pops up. You could also play around with the events to do it on spawn or join

  7. #7

    Default

    Hey Splatter,

    Thanks, that's pretty close. What that does is bring it up when the old map is ending. Is there any way to bring it up after the new map starts loading?

    EDIT or what I've got now would be perfect, if I only knew how to tell the player what map is about to load.
    Last edited by HighonDeath; May 23rd, 2020 at 09:55 AM.

Posting Permissions

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