maku_kenesu19

Never Miss Sign Check

Oct 27th, 2025 (edited)
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.75 KB | Gaming | 0 0
  1. script_name("SignCheck Reminder")
  2. script_author("Maku Kenesu")
  3. script_version("1.0")
  4.  
  5. require "lib.moonloader"
  6. require "lib.sampfuncs"
  7. local sampev = require "lib.samp.events"
  8. local inicfg = require "inicfg"
  9.  
  10. local CONFIG_DIR = getWorkingDirectory() .. "\\config\\"
  11. local CONFIG_FILE = CONFIG_DIR .. "SignCheckReminder.ini"
  12.  
  13. local settings = inicfg.load({
  14.   settings = {
  15.     posX = 0.02,
  16.     posY = 0.5,
  17.     sound = true
  18.   }
  19. }, CONFIG_FILE)
  20.  
  21. local FONT = renderCreateFont("Arial", 13, 5)
  22. local SCREEN_X, SCREEN_Y = getScreenResolution()
  23. local COLOR_WHITE = 0xFFFFFFFF
  24. local COLOR_GREEN = 0xFF00FF00
  25. local COLOR_RED = 0xFFFF0000
  26. local COLOR_LABEL = 0xFFADFF2F
  27. local COLOR_BG = 0x80000000
  28. local PADDING_X, PADDING_Y = 10, 6
  29. local LABEL = "[SignCheck Reminder] "
  30. local AUTHOR = "by Maku Kenesu"
  31.  
  32. local isTextVisible = true
  33. local isSignActive = false
  34. local isRedAlert = false
  35. local isPaycheckReceived = false
  36. local isPaycheckExpired = false
  37. local isEditing = false
  38. local signEndTime, redEndTime, payEndTime, expireEndTime, nextSoundTime = 0, 0, 0, 0, 0
  39. local blinkTimer, blinkState = 0, true -- for blinking /SIGNCHECK
  40.  
  41. local function getPixelPosition()
  42.   return settings.settings.posX * SCREEN_X, settings.settings.posY * SCREEN_Y
  43. end
  44.  
  45. local function saveSettings()
  46.   inicfg.save(settings, CONFIG_FILE)
  47. end
  48.  
  49. local function sendChat(msg, color)
  50.   sampAddChatMessage(string.format("{%06X}%s{FFFFFF}%s", bit.band(COLOR_LABEL, 0xFFFFFF), LABEL, msg), -1)
  51. end
  52.  
  53. local function startSignTimer()
  54.   isSignActive = true
  55.   isRedAlert = false
  56.   isPaycheckReceived = false
  57.   isPaycheckExpired = false
  58.   signEndTime = os.clock() + 300
  59.   nextSoundTime = os.clock() + 30
  60.   blinkTimer = os.clock() + 1
  61.   blinkState = true
  62. end
  63.  
  64. local function stopSignTimer()
  65.   isSignActive = false
  66. end
  67.  
  68. local function startRedAlert()
  69.   isRedAlert = true
  70.   isSignActive = false
  71.   isPaycheckReceived = false
  72.   isPaycheckExpired = false
  73.   redEndTime = os.clock() + 60
  74. end
  75.  
  76. local function startPaycheckReceived()
  77.   isPaycheckReceived = true
  78.   isSignActive = false
  79.   isRedAlert = false
  80.   isPaycheckExpired = false
  81.   payEndTime = os.clock() + 60
  82. end
  83.  
  84. local function startPaycheckExpired()
  85.   isPaycheckExpired = true
  86.   isSignActive = false
  87.   isRedAlert = false
  88.   isPaycheckReceived = false
  89.   expireEndTime = os.clock() + 60
  90. end
  91.  
  92. local function drawSignText(text, x, y, color)
  93.   local width = renderGetFontDrawTextLength(FONT, text)
  94.   local height = 20
  95.   local boxWidth = width + (PADDING_X * 2)
  96.   local boxHeight = height + (PADDING_Y * 2)
  97.   renderDrawBox(x, y, boxWidth, boxHeight, COLOR_BG)
  98.   renderFontDrawText(FONT, text, x + PADDING_X, y + PADDING_Y, color)
  99. end
  100.  
  101. local function togglePositionEdit()
  102.   isEditing = not isEditing
  103.   showCursor(isEditing)
  104.   if isEditing then
  105.     sendChat("Move mode enabled. Click top-left corner to set new position.", COLOR_LABEL)
  106.   else
  107.     sendChat("Move mode disabled.", COLOR_LABEL)
  108.   end
  109. end
  110.  
  111. local function handlePositionEdit()
  112.   if wasKeyPressed(VK_LBUTTON) then
  113.     local mouseX, mouseY = getCursorPos()
  114.     settings.settings.posX = mouseX / SCREEN_X
  115.     settings.settings.posY = mouseY / SCREEN_Y
  116.     saveSettings()
  117.     sendChat(string.format("New position saved (%.2f, %.2f).", settings.settings.posX, settings.settings.posY), COLOR_LABEL)
  118.     togglePositionEdit()
  119.   end
  120. end
  121.  
  122. local function toggleSound()
  123.   settings.settings.sound = not settings.settings.sound
  124.   saveSettings()
  125.   local state = settings.settings.sound and "enabled" or "disabled"
  126.   sendChat("Sound alerts " .. state .. ".", COLOR_LABEL)
  127. end
  128.  
  129. local function showHelp()
  130.   sendChat("Available commands:", COLOR_LABEL)
  131.   sampAddChatMessage("/sr.pos - Move the reminder text.", -1)
  132.   sampAddChatMessage("/sr.sound - Toggle sound alerts.", -1)
  133.   sampAddChatMessage("/sr.help - Show this help message.", -1)
  134. end
  135.  
  136. function sampev.onServerMessage(_, text)
  137.   if text:find("Sign the check to receive your paycheck.", 1, true) then
  138.     startSignTimer()
  139.     if settings.settings.sound then
  140.       lua_thread.create(function()
  141.         addOneOffSound(0.0, 0.0, 0.0, 1097)
  142.         wait(3500)
  143.         addOneOffSound(0.0, 0.0, 0.0, 1098)
  144.       end)
  145.     end
  146.  
  147.   elseif text:find("________ BANK STATEMENT ________", 1, true) then
  148.     if settings.settings.sound then addOneOffSound(0.0, 0.0, 0.0, 1133) end
  149.     stopSignTimer()
  150.     startPaycheckReceived()
  151.  
  152.   elseif text:find("* You haven't played long enough to obtain a paycheck.", 1, true) then
  153.     if settings.settings.sound then addOneOffSound(0.0, 0.0, 0.0, 1056) end
  154.     startRedAlert()
  155.  
  156.   elseif text:find("Your paycheck code expired. Please remember to /signcheck next time.", 1, true) then
  157.     if settings.settings.sound then addOneOffSound(0.0, 0.0, 0.0, 1056) end
  158.     startPaycheckExpired()
  159.  
  160.   elseif text:find("You have one minute left before your paycheck code expires. Please type /signcheck to get your paycheck.", 1, true) then
  161.     if settings.settings.sound then
  162.       lua_thread.create(function()
  163.         addOneOffSound(0.0, 0.0, 0.0, 1068)
  164.         wait(3500)
  165.         addOneOffSound(0.0, 0.0, 0.0, 1069)
  166.       end)
  167.     end
  168.   end
  169. end
  170.  
  171. function main()
  172.   while not isSampAvailable() do wait(100) end
  173.   sampAddChatMessage(string.format("{%06X}%s%s {FFFFFF}- Use /sr.help for commands.", bit.band(COLOR_LABEL, 0xFFFFFF), LABEL, AUTHOR), -1)
  174.   sampRegisterChatCommand("sr.pos", togglePositionEdit)
  175.   sampRegisterChatCommand("sr.sound", toggleSound)
  176.   sampRegisterChatCommand("sr.help", showHelp)
  177.  
  178.   while true do
  179.     wait(0)
  180.     local now = os.clock()
  181.  
  182.     if isRedAlert and now > redEndTime then isRedAlert = false end
  183.     if isSignActive and now > signEndTime then stopSignTimer() end
  184.     if isPaycheckReceived and now > payEndTime then isPaycheckReceived = false end
  185.     if isPaycheckExpired and now > expireEndTime then isPaycheckExpired = false end
  186.  
  187.     -- Blink logic
  188.     if isSignActive and now >= blinkTimer then
  189.       blinkState = not blinkState
  190.       blinkTimer = now + 1
  191.     end
  192.  
  193.     if isSignActive and now >= nextSoundTime then
  194.       if settings.settings.sound then addOneOffSound(0.0, 0.0, 0.0, 1057) end
  195.       nextSoundTime = now + 60
  196.     end
  197.  
  198.     if isTextVisible then
  199.       local posX, posY = getPixelPosition()
  200.       local color, text = COLOR_WHITE, "No Check to Sign"
  201.  
  202.       if isSignActive then
  203.         color = blinkState and COLOR_GREEN or COLOR_WHITE
  204.         text = "/SIGNCHECK"
  205.       elseif isRedAlert then
  206.         color, text = COLOR_RED, "Missed Paycheck"
  207.       elseif isPaycheckReceived then
  208.         color, text = COLOR_GREEN, "Paycheck Received"
  209.       elseif isPaycheckExpired then
  210.         color, text = COLOR_RED, "Paycheck Expired"
  211.       end
  212.  
  213.       drawSignText(text, posX, posY, color)
  214.     end
  215.  
  216.     if isEditing then handlePositionEdit() end
  217.   end
  218. end
  219.  
Advertisement
Add Comment
Please, Sign In to add comment