can you try this
local pedVoices = {}
local pedIds = {}
local updateTimer
local currentSkinIndex = 0
function configureTable()
local skinids = getValidPedModels()
for i=1,#skinids do
pedIds[skinids[i]] = true
end
end
function writeTableDataToFile()
local voiceFile = fileCreate("voices.csv") -- file located mods/deathmatch/resources folder
fileWrite(voiceFile, "PEDMODEL, VOICETYPE, VOICENAME;\n")
for _,v in pairs(pedVoices) do
local formattedData = string.format("%s %s %s;\n", v.model_id, v.voice_type, v.voice_name)
fileWrite(voiceFile, formattedData)
end
fileClose(voiceFile)
pedVoices = {}
pedIds = {}
currentSkinIndex = nil
end
function setPlayerSkinAndAssignTable()
if pedIds[currentSkinIndex] then
setElementModel(localPlayer, currentSkinIndex)
local voiceType, voiceName = getPedVoice(localPlayer)
if voiceType and voiceName then
data = {model_id=currentSkinIndex, voice_type=voiceType, voice_name=voiceName}
table.insert(pedVoices, data)
print(data.model_id, data.voice_type, data.voice_name)
else
data = {model_id=currentSkinIndex, voice_type="none", voice_name="none"}
table.insert(pedVoices, data)
print(data.model_id, data.voice_type, data.voice_name)
end
end
if currentSkinIndex == 312 then
if isTimer(updateTimer) then
killTimer(updateTimer)
updateTimer = nil
end
print("saving finished now writing file...")
writeTableDataToFile()
return
end
currentSkinIndex = currentSkinIndex + 1
end
addCommandHandler("gv",
function()
if isTimer(updateTimer) then
killTimer(updateTimer)
updateTimer = nil
end
configureTable()
updateTimer = setTimer(setPlayerSkinAndAssignTable, 1000, 0)
end)