opnaiC Posted July 21, 2016 Share Posted July 21, 2016 local gWeekDays = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } function FormatDate(format, escaper, timestamp) Check("FormatDate", "string", format, "format", {"nil","string"}, escaper, "escaper", {"nil","string"}, timestamp, "timestamp") escaper = (escaper or "'"):sub(1, 1) local time = getRealTime(timestamp) local formattedDate = "" local escaped = false time.year = time.year + 1900 time.month = time.month + 1 local datetime = { d = ("%02d"):format(time.monthday), h = ("%02d"):format(time.hour), i = ("%02d"):format(time.minute), m = ("%02d"):format(time.month), s = ("%02d"):format(time.second), w = gWeekDays[time.weekday+1]:sub(1, 2), W = gWeekDays[time.weekday+1], y = tostring(time.year):sub(-2), Y = time.year } for char in format:gmatch(".") do if (char == escaper) then escaped = not escaped else formattedDate = formattedDate..(not escaped and datetime[char] or char) end end return formattedDate end function timeCommand (command) if command == 'time' then cancelEvent() outputChatBox (FormatDate("'m/d/Y h:m"), source, 255,140,0) end end addEventHandler ("onPlayerCommand", root, timeCommand) I want to change the mta /time command in my format. Link to comment
aka Blue Posted July 21, 2016 Share Posted July 21, 2016 Try this, lets see: function timeCommand (command) cancelEvent() if command == 'time' then outputChatBox (FormatDate("'m/d/Y h:m"), source, 255,140,0) end end addEventHandler ("onPlayerCommand", root, timeCommand) Link to comment
opnaiC Posted July 21, 2016 Author Share Posted July 21, 2016 Try this, lets see: function timeCommand (command) cancelEvent() if command == 'time' then outputChatBox (FormatDate("'m/d/Y h:m"), source, 255,140,0) end end addEventHandler ("onPlayerCommand", root, timeCommand) When cancelEvent() is in the first line nothing will work Link to comment
1LoL1 Posted July 21, 2016 Share Posted July 21, 2016 This will not work it's client-side command. Link to comment
aka Blue Posted July 25, 2016 Share Posted July 25, 2016 Try this, lets see: function timeCommand (command) cancelEvent() if command == 'time' then outputChatBox (FormatDate("'m/d/Y h:m"), source, 255,140,0) end end addEventHandler ("onPlayerCommand", root, timeCommand) When cancelEvent() is in the first line nothing will work Mabako's Paradise method: -- overwrite MTA's default chat events addEventHandler( "onPlayerChat", getRootElement( ), function( message, type ) cancelEvent( ) if exports.players:isLoggedIn( source ) and not isPedDead( source ) then if type == 0 then localizedMessage( source, " " .. getPlayerName( source ) .. " dice: ", message, 230, 230, 230, false, 127, 127, 127 ) elseif type == 1 then me( source, message ) elseif type == 2 then faction( source, exports.factions:getPlayerFactions( source )[ 1 ], message ) end end end ) 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