User:Ccw: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Removing all content from page)
No edit summary
Line 1: Line 1:
__NOTOC__
= Things that keep me awake at night =


== WARNING: Gamemodes which depend on being started with the mapmanager may explode==
That is, gamemodes which either use the mapmanger events '''onGamemodeStop()/Start()''' or ''' onGamemodeMapStop()/Start()''' or depend on the 'one gamemode at a time' system enforced by the mapmanager, may malfunction if invoked with 'start gamemode' or startResource().
Affected gamemodes are:
*assault
*battlefield69
*cdm
*ctf
*cto
*ctv
*fallout
*hay
*interstate69
*race
*stealth
*tdma
*teamwars
*freeroam
Noob admins who don't use the mapmanger will have gamemode errors with little obvious reason why.
Also, stuff like the web browser and the admin panel, all start resources with startResource(), which will not work correctly with the gamemodes listed above.
=== Solution A ===
When starting a gamemode from inside a script, instead of using:
<syntaxhighlight lang="lua">
    startResource( getResourceFromName('gamemode') )
</syntaxhighlight>
use this instead:
<syntaxhighlight lang="lua">
    exports.mapmanager:changeGamemode( getResourceFromName('gamemode') )
</syntaxhighlight>
=== Solution B ===
Or, perhaps a more better way would be to insert this bit of code into each affected gamemode:
<syntaxhighlight lang="lua">
----------------------------------------------------
-- Divert to mapmanager if 'start' command used
----------------------------------------------------
addEventHandler('onResourceStart', g_ResRoot,
    function()
        setTimer(
            function()
                if not g_bCalledOnGamemodeStart then
                    outputConsole( "Trying to restart '" .. getResourceName(getThisResource()) .. "' with mapmanager..." )
                    exports.mapmanager:changeGamemode( getThisResource() )
                end
            end
            ,900,1)
end
)
addEventHandler('onGamemodeStart', g_ResRoot,
    function()
        g_bCalledOnGamemodeStart = true
    end
)
</syntaxhighlight>
Both solutions assume the mapmanger is up and running first. But that is requirement for these gamemodes anyway.

Revision as of 01:07, 2 April 2009

Things that keep me awake at night

WARNING: Gamemodes which depend on being started with the mapmanager may explode

That is, gamemodes which either use the mapmanger events onGamemodeStop()/Start() or onGamemodeMapStop()/Start() or depend on the 'one gamemode at a time' system enforced by the mapmanager, may malfunction if invoked with 'start gamemode' or startResource().

Affected gamemodes are:

  • assault
  • battlefield69
  • cdm
  • ctf
  • cto
  • ctv
  • fallout
  • hay
  • interstate69
  • race
  • stealth
  • tdma
  • teamwars
  • freeroam

Noob admins who don't use the mapmanger will have gamemode errors with little obvious reason why. Also, stuff like the web browser and the admin panel, all start resources with startResource(), which will not work correctly with the gamemodes listed above.


Solution A

When starting a gamemode from inside a script, instead of using:

    startResource( getResourceFromName('gamemode') )

use this instead:

    exports.mapmanager:changeGamemode( getResourceFromName('gamemode') )


Solution B

Or, perhaps a more better way would be to insert this bit of code into each affected gamemode:

----------------------------------------------------
-- Divert to mapmanager if 'start' command used
----------------------------------------------------
addEventHandler('onResourceStart', g_ResRoot,
    function()
        setTimer(
            function()
                if not g_bCalledOnGamemodeStart then
                    outputConsole( "Trying to restart '" .. getResourceName(getThisResource()) .. "' with mapmanager..." )
                    exports.mapmanager:changeGamemode( getThisResource() )
                end
            end
            ,900,1)
	end
)

addEventHandler('onGamemodeStart', g_ResRoot,
    function()
        g_bCalledOnGamemodeStart = true
    end
)


Both solutions assume the mapmanger is up and running first. But that is requirement for these gamemodes anyway.