script_name('HideCars')
script_author('xSpiridon')
local sampev = require('samp.events')
local BitStreamIO = require('samp.events.bitstream_io')
local toggle = false
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(2000) end
sampRegisterChatCommand('hidecars', hideAllVehicles)
wait(-1)
end
function sampev.onVehicleStreamIn()
if toggle then
return false
end
end
function hideAllVehicles()
toggle = not toggle
if toggle then
sampAddChatMessage('[HideCars] {FFFFFF}Activated.', 0xFF3F33)
local vehicles = getAllVehicles()
for _, veh in pairs(vehicles) do
local exist, vehId = sampGetVehicleIdByCarHandle(veh)
if exist and veh ~= 1 and not isCharInCar(PLAYER_PED, veh) then
hideCar(vehId)
end
end
else
sampAddChatMessage('[HideCars] {FFFFFF}Deactivated.', 0xFF3F33)
end
end
function hideCar(id)
local bs_write = BitStreamIO.bs_write
local bs = raknetNewBitStream()
bs_write.int16(bs, id)
raknetEmulRpcReceiveBitStream(165, bs)
end