MrXz Posted January 26, 2012 Posted January 26, 2012 function SToptimesManager:playerFinished( player, newTime, dateRecorded ) -- Check if top time recording is disabled for this player if getElementData ( player, "toptimes" ) == "off" then return end if not self.mapTimes then outputDebug( 'TOPTIMES', 'SToptimesManager:playerFinished - self.mapTimes == nil' ) return end dateRecorded = dateRecorded or getRealDateTimeNowString() local oldTime = self.mapTimes:getTimeForPlayer( player ) -- Can be false if no previous time local newPos = self.mapTimes:getPositionForTime( newTime, dateRecorded ) -- See if time is an improvement for this player if not oldTime or newTime < oldTime then local oldPos = self.mapTimes:getIndexForPlayer( player ) triggerEvent("onPlayerToptimeImprovement", player, newPos, newTime, oldPos, oldTime, self.displayTopCount, self.mapTimes:getValidEntryCount() ) -- See if its in the top display if newPos <= self.displayTopCount then outputChatBox( 'TOPTIMES' .. getPlayerName(player) .. 'got toptime position' .. newPos ) end if oldTime then outputChatBox( 'TOPTIMES', getPlayerName(player) .. ' new personal best ' .. newTime .. ' ' .. oldTime - newTime ) end self.mapTimes:setTimeForPlayer( player, newTime, dateRecorded ) -- updateTopText if database was changed if newPos <= self.displayTopCount then self:updateTopText() end end outputDebug( 'TOPTIMES', '++ SToptimesManager:playerFinished ' .. tostring(getPlayerName(player)) .. ' time:' .. tostring(newTime) ) end I made this script so that when a player makes a toptime, out in the chatbox ..time appears but It does not work ... =/
Castillo Posted January 26, 2012 Posted January 26, 2012 function SToptimesManager:playerFinished( player, newTime, dateRecorded ) -- Check if top time recording is disabled for this player if getElementData ( player, "toptimes" ) == "off" then return end if not self.mapTimes then outputDebug( 'TOPTIMES', 'SToptimesManager:playerFinished - self.mapTimes == nil' ) return end dateRecorded = dateRecorded or getRealDateTimeNowString() local oldTime = self.mapTimes:getTimeForPlayer( player ) -- Can be false if no previous time local newPos = self.mapTimes:getPositionForTime( newTime, dateRecorded ) -- See if time is an improvement for this player if not oldTime or newTime < oldTime then local oldPos = self.mapTimes:getIndexForPlayer( player ) triggerEvent("onPlayerToptimeImprovement", player, newPos, newTime, oldPos, oldTime, self.displayTopCount, self.mapTimes:getValidEntryCount() ) -- See if its in the top display if newPos <= self.displayTopCount then outputChatBox( 'TOPTIMES: ' .. getPlayerName(player) .. 'got toptime position ' .. newPos, root ) end if oldTime then outputChatBox( 'TOPTIMES: '.. getPlayerName(player) .. ' new personal best ' .. newTime .. ' ' .. oldTime - newTime, root ) end self.mapTimes:setTimeForPlayer( player, newTime, dateRecorded ) -- updateTopText if database was changed if newPos <= self.displayTopCount then self:updateTopText() end end outputDebug( 'TOPTIMES', '++ SToptimesManager:playerFinished ' .. tostring(getPlayerName(player)) .. ' time:' .. tostring(newTime) ) end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
MrXz Posted January 26, 2012 Author Posted January 26, 2012 function SToptimesManager:playerFinished( player, newTime, dateRecorded ) -- Check if top time recording is disabled for this player if getElementData ( player, "toptimes" ) == "off" then return end if not self.mapTimes then outputDebug( 'TOPTIMES', 'SToptimesManager:playerFinished - self.mapTimes == nil' ) return end dateRecorded = dateRecorded or getRealDateTimeNowString() local oldTime = self.mapTimes:getTimeForPlayer( player ) -- Can be false if no previous time local newPos = self.mapTimes:getPositionForTime( newTime, dateRecorded ) -- See if time is an improvement for this player if not oldTime or newTime < oldTime then local oldPos = self.mapTimes:getIndexForPlayer( player ) triggerEvent("onPlayerToptimeImprovement", player, newPos, newTime, oldPos, oldTime, self.displayTopCount, self.mapTimes:getValidEntryCount() ) -- See if its in the top display if newPos <= self.displayTopCount then outputChatBox( '#FF0000[TopTime]: #FFFFFF' .. getPlayerName(player) .. ' #00FF37got toptime position ' .. newPos .. ' time: ' .. newTime, root, 2, 255, 2, true) end if oldTime then outputChatBox( 'TOPTIMES: '.. getPlayerName(player) .. ' new personal best ' .. newTime .. ' ' .. oldTime - newTime, root ) end self.mapTimes:setTimeForPlayer( player, newTime, dateRecorded ) -- updateTopText if database was changed if newPos <= self.displayTopCount then self:updateTopText() end end outputDebug( 'TOPTIMES', '++ SToptimesManager:playerFinished ' .. tostring(getPlayerName(player)) .. ' time:' .. tostring(newTime) ) end Now I did this that appears time .. but time out in seconds ..as I get time as the toptime? addEvent('onPlayerPickUpRacePickup') addEventHandler('onPlayerPickUpRacePickup', g_Root, function(number, sort, model) if sort == "vehiclechange" then if model == 425 then outputChatBox ( source, "has got the Hunter", getRootElement(), 255, 255, 255, true ) if g_SToptimesManager then g_SToptimesManager:playerFinished( source, exports.race:getTimePassed()) end end end end ) and notice of hunter .. not work for me either .. =/ Pleasee Help That would be all ^^!
Castillo Posted January 27, 2012 Posted January 27, 2012 addEvent('onPlayerPickUpRacePickup') addEventHandler('onPlayerPickUpRacePickup', g_Root, function(number, sort, model) if (sort == "vehiclechange" and model == 425) then outputChatBox ( getPlayerName(source) .." has got the Hunter", getRootElement(), 255, 255, 255, true ) if g_SToptimesManager then g_SToptimesManager:playerFinished( source, exports.race:getTimePassed()) end end end ) I don't get what do you mean about Top Times. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
MrXz Posted January 27, 2012 Author Posted January 27, 2012 function SToptimesManager:playerFinished( player, newTime, dateRecorded ) -- Check if top time recording is disabled for this player if getElementData ( player, "toptimes" ) == "off" then return end if not self.mapTimes then outputDebug( 'TOPTIMES', 'SToptimesManager:playerFinished - self.mapTimes == nil' ) return end dateRecorded = dateRecorded or getRealDateTimeNowString() local oldTime = self.mapTimes:getTimeForPlayer( player ) -- Can be false if no previous time local newPos = self.mapTimes:getPositionForTime( newTime, dateRecorded ) -- See if time is an improvement for this player if not oldTime or newTime < oldTime then local oldPos = self.mapTimes:getIndexForPlayer( player ) triggerEvent("onPlayerToptimeImprovement", player, newPos, newTime, oldPos, oldTime, self.displayTopCount, self.mapTimes:getValidEntryCount() ) -- See if its in the top display if newPos <= self.displayTopCount then outputChatBox( '#FF0000[TopTime]: #FFFFFF' .. getPlayerName(player) .. ' #00FF37got toptime position ' .. newPos .. ' time: ' .. newTime, root, 2, 255, 2, true) end if oldTime then outputChatBox( 'TOPTIMES: '.. getPlayerName(player) .. ' new personal best ' .. newTime .. ' ' .. oldTime - newTime, root ) end self.mapTimes:setTimeForPlayer( player, newTime, dateRecorded ) -- updateTopText if database was changed if newPos <= self.displayTopCount then self:updateTopText() end end outputDebug( 'TOPTIMES', '++ SToptimesManager:playerFinished ' .. tostring(getPlayerName(player)) .. ' time:' .. tostring(newTime) ) end I say .. I made this script ... but the time in the chat out in seconds.. as I can put in minutes as in the toptimes change from seconds to minutes...
Castillo Posted January 27, 2012 Posted January 27, 2012 function SToptimesManager:playerFinished( player, newTime, dateRecorded ) -- Check if top time recording is disabled for this player if getElementData ( player, "toptimes" ) == "off" then return end if not self.mapTimes then outputDebug( 'TOPTIMES', 'SToptimesManager:playerFinished - self.mapTimes == nil' ) return end dateRecorded = dateRecorded or getRealDateTimeNowString() local oldTime = self.mapTimes:getTimeForPlayer( player ) -- Can be false if no previous time local newPos = self.mapTimes:getPositionForTime( newTime, dateRecorded ) -- See if time is an improvement for this player if not oldTime or newTime < oldTime then local oldPos = self.mapTimes:getIndexForPlayer( player ) triggerEvent("onPlayerToptimeImprovement", player, newPos, newTime, oldPos, oldTime, self.displayTopCount, self.mapTimes:getValidEntryCount() ) -- See if its in the top display if newPos <= self.displayTopCount then outputChatBox( '#FF0000[TopTime]: #FFFFFF' .. getPlayerName(player) .. ' #00FF37got toptime position ' .. newPos .. ' time: ' .. SMaptimes:timeMsToTimeText(newTime), root, 2, 255, 2, true) end if oldTime then outputChatBox( 'TOPTIMES: '.. getPlayerName(player) .. ' new personal best ' .. SMaptimes:timeMsToTimeText(newTime) .. ' ' .. oldTime - newTime, root ) end self.mapTimes:setTimeForPlayer( player, newTime, dateRecorded ) -- updateTopText if database was changed if newPos <= self.displayTopCount then self:updateTopText() end end outputDebug( 'TOPTIMES', '++ SToptimesManager:playerFinished ' .. tostring(getPlayerName(player)) .. ' time:' .. tostring(newTime) ) end Works, tested. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
MrXz Posted January 27, 2012 Author Posted January 27, 2012 Thanks .. thank you very much .. I appreciate your work .. Thanks again and good luck ^^! Keep it up ^^!
Castillo Posted January 27, 2012 Posted January 27, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Admigo Posted February 6, 2012 Posted February 6, 2012 I used this code to on my script but when i get a personal record i get a error:bad argument@output chatbox and in game it says:TOPTIMES: END#Admigo new personal best 01:01:544 26255. How can i fix this?
MrXz Posted February 6, 2012 Author Posted February 6, 2012 Use this Script function SToptimesManager:playerFinished( player, newTime, dateRecorded ) -- Check if top time recording is disabled for this player if getElementData ( player, "toptimes" ) == "off" then return end if not self.mapTimes then outputDebug( 'TOPTIMES', 'SToptimesManager:playerFinished - self.mapTimes == nil' ) return end dateRecorded = dateRecorded or getRealDateTimeNowString() local oldTime = self.mapTimes:getTimeForPlayer( player ) -- Can be false if no previous time local newPos = self.mapTimes:getPositionForTime( newTime, dateRecorded ) -- See if time is an improvement for this player if not oldTime or newTime < oldTime then local oldPos = self.mapTimes:getIndexForPlayer( player ) triggerEvent("onPlayerToptimeImprovement", player, newPos, newTime, oldPos, oldTime, self.displayTopCount, self.mapTimes:getValidEntryCount() ) -- See if its in the top display if newPos <= self.displayTopCount then outputChatBox( '*#DE00FF*[TOPTIME]: #FFFFFF' .. getPlayerName(source) .. ' #FF9305got toptime position #FFFFFF' .. newPos .. ' #FF0000[Time: ' .. SMaptimes:timeMsToTimeText(newTime) .. ']', root, 2, 255, 2, true) end if oldTime then outputDebug( '#DE00FF*[TOPTIME]: #FFFFFF' .. getPlayerName(source) .. ' #FF9305got toptime position #FFFFFF' .. newPos .. ' #FF0000[Time: ' .. SMaptimes:timeMsToTimeText(newTime) .. ']', root, 2, 255, 2, true) end self.mapTimes:setTimeForPlayer( player, newTime, dateRecorded ) -- updateTopText if database was changed if newPos <= self.displayTopCount then self:updateTopText() end end outputDebug( 'TOPTIMES', '++ SToptimesManager:playerFinished ' .. tostring(getPlayerName(player)) .. ' time:' .. tostring(newTime) ) end
meh Posted May 1, 2012 Posted May 1, 2012 i apologize for bumping, but how to make this work? i need to rename race_top times to toptimes or what? please help.
Michael# Posted May 1, 2012 Posted May 1, 2012 Just edit function STopTimesManager:playerFinished and put this. Just don't ask me where is the function because I don't know, I don't use this shit
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