.:HyPeX:. Posted February 27, 2015 Share Posted February 27, 2015 Hello everyone, i've got a bug with my race gamemode, and it is that the players when joining, they arent set ever the "waiting" state, they're set alive, wich is annoying for all my customization i do arround the race state, becouse it detects alive players, wich are not. Where in the race is the "Waiting" state supposed to appear? So i can check if there's something faulty between the lines. Thanks HyPeX Link to comment
SpecT Posted February 27, 2015 Share Posted February 27, 2015 In race_server search for joinHandlerBoth function. At the end of the function there should be setPlayerStatus( player, nil, "Waiting" ) Link to comment
.:HyPeX:. Posted February 27, 2015 Author Share Posted February 27, 2015 I didnt found any errors with it, but i might be missing something, this is the function (Certainly longer than what i expected) function joinHandlerBoth(player) if #g_Spawnpoints == 0 then -- start vote if no map is loaded if not TimerManager.hasTimerFor("watchdog") then TimerManager.createTimerFor("map","watchdog"):setTimer( function() if #g_Spawnpoints == 0 then outputDebugString('No map loaded; showing votemanager') TimerManager.destroyTimersFor("spawn") RaceMode.endMap() end end, 1000, 1 ) end return else TimerManager.destroyTimersFor("watchdog") end if TimerManager.hasTimerFor("spawn") then for i,p in ipairs(getElementsByType('player')) do if not table.find(g_Players, p) then player = p break end end if not player then -- Is everyone ready? if howManyPlayersNotReady() == 0 then TimerManager.destroyTimersFor("spawn") if stateAllowsGridCountdown() then gotoState('GridCountdown') g_RaceStartCountdown:start() end end return end end local bPlayerJoined = not player if bPlayerJoined then player = source setPlayerStatus( player, "joined", "" ) else setPlayerStatus( player, "not ready", "" ) end if not player then outputDebug( 'MISC', 'joinHandler: player==nil' ) return end table.insert(g_Players, player) local vehicle if true then local spawnpoint = g_CurrentRaceMode:pickFreeSpawnpoint(player) local x, y, z = unpack(spawnpoint.position) -- Set random seed dependant on map name, so everyone gets the same models setRandomSeedForMap('clothes') if g_MapOptions.skins == 'cj' then spawnPlayer(player, x + 4, y, z, 0, 0) local clothes = { [16] = math.random(12, 13), [17] = 7 } -- 16=Hats(12:helmet 13:moto) 17=Extra(7:garageleg) for vehicles,vehicleclothes in pairs(g_VehicleClothes) do if table.find(vehicles, spawnpoint.vehicle) then for type,index in pairs(vehicleclothes) do clothes[type] = index or nil end end end local texture, model for type,index in pairs(clothes) do texture, model = getClothesByTypeIndex(type, index) addPedClothes(player, texture, model, type) end elseif g_MapOptions.skins == 'random' then repeat until spawnPlayer(player, x + 4, y, z, 0, math.random(9, 288)) else local ok for i=1,20 do ok = spawnPlayer(player, x + 4, y, z, 0, getRandomFromRangeList(g_MapOptions.skins)) if ok then break end end if not ok then spawnPlayer(player, x + 4, y, z, 0, 264) end end setPlayerSpectating(player, false) setPlayerNotReady( player ) setPedStat(player, 160, 1000) setPedStat(player, 229, 1000) setPedStat(player, 230, 1000) if spawnpoint.vehicle then setRandomSeedForMap('vehiclecolors') -- Replace groups of unprintable characters with a space, and then remove any leading space local plate = getPlayerName(player):gsub( '[^%a%d]+', ' ' ):gsub( '^ ', '' ) vehicle = createVehicle(spawnpoint.vehicle, x, y, z, 0, 0, spawnpoint.rotation, plate:sub(1, -- s8) -->) if setElementSyncer then setElementSyncer( vehicle, false ) end g_Vehicles[player] = vehicle Override.setAlpha( "ForRCVehicles", player, g_RCVehicleIDs[spawnpoint.vehicle] and 0 or nil ) RaceMode.playerFreeze(player) outputDebug( 'MISC', 'joinHandlerBoth: setElementFrozen true for ' .. tostring(getPlayerName(player)) .. ' vehicle:' .. tostring(vehicle) ) if bPlayerJoined and g_CurrentRaceMode.running then unfreezePlayerWhenReady(player) end if g_MapOptions.respawn == 'none' and not stateAllowsSpawnInNoRespawnMap() then g_CurrentRaceMode.setPlayerIsFinished(player) setElementPosition(vehicle, 0, 0, 0) end if spawnpoint.paintjob or spawnpoint.upgrades then setVehiclePaintjobAndUpgrades(vehicle, spawnpoint.paintjob, spawnpoint.upgrades) else if g_MapOptions.autopimp then pimpVehicleRandom(vehicle) end if g_GameOptions.vehiclecolors == 'random' then setRandomSeedForMap('vehiclecolors') local vehicleColorFixed = false for vehicleID,color in pairs(g_FixedColorVehicles) do if vehicleID == tonumber(spawnpoint.vehicle) then if color then setVehicleColor(vehicle, color[1], color[2], color[3], color[4]) end vehicleColorFixed = true break end end if not vehicleColorFixed then setVehicleColor(vehicle, math.random(0, 126), math.random(0, 126), 0, 0) end end end warpPedIntoVehicle(player, vehicle) end destroyBlipsAttachedTo(player) createBlipAttachedTo(player, 0, 1, 200, 200, 200) g_CurrentRaceMode:onPlayerJoin(player, spawnpoint) end -- Send client all info local playerInfo = {} playerInfo.admin = isPlayerInACLGroup(player, g_GameOptions.admingroup) playerInfo.testing = _TESTING playerInfo.joined = bPlayerJoined local duration = bPlayerJoined and (g_MapOptions.duration and (g_MapOptions.duration - g_CurrentRaceMode:getTimePassed()) or true) clientCall(player, 'initRace', vehicle, g_Checkpoints, g_Objects, g_Pickups, g_MapOptions, g_CurrentRaceMode:isRanked(), duration, g_GameOptions, g_MapInfo, playerInfo ) if bPlayerJoined and getPlayerCount() == 2 and stateAllowsRandomMapVote() and g_GameOptions.joinrandomvote then -- Start random map vote if someone joined a lone player mid-race TimerManager.createTimerFor("map"):setTimer(startMidMapVoteForRandomMap,7000,1) end -- Handle spectating when joined if g_CurrentRaceMode.isPlayerFinished(player) then -- Joining 'finished' clientCall(player, "Spectate.start", 'auto' ) setPlayerStatus( player, nil, "waiting" ) else if bPlayerJoined and g_CurrentRaceMode.running then -- Joining after start addActivePlayer(player) if g_GameOptions.joinspectating then clientCall(player, "Spectate.start", 'manual' ) setPlayerStatus( player, nil, "spectating") Override.setCollideOthers( "ForSpectating", RaceMode.getPlayerVehicle( player ), 0 ) end end end end isPlayerFinished relates to what? the conflict might come from there. Link to comment
SpecT Posted February 28, 2015 Share Posted February 28, 2015 I didnt found any errors with it, but i might be missing something, this is the function (Certainly longer than what i expected) function joinHandlerBoth(player) if #g_Spawnpoints == 0 then -- start vote if no map is loaded if not TimerManager.hasTimerFor("watchdog") then TimerManager.createTimerFor("map","watchdog"):setTimer( function() if #g_Spawnpoints == 0 then outputDebugString('No map loaded; showing votemanager') TimerManager.destroyTimersFor("spawn") RaceMode.endMap() end end, 1000, 1 ) end return else TimerManager.destroyTimersFor("watchdog") end if TimerManager.hasTimerFor("spawn") then for i,p in ipairs(getElementsByType('player')) do if not table.find(g_Players, p) then player = p break end end if not player then -- Is everyone ready? if howManyPlayersNotReady() == 0 then TimerManager.destroyTimersFor("spawn") if stateAllowsGridCountdown() then gotoState('GridCountdown') g_RaceStartCountdown:start() end end return end end local bPlayerJoined = not player if bPlayerJoined then player = source setPlayerStatus( player, "joined", "" ) else setPlayerStatus( player, "not ready", "" ) end if not player then outputDebug( 'MISC', 'joinHandler: player==nil' ) return end table.insert(g_Players, player) local vehicle if true then local spawnpoint = g_CurrentRaceMode:pickFreeSpawnpoint(player) local x, y, z = unpack(spawnpoint.position) -- Set random seed dependant on map name, so everyone gets the same models setRandomSeedForMap('clothes') if g_MapOptions.skins == 'cj' then spawnPlayer(player, x + 4, y, z, 0, 0) local clothes = { [16] = math.random(12, 13), [17] = 7 } -- 16=Hats(12:helmet 13:moto) 17=Extra(7:garageleg) for vehicles,vehicleclothes in pairs(g_VehicleClothes) do if table.find(vehicles, spawnpoint.vehicle) then for type,index in pairs(vehicleclothes) do clothes[type] = index or nil end end end local texture, model for type,index in pairs(clothes) do texture, model = getClothesByTypeIndex(type, index) addPedClothes(player, texture, model, type) end elseif g_MapOptions.skins == 'random' then repeat until spawnPlayer(player, x + 4, y, z, 0, math.random(9, 288)) else local ok for i=1,20 do ok = spawnPlayer(player, x + 4, y, z, 0, getRandomFromRangeList(g_MapOptions.skins)) if ok then break end end if not ok then spawnPlayer(player, x + 4, y, z, 0, 264) end end setPlayerSpectating(player, false) setPlayerNotReady( player ) setPedStat(player, 160, 1000) setPedStat(player, 229, 1000) setPedStat(player, 230, 1000) if spawnpoint.vehicle then setRandomSeedForMap('vehiclecolors') -- Replace groups of unprintable characters with a space, and then remove any leading space local plate = getPlayerName(player):gsub( '[^%a%d]+', ' ' ):gsub( '^ ', '' ) vehicle = createVehicle(spawnpoint.vehicle, x, y, z, 0, 0, spawnpoint.rotation, plate:sub(1, -- s8) -->) if setElementSyncer then setElementSyncer( vehicle, false ) end g_Vehicles[player] = vehicle Override.setAlpha( "ForRCVehicles", player, g_RCVehicleIDs[spawnpoint.vehicle] and 0 or nil ) RaceMode.playerFreeze(player) outputDebug( 'MISC', 'joinHandlerBoth: setElementFrozen true for ' .. tostring(getPlayerName(player)) .. ' vehicle:' .. tostring(vehicle) ) if bPlayerJoined and g_CurrentRaceMode.running then unfreezePlayerWhenReady(player) end if g_MapOptions.respawn == 'none' and not stateAllowsSpawnInNoRespawnMap() then g_CurrentRaceMode.setPlayerIsFinished(player) setElementPosition(vehicle, 0, 0, 0) end if spawnpoint.paintjob or spawnpoint.upgrades then setVehiclePaintjobAndUpgrades(vehicle, spawnpoint.paintjob, spawnpoint.upgrades) else if g_MapOptions.autopimp then pimpVehicleRandom(vehicle) end if g_GameOptions.vehiclecolors == 'random' then setRandomSeedForMap('vehiclecolors') local vehicleColorFixed = false for vehicleID,color in pairs(g_FixedColorVehicles) do if vehicleID == tonumber(spawnpoint.vehicle) then if color then setVehicleColor(vehicle, color[1], color[2], color[3], color[4]) end vehicleColorFixed = true break end end if not vehicleColorFixed then setVehicleColor(vehicle, math.random(0, 126), math.random(0, 126), 0, 0) end end end warpPedIntoVehicle(player, vehicle) end destroyBlipsAttachedTo(player) createBlipAttachedTo(player, 0, 1, 200, 200, 200) g_CurrentRaceMode:onPlayerJoin(player, spawnpoint) end -- Send client all info local playerInfo = {} playerInfo.admin = isPlayerInACLGroup(player, g_GameOptions.admingroup) playerInfo.testing = _TESTING playerInfo.joined = bPlayerJoined local duration = bPlayerJoined and (g_MapOptions.duration and (g_MapOptions.duration - g_CurrentRaceMode:getTimePassed()) or true) clientCall(player, 'initRace', vehicle, g_Checkpoints, g_Objects, g_Pickups, g_MapOptions, g_CurrentRaceMode:isRanked(), duration, g_GameOptions, g_MapInfo, playerInfo ) if bPlayerJoined and getPlayerCount() == 2 and stateAllowsRandomMapVote() and g_GameOptions.joinrandomvote then -- Start random map vote if someone joined a lone player mid-race TimerManager.createTimerFor("map"):setTimer(startMidMapVoteForRandomMap,7000,1) end -- Handle spectating when joined if g_CurrentRaceMode.isPlayerFinished(player) then -- Joining 'finished' clientCall(player, "Spectate.start", 'auto' ) setPlayerStatus( player, nil, "waiting" ) else if bPlayerJoined and g_CurrentRaceMode.running then -- Joining after start addActivePlayer(player) if g_GameOptions.joinspectating then clientCall(player, "Spectate.start", 'manual' ) setPlayerStatus( player, nil, "spectating") Override.setCollideOthers( "ForSpectating", RaceMode.getPlayerVehicle( player ), 0 ) end end end end isPlayerFinished relates to what? the conflict might come from there. I have not found missing code. About the isPlayerFinished: function isPlayerFinished(player) return getElementData(player, 'race.finished') or false end Its for the race maps with checkpoints. Link to comment
.:HyPeX:. Posted February 28, 2015 Author Share Posted February 28, 2015 Okay then, came down to this: if g_CurrentRaceMode.isPlayerFinished(player) then -- Joining 'finished' clientCall(player, "Spectate.start", 'auto' ) setPlayerStatus( player, nil, "waiting" ) else if bPlayerJoined and g_CurrentRaceMode.running then -- Joining after start addActivePlayer(player) if g_GameOptions.joinspectating then clientCall(player, "Spectate.start", 'manual' ) setPlayerStatus( player, nil, "spectating") Override.setCollideOthers( "ForSpectating", RaceMode.getPlayerVehicle( player ), 0 ) end end end There's only one way it wouldnt be set an spectating state, wich would be if the first if failed, and then it didnt matched one of the following ones, g_GameOptions.joinspectating would be set from the admin panel, right? EDIT: Its not that maybe, what sets the player to "alive" state? it might be aswell be set alive state prematurely.. Link to comment
SpecT Posted February 28, 2015 Share Posted February 28, 2015 Okay then, came down to this: if g_CurrentRaceMode.isPlayerFinished(player) then -- Joining 'finished' clientCall(player, "Spectate.start", 'auto' ) setPlayerStatus( player, nil, "waiting" ) else if bPlayerJoined and g_CurrentRaceMode.running then -- Joining after start addActivePlayer(player) if g_GameOptions.joinspectating then clientCall(player, "Spectate.start", 'manual' ) setPlayerStatus( player, nil, "spectating") Override.setCollideOthers( "ForSpectating", RaceMode.getPlayerVehicle( player ), 0 ) end end end There's only one way it wouldnt be set an spectating state, wich would be if the first if failed, and then it didnt matched one of the following ones, g_GameOptions.joinspectating would be set from the admin panel, right? EDIT: Its not that maybe, what sets the player to "alive" state? it might be aswell be set alive state prematurely.. Hmm ... You should have setPlayerReady function that sets the player to "alive" state. Maybe that function is missing or its wrong ... Post it's code. Link to comment
.:HyPeX:. Posted February 28, 2015 Author Share Posted February 28, 2015 Only 2 matches found. From race_server: addEvent('onNotifyPlayerReady', true) addEventHandler('onNotifyPlayerReady', g_Root, function() if checkClient( false, source, 'onNotifyPlayerReady' ) then return end setPlayerReady( source ) for i, pickupID in ipairs(unloadedPickups) do -- outputDebugString(getPlayerName(source).." unload "..tostring(pickupID)) clientCall(source, "unloadPickup", pickupID ) end end function setPlayerReady( player ) setElementData(player, "state", "alive") g_NotReady[player] = false g_NotReadyTimeout = getTickCount() + 20000 if _DEBUG_TIMING then g_NotReadyTimeout = g_NotReadyTimeout - 10000 end -- Set max timeout to 30 seconds after first person is ready if not g_NotReadyMaxWait then g_NotReadyMaxWait = getTickCount() + 30000 end end Link to comment
SpecT Posted February 28, 2015 Share Posted February 28, 2015 In the original race gamemode the code is not like this: setElementData(player, "state", "alive") It is: setPlayerStatus( player, "alive", nil ) Replace it and tell me what is the result. Link to comment
.:HyPeX:. Posted March 2, 2015 Author Share Posted March 2, 2015 Tried so far and it seems fixed, i'd need a realtime test to know if it does fix it. For now that seems to work, but i got an issue aside, when there's more than one player, i've got a podium script when all players die. (I let the single one live until it dies, deathmatch mode). My issue is that when there's more than one player, the podium has black-outs, the camera moves away, i'm afraid, and i dont know why. And this only happens with 2 or more players. My idea was that maybe the spectators as it failed to have a target, it simply moves the camera away (As it'd do if all alive players went spectating). Where is this part of the spectating to test if disabling it fixes it? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now