dim3 Forum

Full Version: Game Timer(Online)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm not sure what's wrong with this. It works fine offline, but on a server it doesn't work. Supposed to restart the map every foo amount of time. Should be fairly obvious as to how it works. Could it be that functionality like this doesn't work online?

-- Please no off-topic posting. Try to keep your answers useful.

Code:
// ***********************************************************

//

// Game Script

//

// This script is the main script for the entire game.

//

// ***********************************************************



// menu item ids



var MENU_ITEM_CONTINUE=0;

var MENU_ITEM_SETUP=2;

var MENU_ITEM_SAVE_LOAD=3;



var MENU_ITEM_SHOW_CONSOLE=10;

var MENU_ITEM_HIDE_CONSOLE=11;


// other ids, etc

const GAME_TIMER_ID=100;

var currentTime=60;


//

// game startup

//



function gameConstruct(game)

{

        // set the scaling factor for the bitmaps

    

    iface.screen.widthScale=640;

    iface.screen.heightScale=480;

    

        // get starting spot for player

        

    if (map.setting.multiplayer) {
        map.action.setHostMap('Spawn','Player');
    }
    
    game.event.startTimer(10,GAME_TIMER_ID);
    
        // set timer variable, in seconds
    
    currentTime=60;

}


function gameTimer(game)
{
    if (currentTime!=0) {
        iface.text.setText('Timer',currentTime);
        currentTime--;
    } else {
        game.event.clearTimer();
        game.event.sendMessageToPlayer(997);
        game.event.startWait(50, 996);
    }

}


//

// handle menu events

//

    

function gameMenuSelect(id)

{

    switch (id) {

    

        case MENU_ITEM_CONTINUE:

            return;

            

        case MENU_ITEM_SETUP:

            iface.interaction.startSetup();

            return;

            

        case MENU_ITEM_SAVE_LOAD:

            iface.interaction.startSaveLoad();

            return;

                        

        case MENU_ITEM_SHOW_CONSOLE:

            iface.console.show();

            return;



        case MENU_ITEM_HIDE_CONSOLE:

            iface.console.hide();

            return;

            

    }



}



//

// handle score changes for players in game

//



function gameScore(game)

{

    switch (game.setting.type) {



        case 'CTF':

            game.score.setScore(game.score.goal);

            break;



        default:

            game.score.setScore(game.score.kill+1);

            break;



    }

}



//

// handle game events

//



function event(game,mainEvent,subEvent,id,tick)

{

    switch (mainEvent) {

    

        case DIM3_EVENT_CONSTRUCT:

            gameConstruct(game);

            return;

            

        case DIM3_EVENT_MENU:

            gameMenuSelect(id);

            return;



        case DIM3_EVENT_RULE_SCORE:

            gameScore(game);

            return;
            
        case DIM3_EVENT_WAIT:
            map.action.restartMap();
            return;

            

    }

}
Sorry, missed this topic. The quick answer is it's not going to work, the local game script itself (in a network game) can't change the map. The server itself doesn't actually run a script but negotiations the client versions of the scripts.

If you want the server itself to randomly change the maps, then that's something I could add.

[>] Brian
That's terrible, Brian. You need to have a game, cgame, etc. game bing the server and cgame being the client-side scripts. Game.js and course scripts need to be serverside. The client should download the server's. Also the server should check client file checksum to make sure it's the same. Please change the game.js and course scripts (maybe more) to serverside so functionality like this can be done by creaters.
teh1ghool Wrote:That's terrible, Brian. You need to have a game, cgame, etc. game bing the server and cgame being the client-side scripts. Game.js and course scripts need to be serverside. The client should download the server's. Also the server should check client file checksum to make sure it's the same. Please change the game.js and course scripts (maybe more) to serverside so functionality like this can be done by creaters.

You need to think a little more about networking on fast games Smile All network games that are quake/UT like are client to client with the server acting as a negotiator.

Now, what happens is that the clients themselves can tell the server to change the maps, and that's fine, that's what they are doing, but it's still client to client (otherwise the lag would be too great as all messages would need to round-robin through server physics.)

Eventually, the server itself will have the ability to run scripts, but right now that won't happen yet as there's too many other things to get working right, first.

[>] Brian
Well there needs to be a way to do what I want done in scripts. Things like this can't just be added to the core, Brian. That kind of defeats the purpose of scripting...
teh1ghool Wrote:Well there needs to be a way to do what I want done in scripts. Things like this can't just be added to the core, Brian. That kind of defeats the purpose of scripting...

Oh yeah, I agree, and there will be in the future, for sure. Scripting server is something that I'll definitely work on, but right now I still have people that can't seem to get the server running as is, so that's my highest priority.

[>] Brian
Yessir, understood. Please start this as soon as the server is working again. Absolutely destroys ability to have online games. Online games are pretty much always time-based.
Reference URL's