require 'lib.sampfuncs'
require 'lib.moonloader'
arr_nick = {}
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(1000) end
local dlstatus = require('moonloader').download_status
local json = getWorkingDirectory() .. '\\database.json'
if doesFileExist(json) then os.remove(json) end
downloadUrlToFile("https://raw.githubusercontent.com/AlannButler/database_names_surnames/main/n_s", json,
function(id, status, p1, p2)
if status == dlstatus.STATUSEX_ENDDOWNLOAD then
if doesFileExist(json) then
local f = io.open(json, 'r')
if f then
arr_nick = decodeJson(f:read('*a'))
f:close()
end
end
end
end)
sampRegisterChatCommand("rand_nick", rand_nick)
end
function random(min, max)
kf = math.random(min, max)
math.randomseed(os.time() * kf)
rand = math.random(min, max)
return tonumber(rand)
end
function rand_nick()
name = arr_nick[random(1, 5162)]
surname = arr_nick[random(5163, 81533)]
sampAddChatMessage(string.format("Ник: %s_%s", name, surname), -1)
end