Advertisement
imring

packScripts [ SA:MP ]

Dec 18th, 2017
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.11 KB | None | 0 0
  1. script_name('packScripts')
  2. script_author('imring')
  3. script_version('1.00')
  4.  
  5. timestamp = true
  6. textdraw = false
  7.  
  8. colorText = 0xCCFF00
  9. colorTextString = '{'..string.format('%x', colorText)..'}'
  10.  
  11. function main()
  12.  
  13.     while not isSampAvailable() do wait(0) end
  14.  
  15.     font1 = renderCreateFont('Verdana', 8, 13)
  16.     resX, resY = getScreenResolution()
  17.  
  18.     while update ~= false do wait(100) end
  19.  
  20.     sampRegisterChatCommand('tstamp', timeStamp)
  21.     sampRegisterChatCommand('rtd', renderTextDraw)
  22.     sampRegisterChatCommand('id', idPlayer)
  23.  
  24.     sampAddChatMessage('Скрипт '..thisScript().name..' загружён. Версия: '..thisScript().version..'.', colorText)
  25.  
  26.     while true do wait(0)
  27.  
  28.         if not sampIsScoreboardOpen() then
  29.  
  30.             if timestamp then
  31.                 local cordY = resY/30+200
  32.                 local cordX = resX-250
  33.                 local month = getMonth(tonumber(os.date('%m', os.time())))
  34.                 local time = os.date('%d '..month..' %Y %X', os.time())
  35.                 renderFontDrawText(font1, time, cordX, cordY, -1)
  36.             end
  37.  
  38.             if textdraw then
  39.                 for textdrawid = 0, 3000 do
  40.                     if sampTextdrawIsExists(textdrawid) then
  41.                         local X, Y = sampTextdrawGetPos(textdrawid)
  42.                         local posX, posY = convertGameScreenCoordsToWindowScreenCoords(X, Y)
  43.                         renderFontDrawText(font1, textdrawid, posX, posY, 0xFF00FF00)
  44.                     end
  45.                 end
  46.             end
  47.            
  48.         end
  49.  
  50.         if isKeyJustPressed(84) and not sampIsChatInputActive() and not sampIsDialogActive() then
  51.             sampSetChatInputEnabled(true)
  52.         end
  53.  
  54.     end
  55. end
  56.  
  57. function timeStamp() timestamp = not timestamp end
  58.  
  59. function renderTextDraw() textdraw = not textdraw end
  60.  
  61. function idPlayer(text)
  62.     local stringtext = string.match(text, '%q*(.+)')
  63.     if stringtext ~= nil then
  64.         local idplayer = tonumber(stringtext)
  65.         if idplayer == nil then
  66.             for i = 0, 1000 do
  67.                 local _, myid = sampGetPlayerIdByCharHandle(playerPed)
  68.                 if sampIsPlayerConnected(i) or i == myid then
  69.                     local nick = sampGetPlayerNickname(i)
  70.                     if string.find(string.lower(nick), string.lower(stringtext)) then
  71.                         local ping = sampGetPlayerPing(i)
  72.                         local color = string.sub(string.format('%x', sampGetPlayerColor(i)), 3)
  73.                         sampAddChatMessage('Nick: {'..color..'}'..nick..' {FFFFFF}| ID: '..i..' | Ping: '..ping, -1)
  74.                     end
  75.                 end
  76.             end
  77.         else
  78.             for i = 0, 1000 do
  79.                 local _, myid = sampGetPlayerIdByCharHandle(playerPed)
  80.                 if idplayer == i then
  81.                     if sampIsPlayerConnected(i) or i == myid then
  82.                         local nick = sampGetPlayerNickname(i)
  83.                         local ping = sampGetPlayerPing(i)
  84.                         local color = string.sub(string.format('%x', sampGetPlayerColor(i)), 3)
  85.                         sampAddChatMessage('Nick: {'..color..'}'..nick..' {FFFFFF}| ID: '..i..' | Ping: '..ping, -1)
  86.                     end
  87.                 end
  88.             end
  89.         end
  90.     else sampAddChatMessage('Use: [ /id [ID/NICK] ]', -1) end
  91. end
  92.  
  93. function getMonth(month)
  94.     local months = {
  95.         [1] = 'Января',
  96.         [2] = 'Февраля',
  97.         [3] = 'Марта',
  98.         [4] = 'Апреля',
  99.         [5] = 'Мая',
  100.         [6] = 'Июня',
  101.         [7] = 'Июля',
  102.         [8] = 'Августа',
  103.         [9] = 'Сентября',
  104.         [10] = 'Октября',
  105.         [11] = 'Ноября',
  106.         [12] = 'Декабря'
  107.     }
  108.     return months[month]
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement