-
Notifications
You must be signed in to change notification settings - Fork 0
/
s_modelsHandler.lua
35 lines (27 loc) · 1.43 KB
/
s_modelsHandler.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
addEvent("modelLoader:getModelFiles", true)
addEventHandler("modelLoader:getModelFiles", resourceRoot,
function(thePlayer, modelIndex)
if (thePlayer and modelIndex) then
if not(isElement(thePlayer) and getElementType(thePlayer) == "player") then return end
modelIndex = tonumber(modelIndex)
if (not modelIndex) or (not _MODELS[modelIndex])then return end
local txdFile = fileOpen("Models/" .. _MODELS[modelIndex].txdFileName, true)
local dffFile = fileOpen("Models/" .. _MODELS[modelIndex].dffFileName, true)
if not(txdFile and dffFile) then outputDebugString("couldn't load txd or dff file for " .. _MODELS[modelIndex].txdFileName .. " and " .. _MODELS[modelIndex].dffFileName, 1, 255, 0, 0) return end
local colFile
local col
if (_MODELS[modelIndex].colFileName) then
local col = fileOpen("Models/" .. _MODELS[modelIndex].colFileName, true)
colFile = fileRead(col, fileGetSize(col))
end
triggerClientEvent(thePlayer, "modelLoader:loadOneModel", resourceRoot, fileRead(txdFile, fileGetSize(txdFile)), fileRead(dffFile, fileGetSize(dffFile)), _MODELS[modelIndex].objectId, colFile)
fileClose(txdFile)
fileClose(dffFile)
if (col) then
fileClose(col)
end
else
outputDebugString("invalid arguments given for 'modelLoader:getModelFiles' Event (server-side)", 1, 255, 0, 0)
end
end
)