Help Auto Accept Vest LUA

designer

Member
Joined
Apr 3, 2023
Messages
14
Reaction score
0
Location
United States
Hey there! I am trying to make a auto accept vest but my code doesn’t seem to work. Here is my code, I’d appreciate it if you guys could help me.

require "lib.sampfuncs" function main() sampAddChatMessage("{FFFFFF}AutoAccept - {0085ff}[Credit: Y2K]", -1) local isModActive = true -- Script is active by default while true do wait(0) if isModActive then for i = 98, 99 do local text, prefix, color, prefixColor = sampGetChatString(i) if text:find("wants to protect you for $200, type /accept bodyguard to accept.") then -- If the message is found sampSendChat("/accept bodyguard") wait(1000) -- Waits for a second end end end end end function toggleMod() -- Function to toggle mod on/off isModActive = not isModActive -- Toggles the boolean value of isModActive if isModActive then sampAddChatMessage("~y~Auto AcceptVest: ~g~on", -1) -- Displays message when mod is activated else sampAddChatMessage("~y~Auto AcceptVest: ~r~off", -1) -- Displays message when mod is deactivated end end sampRegisterChatCommand("av", toggleMod) -- Registers "/av" command to toggle mod on/off
 

Tuzas

Active member
Joined
Nov 1, 2019
Messages
121
Reaction score
68
Location
null
JavaScript:
require "lib.sampfuncs"
local isModActive = true -- change to false if needed
local sampev = require 'lib.samp.events'


function main()
    sampAddChatMessage("{FFFFFF}AutoAccept  -  {0085ff}[Credit: Y2K]", -1)
    sampRegisterChatCommand("av", function()
    isModActive = not isModActive
    sampAddChatMessage(isModActive and "~y~Auto AcceptVest: ~g~on" or "~y~Auto AcceptVest: ~r~off" , -1)
   end)
    
    while true do
        wait(0)
        
    end
end

function sampev.onServerMessage(color, text)
if isModActive and  text:find('wants to protect you for $200, type /accept bodyguard to accept.') then
lua_thread.create(function()
     wait(1000)
     sampSendChat("/accept bodyguard")
 end)
 end
end
 
Top