OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: Cougarxr7 on 07 Jul 2009, 13:12:55

Title: Greeting message, local?
Post by: Cougarxr7 on 07 Jul 2009, 13:12:55
I have a greeting message for the server in sqs format.. The problem is it runs for all everytime someone joins the the game.
I have tried this,
Code: [Select]
?!local _unitName : goto "start"
#start
_counter = 1;
#loop
~10
Of course it did not work.
What I'd like to happend is the joining player gets the message, not players that has been in the server already.
Thanks!
Title: Re: Greeting message, local?
Post by: Spooner on 07 Jul 2009, 16:18:49
There is no message being shown in that code snippet (which also makes little sense out of context) and you haven't told us how you run it.
Title: Re: Greeting message, local?
Post by: Cougarxr7 on 07 Jul 2009, 16:48:22
My bad!
Here.
Code: [Select]
~10
titleText [format ["MESSAGE, %1", name player], "Plain down"]<this will be seen by all.
~10
?!local _unitName : goto "start"< from here on down joining player only.
#start
_counter = 1;
#loop
~10
titletext ["MESSAGE","Plain down"] 
~10
titletext ["MESSAGE!","Plain down"]
_counter = _counter - 1
? _counter > 0 : goto "loop"
exit
~10
Title: Re: Greeting message, local?
Post by: Spooner on 07 Jul 2009, 20:10:12
I've decided I'm finally going to completely stop supporting SQS any more, because it has been obsolete for a very long time and is literally a dead end for anyone who uses it, actually preventing them from writing good scripts! Also answers on how to use it only helps people to stay in a backwards language that hinders their abilities (and doesn't help people who have made the leap to SQF). Thus, it is simply a waste of my time. Sorry!

Your code seems a bit confused compared to what you said you wanted to achieve, so I'm not sure what is going on (and I can't fix something that I don't understand the intention of). Also, you didn't say how you ran it, which was the important part of what I asked you. If you run it in init.sqf(/sqs) then it will only run once. If you run it from the init line of all playable object, which is what I suspect you are doing, then yes, it will run every time someone JIPs into an empty position (assuming disabledAI is on).
Code: (init.sqf) [Select]
// Must wait until there is a player object spawned in to get the name of.
if (not isDedicated) then { waitUntil { alive player }; };
// Show this message once when player initially joins the game.
titleText [format ["Hello, %1, you are about to become a moon-fairy!", name player], "Plain down"];

Title: Re: Greeting message, local?
Post by: Cougarxr7 on 08 Jul 2009, 00:00:08
Spooner, thank you for the sqf file. I've been wanting to get rid of that sqs file.
Again Thanks!
Title: Re: Greeting message, local?
Post by: Spooner on 08 Jul 2009, 00:47:27
Yes, sorry, the declamation against SQS wasn't personally directed at you, but it is something that I've meaning to do for a while  :whistle:

I forgot the isDedicated check so that you don't wait forever if run on a dedi server (edited previous post).
Title: Re: Greeting message, local?
Post by: Cougarxr7 on 08 Jul 2009, 01:39:39
Spooner, no need to ever apologize to me, we are human and to me that makes us a 24/7 walking apology.
Is the sqf limited to a one line message?
I tried this in the init.sqf and it only showed the first line.
Code: [Select]
if (not isDedicated) then { waitUntil { alive player }; };
titleText [format ["Hello, %1, you are about to become a moon-fairy!", name player], "Plain down"];
sleep5
titletext ["my message!","Plain down"] 
sleep5
titletext ["my message","Plain down"]
sleep5
titletext ["my message","Plain down"]
sleep5
Then I tried it as a "greetings.sqf, with [] execVM "greetings.sqf"; in the init.sqf.
Only the first line showed up.
??
Title: Re: Greeting message, local?
Post by: Deadfast on 10 Jul 2009, 02:45:39
In SQF every line of command has to be ended by a semi column (;):

Code: [Select]
if (not isDedicated) then { waitUntil { alive player }; };
titleText [format ["Hello, %1, you are about to become a moon-fairy!", name player], "Plain down"];
sleep 5;
titletext ["my message!","Plain down"];
sleep 5;
titletext ["my message","Plain down"];
sleep 5;
titletext ["my message","Plain down"];
sleep 5;
Title: Re: Greeting message, local?
Post by: Cougarxr7 on 10 Jul 2009, 16:17:39
Deadfast, I totally spaced out and can't believe I missed something so common as those ;!
Thanks!