1. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

What's the best way to do a welcome message?

Discussion in 'Modding Help' started by JaytleBee, Dec 21, 2015.

  1. JaytleBee

    JaytleBee Ballista Bolt Thrower
    1. [Server] Sandbox Reborn

    Messages:
    117
    Should I just put a onNewPlayerJoin hook in some file? All files that use that hook are serverside, so I'm pretty confused where I should put it.

    Thanks for your help ::):
     
  2. makmoud98

    makmoud98 You are already DEAD Forum Moderator Staff Alumni Tester

    Messages:
    586
    onNewPlayerJoin
    >set "just joined" bool on the player
    when creating the player's blob for spawning, check if just joined,
    >send command to player's blob, that renders the welcome message clientside
    >set the just join bool false
     
  3. Geti

    Geti Please avoid PMing me (poke a mod instead) THD Team Administrator Global Moderator

    Messages:
    3,730
    Significantly simpler option (completely untested but should work, with comments)
    Code:
    //only run on the client, no synced or shared state at all
    #define CLIENT_ONLY
    //script-local variables
    //wont be cleared between games
    bool show_message = true;
    u32 time_hide_message = 0;
    u32 show_time = 30; //seconds
    
    void onInit(CRules@ this)
    {
       //set this up once, when the script is initialised
       time_hide_message = Time() + show_time;
    }
    
    //logic
    //(this could be moved into onrender but that could
    // be run more often than we'd like)
    void onTick(CRules@ this)
    {
       if (!show_message)
       {
         return;
       }
    
       u32 current_time = Time();
       if (time_hide_message < current_time)
       {
         //you could actually remove the script but I have
         //no idea what happens if you do that on a clientside
         //rules script, this is safer
         show_message = false;
       }
    }
    
    //rendering
    void onRender(CRules@ this)
    {
       if(!show_message)
       {
         return;
       }
    
       //(do whatever you need to actually show the message here)
    }
    
     
    blackjoker77777 and Asu like this.
  4. JaytleBee

    JaytleBee Ballista Bolt Thrower
    1. [Server] Sandbox Reborn

    Messages:
    117
    Thanks, really helped me out!
     
    Geti likes this.