Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: MP Script Considerations, Client/Server Comms etc

  1. #1
    Opened up this topic for covering the client/server communications, how to have synchronised clients with server & thus with eachother, aswell as sharing thoughts and script snippets etc.

    In continuation of this thread, last posts:
    http://www.flashpoint1985.com/cgi-bin....w;st=15

    I want to kick off with some testing i've done and hope to get your thoughts:

    I made a server/client script for synchronising the time (especially taking JIP in account), fog and overcast with the server.
    It's half in SQF and half in SQS as I was not sure on how to get the same functionality from sqs in sqf (the @ part where it waits for the condition to be come true)

    Running on the server (execVM):<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// bc_server.sqf by Sickboy &#40;sb_at_6thSense.eu&#41;

    while {true} do
    {
    // Always broadcast time for JIP
    six_time = daytime; publicVariable &#34;six_time&#34;;

    // Only broadcast fog and overcast when different from last, saves bandwidth at static weather settings
    if&#40;six_fog &#33;= fog&#41; then { six_fog = fog; publicVariable &#34;six_fog&#34; };
    if&#40;six_overcast &#33;= overcast&#41; then { six_fog = overcast; publicVariable &#34;six_overcast&#34; };

    // Notify the clients we have broadcasted
    six_bc = true; publicVariable &#34;six_bc&#34;;
    sleep 20;
    };[/QUOTE]
    Running on the client (exec):<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; bc_client.sqs by Sickboy &#40;sb_at_6thSense.eu&#41;
    ;
    _timeset = false

    #lp
    @six_bc
    six_bc = false
    if &#40;overcast &#33;= six_overcast&#41; then { 5 setOvercast six_overcast };
    if &#40;fog &#33;= six_fog&#41; then { 5 setFog six_fog };
    if &#40;&#33;_timeset&#41; then { _six_time = &#40;six_time - daytime + 24&#41; % 24; skiptime _six_time; _timeset = true; if&#40;six_DEBUG_MISS&#41; then { hint format&#91;&#34;Timeset&#58; %1&#92;n%2&#34;,_six_time,six_time&#93; } };
    goto &#34;lp&#34;

    exit[/QUOTE]

    The mentioned variables are initialized at the start on both server and client:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">six_DEBUG_MISS = true; six_time = 0; six_fog = 0; six_overcast = 0[/QUOTE]

    This seems to work well, altough I have not yet extensively tested this, will do soon.

    I left DAC generating dynamic weather on the server on and disabled it on the clients, as the dac implementation usually isn&#39;t synchronised properly over the clients.
    (btw, don&#39;t ask me to share the edited DAC, as I have no permission from nor affiliation with Silola whatsoever, to release this etc. etc. so I will not, so don&#39;t ask )

    Of coarse this little piece can be used for other variables too, and other implementations aswell..
    I&#39;m wondering how this could be fully converted to SQF aswell as improving the code or even the whole implementation.

    I was playing around with onPlayerConnected etc. but don&#39;t seem to get the hang of it yet



    A.C.E. Advanced Combat Environment

    Dev-Heaven.net Free Project Hosting | A2 Community Issue Tracker Help BIS, Help yourself!

  2. #2
    I cannot test, but you could try:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    private &#91;&#34;_timeset&#34;&#93;;

    _timeset = false;

    while {true} do
    {
    *** switch &#40;six_bc&#41; do
    *** {
    *** *** ***case true&#58;
    *** *** ***{
    *** *** *** *** six_bc = false;
    *** *** *** *** if &#40;overcast &#33;= six_overcast&#41; then { 5 setOvercast six_overcast };
    *** *** *** *** if &#40;fog &#33;= six_fog&#41; then { 5 setFog six_fog };
    *** *** *** *** if &#40;&#33;_timeset&#41; then { _six_time = &#40;six_time - daytime + 24&#41; % 24; skiptime _six_time; _timeset = true; if&#40;six_DEBUG_MISS&#41; then { hint format&#91;&#34;Timeset&#58; %1&#92;n%2&#34;,_six_time,six_time&#93; } };
    *** *** ***};
    *** *** ***case default&#58;
    *** *** ***{
    *** *** *** *** sleep 1;
    *** *** ***};
    *** };
    };[/QUOTE]

    I would actually refine it further and make the weather changing a function and place into a seperate file and preprocess it, but it is all up to the coder.

  3. #3
    Colonel Sickboy's Avatar
    Join Date
    May 11 2005
    Location
    Netherlands
    Posts
    9,619
    Author of the Thread
    Quote Originally Posted by (CrashDome @ Dec. 12 2006,22:29)
    I cannot test, but you could try:
    ...
    I would actually refine it further and make the weather changing a function and place into a seperate file and preprocess it, but it is all up to the coder.
    Thanks m8&#33; Will have a go with the code tonight. I will consider the weather as functions etc, but that&#39;s &#39;tweaking&#39; in my books, as I got still shitloads to do

    Just picked this code up from the onplayerconnected howto thread:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">onplayerconnected &#34;&#91;&#93; exec &#34;&#34;PlayerConnected.sqs&#34;&#34; &#34;;[/QUOTE]execute only on the server.... (Probably change to execVM SQF)

    Now that I know how the implementation works of onplayerconnected (f*cking simple lol ) I can drop the time sync from the loop and place it in the onplayerconnected script, aswell as start thinking about all other scripting aspects

  4. #4
    Quote Originally Posted by [b
    Quote[/b] ]Now that I know how the implementation works of onplayerconnected (f*cking simple lol ) I can drop the time sync from the loop and place it in the onplayerconnected script, aswell as start thinking about all other scripting aspects
    Good deal&#33; Now i just gots to get me a copy....

  5. #5
    Colonel Sickboy's Avatar
    Join Date
    May 11 2005
    Location
    Netherlands
    Posts
    9,619
    Author of the Thread
    Quote Originally Posted by (CrashDome @ Dec. 13 2006,15:34)
    Good deal&#33; *** ***Now i just gots to get me a copy....
    32 euro at the czech online distribution
    48 euro at the german online distribution
    what are you waiting for ?

    offtopic though




  6. #6
    Quote Originally Posted by (sickboy @ Dec. 13 2006,08:54)
    32 euro at the czech online distribution
    48 euro at the german online distribution
    what are you waiting for ?
    English version.

    Unlike most people, I am only getting one copy and prefer it to be the one I want most&#33;

  7. #7
    Can you explain what this does more so a noob understands its value..


    By the way thank you for all of the work with the language packs

  8. #8
    Colonel Sickboy's Avatar
    Join Date
    May 11 2005
    Location
    Netherlands
    Posts
    9,619
    Author of the Thread
    Quote Originally Posted by (Breeze @ Dec. 17 2006,17:42)
    Can you explain what this does more so a noob understands its value..


    By the way thank you for all of the work ***with the language packs
    NP About the lang stuff

    The script stuff is to synchronise the server time, fog and overcast with the clients.

    There is some scripting missing to make it complete though I guess, if you want I can post those scripting examples aswell

  9. #9
    I started playing flashpoint about 5 months ago because of the advertisements of this game. I wanted to wait on map making until I got this game because I felt alot might change and wanted to get in with a game from the begining.

    I would love any help in learning this scripting I tried going through the tutorials and creating the examples shown but much of it does not work because of the differences in Arma and Flashpoint.

    So yea please post away.

    Also If you know how can you help show me how to get my spawns limited on mp maps so that a player can only have like 5 deaths before sitting balance of round.. I saw this as a parameter on flashpoint and got the parameter part to work but I cant tie the respawn to the parameter.

  10. #10
    nice one sickboy. I actually use this method for one of my missions because i use time acceleration there (every minute realtime is 5 minutes ingame time).

    This is run by a trigger so its run on the server:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    _delaytime = _this Select 0
    _skiphours = _this select 1

    #beginloop
    ~_delaytime
    skipTime _skiphours
    timeofday = date
    publicVariable &#34;timeofday&#34;
    ? &#40;&#33;&#40;local&#40;Server&#41;&#41;&#41; &#58; setDate &#91;&#40;timeofday select 0&#41;, &#40;timeofday select 1&#41;, &#40;timeofday select 2&#41;, &#40;timeofday select 3&#41;, &#40;timeofday select 4&#41;&#93;
    goto &#34;beginloop&#34;
    [/QUOTE]

    usage: [120, 0.25] exec "timeaccel.sqs"
    means that every 120 real life seconds, 15 minutes ingame should be skipped

    It also requires a game logic with the name Server

Page 1 of 2 12 LastLast

Posting Permissions

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