- 244
- 96
- Версия MoonLoader
- .026-beta
Lua:
require "lib.sampfuncs"
require "lib.moonloader"
function main()
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand('getplayers', getPlayers)
while true do
wait(0)
end
end
function getPlayers()
local maxPlayers = sampGetMaxPlayers()
for i = 0, maxPlayers do
if sampIsPlayerConnected(i) then
local name = sampGetPlayerNickname(i)
writeToFile("mydata.txt", "Player "..i..": "..name)
end
end
end
function writeToFile(filename, data)
local file = io.open(filename, "a")
if file then
file:write(data.."\n")
file:close()
sampAddChatMessage("Data has been written to file "..filename, -1)
else
sampAddChatMessage("Failed to open file "..filename, -1)
end
end
\getPLayesr.lua:15: attempt to call global 'sampGetMaxPlayers' (a nil value) stack traceback:`