UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Welcome Message (with sliding)

broken avatar :(
Created 11 years ago
by Cryptic
0 Members and 1 Guest are viewing this topic.
3,017 views
broken avatar :(
×
broken avatar :(
Location: ca
Date Registered: 28 November 2014
Last active: 9 years ago
Posts
7
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
Cryptic's Groups
Cryptic's Contact & Social Links
Introduction

I'm fairly new to this community, however I have a fair bit of background in programming and recently started getting into gsc. I scripted this more as an introduction for myself to gsc, but I thought somebody might find it useful if they wanted to implement it into their own map. If you have any improvements to the script or any suggestions, feel free to send them to me as I always wish to improve.

Tutorial

I personally like to write most of my custom script in my own gsc rather than populating the mapname gsc. I called mine "_welcome/gsc" and I placed it in the maps folder. You don't need to do this and you can just as easily call this as a function in the mapname gsc, but I personally find this messy.



In the gsc you've just created, paste the code below;

Code Snippet
Plaintext
#include common_scripts\utility;
#include maps\_utility;
#include maps\_zombiemode_utility;
#include maps\_hud_util;
     
main()
{
flag_wait("all_players_connected");
level.welcome   = self createText("Welcome to my map.", "center", "top", "center", "top", (0, 1, 1), -1, 75, 3.5, 1);
wait 3;
self moveElem(level.welcome, 5, 1000, 70); // replace 5 with the time in seconds it takes for the text to move
}

//===========================
//==   Generic Functions   ==
//===========================

createText(text, xalign, yalign, halign, valign, colour, x, y, fsize, alpha)
{
customText = create_simple_hud();
customText.alignX = xalign;
customText.alignY = yalign;
customText.horzAlign = halign;
customText.vertAlign = valign;
customText.x      = x;
customText.y      = y;
customText.foreground = 5;
customText.fontscale  = fsize;
customText.alpha = alpha;
customText.color = colour;

customText SetText(text);

return customText;
}

moveElem(elem, time, x, y)
{
elem moveOverTime(time);
elem.x = x;
elem.y = y;
}

The above is for if you are inserting your code into your own gsc. If you'd rather just use the mapname gsc, use the code below into your mapname gsc instead;

Code Snippet
Plaintext
createText(text, xalign, yalign, halign, valign, colour, x, y, fsize, alpha)
{
customText = create_simple_hud();
customText.alignX = xalign;
customText.alignY = yalign;
customText.horzAlign = halign;
customText.vertAlign = valign;
customText.x      = x;
customText.y      = y;
customText.foreground = 5;
customText.fontscale  = fsize;
customText.alpha = alpha;
customText.color = colour;

customText SetText(text);

return customText;
}

moveElem(elem, time, x, y)
{
elem moveOverTime(time);
elem.x = x;
elem.y = y;
}

Lastly, we must make sure that our gsc / method is called upon, or nothing will happen with the map is started. To do this (regardless if we use a custom gsc or a method in the mapname gsc), we must go into the mapname gsc and insert the following line after "maps\_zombiemode::main();".

If using a custom gsc
Code Snippet
Plaintext
maps\_welcome::main(); // replace _welcome with the name of your custom gsc file

If using a method in the mapname gsc
Code Snippet
Plaintext
        level.welcome   = self createText("Welcome to my map.", "center", "top", "center", "top", (0, 1, 1), -1, 75, 3.5, 1);
wait 3;
self moveElem(level.welcome, 5, 1000, 70); // replace 5 with the time in seconds it takes for the text to move

You should be set. You will most likely want to change some of these, such as the text created on the screen, the duration of the text sliding off the screen, the font size, etc.
broken avatar :(
×
broken avatar :(
Location: be
Date Registered: 17 August 2013
Last active: 4 years ago
Posts
369
Respect
Forum Rank
Perk Hacker
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
Web & Software Developer and Designer
Signature
"Deleted code is debugged code." - Jeff Sickel
"Mathematicians stand on each others' shoulders and computer scientists stand on each others' toes." - Richard Hamming
×
JR-Imagine's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
I see no point in having your welcome message being a global variable.
Also would be advised to thread the main() function instead of regularly calling it:
Code Snippet
Plaintext
thread maps\_welcome::main();
Otherwise any scripts called after will wait untill main() is done executing its functionality (which would be time it takes for all players to connect + 3 seconds).

 
Loading ...