Jump to content

timeafterfirstfinish - different for maps


acp___(PL)

Recommended Posts

On my server I have maps that have persisted for one hour and maps persisted for one minut.

I would like to set a parameter "*timeafterfirstfinish" in file meta.xml for each map individual!

I'm too stupid to write script myself, so the only thing that occurred to me add the appropriate lines in the resource race (resorce included MTA:SA 1.0):

What I doing wrong?

meta.xls (resource race-jpetrol)

<?xml version="1.0" encoding="utf-16"?>
<meta>
 <info type="map" gamemodes="race" name="J Petrol" author="Gamingkrazy" description="Urmm... V1" version="1" />
 <map src="J Petrol.map" />
 <settings>
   <setting name="#respawn" value="timelimit" />
<setting name="*timeafterfirstfinish" value="20" />
<setting name="*ghostmode" value="false" />
       <setting name="*ghostalpha" value="false" />
       <setting name="*vehicleweapons" value="true" />
       <setting name="*autopimp" value="false" />
 </settings>
</meta>

<setting name="*timeafterfirstfinish" value="20" />

race_server.lua (resources race)

check line: 28, 57, 101, 102, 103, 147

(...)
function cacheGameOptions()
g_GameOptions = {}
g_GameOptions.timeafterfirstfinish  = getNumber('race.timeafterfirstfinish',30) * 1000
g_GameOptions.hurrytime				= getNumber('race.hurrytime',15) * 1000
g_GameOptions.defaultrespawntime	= getNumber('race.respawntime',5) * 1000
g_GameOptions.ghostmode				= getBool('race.ghostmode',false)
g_GameOptions.ghostalpha			= getBool('race.ghostalpha',false)
g_GameOptions.randommaps			= getBool('race.randommaps',false)
g_GameOptions.statskey				= getString('race.statskey','name')
g_GameOptions.vehiclecolors			= getString('race.vehiclecolors','file')
g_GameOptions.skins					= getString('race.skins','cj')
g_GameOptions.autopimp				= getBool('race.autopimp',true)
g_GameOptions.vehicleweapons		= getBool('race.vehicleweapons',true)
g_GameOptions.firewater				= getBool('race.firewater',false)
g_GameOptions.cachemodels			= getBool('race.cachemodels',true)
g_GameOptions.admingroup			= getString('race.admingroup','Admin')
g_GameOptions.blurlevel				= getNumber('race.blur',36)
g_GameOptions.cloudsenable			= getBool('race.clouds',true)
g_GameOptions.ghostmode_map_can_override		= getBool('race.ghostmode_map_can_override',true)
g_GameOptions.skins_map_can_override			= getBool('race.skins_map_can_override',true)
g_GameOptions.vehicleweapons_map_can_override   = getBool('race.vehicleweapons_map_can_override',true)
g_GameOptions.autopimp_map_can_override			= getBool('race.autopimp_map_can_override',true)
g_GameOptions.firewater_map_can_override		= getBool('race.firewater_map_can_override',true)
g_GameOptions.cachemodels_map_can_override		= getBool('race.cachemodels_map_can_override',true)
g_GameOptions.ghostmode_warning_if_map_override			= getBool('race.ghostmode_warning_if_map_override',true)
g_GameOptions.vehicleweapons_warning_if_map_override	= getBool('race.vehicleweapons_warning_if_map_override',true)
g_GameOptions.timeafterfirstfinish_map_override			= getNumber('race.timeafterfirstfinish',30) * 1000
 
if g_GameOptions.statskey ~= 'name' and g_GameOptions.statskey ~= 'serial' then
	outputWarning( "statskey is not set to 'name' or 'serial'" )
	g_GameOptions.statskey = 'name'
end
end
 
 
function cacheMapOptions(map)
g_MapOptions = {}
g_MapOptions.duration = map.duration and tonumber(map.duration) > 0 and map.duration*1000 or 600000
if g_MapOptions.duration > 86400000 then
	g_MapOptions.duration = 86400000
end
g_MapOptions.respawn = map.respawn
if not g_MapOptions.respawn or g_MapOptions.respawn ~= 'none' then
	g_MapOptions.respawn = 'timelimit'
end
g_MapOptions.respawntime	= g_MapOptions.respawn == 'timelimit' and (map.respawntime and map.respawntime*1000 or g_GameOptions.defaultrespawntime)
g_MapOptions.time			= map.time or '12:00'
g_MapOptions.weather		= map.weather or 0
 
g_MapOptions.skins			= map.skins or 'cj'
g_MapOptions.vehicleweapons = map.vehicleweapons == 'true'
g_MapOptions.ghostmode		= map.ghostmode == 'true'
g_MapOptions.autopimp		= map.autopimp == 'true'
g_MapOptions.firewater		= map.firewater == 'true'
g_MapOptions.cachemodels	= map.cachemodels == 'true'
       g_MapOptions.timeafterfirstfinish = map.timeafterfirstfinish or 30 * 1000
 
outputDebug("MISC", "duration = "..g_MapOptions.duration.."  respawn = "..g_MapOptions.respawn.."  respawntime = "..tostring(g_MapOptions.respawntime).."  time = "..g_MapOptions.time.."  weather = "..g_MapOptions.weather)
 
if g_MapOptions.time then
	setTime(g_MapOptions.time:match('(%d+)%d+)'))
end
if g_MapOptions.weather then
	setWeather(g_MapOptions.weather)
end
 
-- Set ghostmode from g_GameOptions if not defined in the map, or map override not allowed
if not map.ghostmode or not g_GameOptions.ghostmode_map_can_override then
	g_MapOptions.ghostmode = g_GameOptions.ghostmode
elseif g_GameOptions.ghostmode_warning_if_map_override and g_MapOptions.ghostmode ~= g_GameOptions.ghostmode then
	if g_MapOptions.ghostmode then
		outputChatBox( 'Notice: Collisions are turned off for this map' )
	else
		outputChatBox( 'Notice: Collisions are turned on for this map' )
	end
end
 
-- Set skins from g_GameOptions if not defined in the map, or map override not allowed
if not map.skins or not g_GameOptions.skins_map_can_override then
	g_MapOptions.skins = g_GameOptions.skins
end
 
-- Set vehicleweapons from g_GameOptions if not defined in the map, or map override not allowed
if not map.vehicleweapons or not g_GameOptions.vehicleweapons_map_can_override then
	g_MapOptions.vehicleweapons = g_GameOptions.vehicleweapons
elseif g_GameOptions.vehicleweapons_warning_if_map_override and g_MapOptions.vehicleweapons ~= g_GameOptions.vehicleweapons then
	if g_MapOptions.vehicleweapons then
		outputChatBox( 'Notice: Vehicle weapons are turned on for this map' )
	else
		outputChatBox( 'Notice: Vehicle weapons are turned off for this map' )
	end
end
 
-- Set autopimp from g_GameOptions if not defined in the map, or map override not allowed
if not map.autopimp or not g_GameOptions.autopimp_map_can_override then
	g_MapOptions.autopimp = g_GameOptions.autopimp
end
 
 
-- Set timeafterfirstfinish from g_GameOptions if not defined in the map, or map override not allowed
if not map.timeafterfirstfinish or not g_GameOptions.timeafterfirstfinish_map_override then
	g_MapOptions.timeafterfirstfinish = g_GameOptions.timeafterfirstfinish
end
 
-- Set firewater from g_GameOptions if not defined in the map, or map override not allowed
if not map.firewater or not g_GameOptions.firewater_map_can_override then
	g_MapOptions.firewater = g_GameOptions.firewater
end
 
-- Set cachemodels from g_GameOptions if not defined in the map, or map override not allowed
if not map.cachemodels or not g_GameOptions.cachemodels_map_can_override then
	g_MapOptions.cachemodels = g_GameOptions.cachemodels
end
end
 
 
 
-- Called from:
--      onGamemodeMapStart
function loadMap(res)
local map = RaceMap.load(res)
if not map then
	outputDebugString( 'Error loading map ' .. tostring(getResourceName(res)) )
       outputChatBox( 'Error loading map ' .. tostring(getResourceName(res)) )
	return false
end
 
-- set options
   g_MapInfo = {}
   g_MapInfo.name      = map.info['name'] or 'unnamed'
   g_MapInfo.resname   = map.info['resname'] or getResourceName(res)
 
g_SavedMapSettings = {}
g_SavedMapSettings.duration			= map.duration
g_SavedMapSettings.respawn			= map.respawn
g_SavedMapSettings.respawntime		= map.respawntime
g_SavedMapSettings.time				= map.time
g_SavedMapSettings.weather			= map.weather
g_SavedMapSettings.skins			= map.skins
g_SavedMapSettings.vehicleweapons	= map.vehicleweapons
g_SavedMapSettings.ghostmode		= map.ghostmode
g_SavedMapSettings.autopimp			= map.autopimp
g_SavedMapSettings.firewater		= map.firewater
g_SavedMapSettings.cachemodels		= map.cachemodels
g_SavedMapSettings.firewater		= map.firewater
g_SavedMapSettings.timeafterfirstfinish		= map.timeafterfirstfinish
(...)

meta.xls (resources race)

(...)
       <setting name="*ghostmode_map_can_override" friendlyname="Ghost mode map override" group="Gameplay" value="true" accept="false,true" desc="Set to true to allow the map to override this setting"/>
	<setting name="*skins_map_can_override"  friendlyname="Driver skin map override" group="Graphics" value="true" accept="false,true" desc="Set to true to allow the map to override this setting"/>
	<setting name="*vehicleweapons_map_can_override"  friendlyname="Vehicle weapons map override" group="Gameplay" value="true" accept="false,true" desc="Set to true to allow the map to override this setting"/>
	<setting name="*autopimp_map_can_override"  friendlyname="Auto pimp map override" group="Graphics" value="true" accept="false,true" desc="Set to true to allow the map to override this setting"/>
	<setting name="*firewater_map_can_override"  friendlyname="Firewater map override" group="Graphics" value="true" accept="false,true" desc="Set to true to allow the map to override this setting"/>
	<setting name="*cachemodels_map_can_override"  friendlyname="Cache models map override" group="_Advanced" value="true" accept="false,true" desc="Set to true to allow the map to override this setting"/>
	<setting name="*timeafterfirstfinish_map_can_override"  friendlyname="Finish race time map override" group="_Advanced" value="true" accept="false,true" desc="Set to true to allow the map to override this setting"/>
 
	<setting name="*ghostmode_warning_if_map_override"  friendlyname="Ghost mode override warning" group="Gameplay" value="true" accept="false,true" desc="Set to true to issue a warning to players in the chatbox, if the map overrides this setting"/>
	<setting name="*vehicleweapons_warning_if_map_override"  friendlyname="Vehicle weapons override warning" group="Gameplay" value="true" accept="false,true" desc="Set to true to issue a warning to players in the chatbox, if the map overrides this setting"/>
   </settings>
(...)

Link to comment

thanks for help

I was again analyze the race_serwer.lua and ...

line: 7

function cacheGameOptions()
g_GameOptions = {}
g_GameOptions.timeafterfirstfinish  = getNumber('race.timeafterfirstfinish',30) * 1000
g_GameOptions.hurrytime				= getNumber('race.hurrytime',15) * 1000
g_GameOptions.defaultrespawntime	= getNumber('race.respawntime',5) * 1000
(...)
g_GameOptions.timeafterfirstfinish_map_can_override		= getNumber('race.timeafterfirstfinish_map_can_override',30) * 1000

or now I think:

g_GameOptions.timeafterfirstfinish_map_can_override		= getBool('race.timeafterfirstfinish_map_can_override',true)

-- Set timeafterfirstfinish from g_GameOptions if not defined in the map, or map override not allowed
if not map.timeafterfirstfinish or not g_GameOptions.timeafterfirstfinish_map_can_override then
	g_MapOptions.timeafterfirstfinish = g_GameOptions.timeafterfirstfinish
end

g_SavedMapSettings.timeafterfirstfinish		= map.timeafterfirstfinish

Nobody can help me? :(

or

Nobody wants to help me? :x

Link to comment
  • 5 months later...

1. race.zip/modes/base.lua

-- Finish reached
	RaceMode.setPlayerIsFinished(player)
	finishActivePlayer( player )
	setPlayerStatus( player, nil, "finished" )
	if rank == 1 then
           gotoState('SomeoneWon')
		showMessage('You have won the race!', 0, 255, 0, player)
		if self.rankingBoard then	-- Remove lingering labels
			self.rankingBoard:destroy()
		end
		self.rankingBoard = RankingBoard:create()
		if g_MapOptions.duration then
			self:setTimeLeft( g_MapOptions.timeafterfirstfinish ) --2paq edit
		end
	else

2. race.zip/racemap.lua

g_MapSettingNames = table.create(
{'time', 'weather', 'respawn', 'respawntime', 'duration', 'timeafterfirstfinish', 'skins', 'bikehats', 'bikehatchance', 'carhats', 'carhatchance',
 'hairstyles', 'glasses', 'glasseschance', 'shirts', 'trousers', 'shoes',
 'ghostmode', 'vehicleweapons', 'autopimp', 'firewater', 'cachemodels', 'classicchangez'},
true
) --2paq edit

3. race.zip/race_server.lua

function cacheMapOptions(map)
g_MapOptions = {}
g_MapOptions.duration = map.duration and tonumber(map.duration) > 0 and map.duration*1000 or g_GameOptions.defaultduration
g_MapOptions.timeafterfirstfinish = map.timeafterfirstfinish and tonumber(map.timeafterfirstfinish) > 0 and map.timeafterfirstfinish*1000 or g_GameOptions.timeafterfirstfinish -- 2paq edit
if g_MapOptions.duration > 86400000 then
	g_MapOptions.duration = 86400000
end
(...)
end

function loadMap(res)
local map = RaceMap.load(res)
if not map then
	outputDebugString( 'Error loading map ' .. tostring(getResourceName(res)) )
       outputChatBox( 'Error loading map ' .. tostring(getResourceName(res)) )
	return false
end
 
-- set options
   g_MapInfo = {}
   g_MapInfo.name      = map.info['name'] or 'unnamed'
   g_MapInfo.resname   = map.info['resname'] or getResourceName(res)
 
g_SavedMapSettings = {}
g_SavedMapSettings.duration			= map.duration
g_SavedMapSettings.timeafterfirstfinish = map.timeafterfirstfinish --2paq edit
g_SavedMapSettings.respawn			= map.respawn
(...)
end

4. example: race-2paq1001.zip

meta.xml:

<meta>
 <include resource="2paq_driftmeter" />
 <info type="map" gamemodes="race" name="2paq1001" />
 <map src="2paq1001.map" />
 <settings>
   <setting name="#time" value="6:0" />
<setting name="*timeafterfirstfinish" value="120" />
<setting name="*ghostmode" value="false" />
       <setting name="*ghostalpha" value="false" />
       <setting name="*vehicleweapons" value="true" />
       <setting name="*autopimp" value="true" />
       <setting name="#duration" value="1215" />
 </settings>
</meta>

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...