mods = { --name, replaces, modelid, dff, txd, useDFF, false
{"NEW TAB"}, --Start weapons tab
{"Silenced Uzi", "Uzi", 352, "90A6AF4ACAFF4A7DE3E0219B677B1BD1", "15F561879BFEB75696264ADB367E61E9", true, false},
{"Dildo Bat", "Baseball bat", 336, "B6FE64C0E02A2A9A08DDAB03F6024851", "8046CE2F58FDDF4D20414739416F0C69", true, false},
{"iPhone 4", "Phone", 330, "9ADA8235B33A3F5FD85144FEC35BF8A1", "23699B9AA4E37D5B5E1DBAF10FC9F484", true, false},
{"H&K MSG-90", "Sniper", 358, "98561815E2B1963C68643182B827A823", "7EF9D7783F8BED9E02B84AC1417588D6", true, false},
{"Tazer", "Silenced", 347, "BFA095A972F593E32BB0EA31A68D3D31", "D5DCFAA6C2CACE8055D5C5646A982FA8", true, false},
{"AA-12", "Combat SG", 351, "02BE0D07BAE499270203E68C95374D20", "17FC6C25D2F13AF6E79F6702A80940F5", true, false},
{"AK47", "AK47", 355, "99C2EB1656BFFDB826C76DE97D97CD3A", "8BDA22238EF6B076369A1224A60D40B8", true, false},
{"Heckler & Koch HK416", "M4", 356, "640501D7F1A3789B0F922ED1ECD8766A", "2072DEFB86A8CDE2BDE6BA7866216D70", true, false},
{"Heckler & Koch MP5", "MP5", 353, "986A60E8B1DCA05E34C5CF086F386812", "3EE2A44DC2D4F7309B9E6CA4E568B8D5", true, false},
{"Revolver", "Desert Eagle", 348, "958E52BFA4689E7D0B5E0C4A0998F42E", "9C14622630949D0E5A79A2014FC2BC3F", true, false},
{"Chrome Shotgun", "Shotgun", 349, "C1BAC25937DAD5AB1DAA870816B2DB6B", "4C1C7684C3A9395CFF82FE6AD80CA0CA", true, false},
{"Detonator", "Detonator", 364, "8040F5824AE0EC3219E057FF59339464", "5BD566FB6F84CE84DD0FDEE2175DCA97", true, false},
{"Satchel", "Satchel", 363, "2B637D2CBBB95E872C5ADBD5EAA580CA", "3D6D5DB3F8244729D3545015C43FC013", true, false},
{"NEW TAB"}, --Start vehicles tab
{"Triumph Speed Triple", "FCR-900", 521, "DB53437D69FED61FA9177C86E756C4FF", "949728BB6EB0B4D2976EC4A9F802F7CC", true, false},
{"Yamaha DT 180", "Sanchez", 468, "DC64857BC87A051DDB76F87FA069E335", "59F3DD3174BB9C627F13374EA3EF9350", true, false},
{"Mountain Bike", "M Bike", 510, "549FBE0E8979DD5888DEEF9FEAC1BA24", "3FEE3CD4922317DB9D8F113390A2242F", true, false},
{"NEW TAB"}, --Start skins tab
{"Helvete 1", "skin 259", 259, "0", "0", false, false},
{"Helvete 2", "skin 122", 122, "0", "0", false, false},
{"Helvete 3", "skin 35" , 35 , "0", "0", false, false},
{"NEW TAB"}, --Start misc tab
{"Hotel & Skyscraper", "Rodeo TXDs", 6397, "0", "027C8BA9A2146AA396B7073AC4BC064A", false, false},
{"Hotel 2", "Hotel txd", 6388, "0", "D4E5B74FECFC738E2D1E0EFC56259AB0", false, false},
{"UFO House", "UFO House", 13725, "0", "C6CDE8197107EF759D5D319624FD51AD", false, false},
}
addEventHandler("onClientResourceStart", resourceRoot, --On startup
function()
for id,b in ipairs(mods) do --Loop all our possible mods
if b[1] ~= "NEW TAB" then
local txd = fileExists(b[3] ..".txd")
local dff = fileExists(b[3] ..".dff")
if txd or dff then --If we have any of the files then
if txd then
loadModel(id) --If we have both load it
else
startDownload(id) --If we only have one of the files, download the other
end
end
end
end
end)
function loadModel(id)
local gotDFF = false
local gotTXD = false
local useDFF = mods[id][6]
if fileExists(mods[id][3] ..".txd") then
local fh = fileOpen(mods[id][3] ..".txd", true)
if md5(fileRead(fh, fileGetSize(fh))) == mods[id][5] then
gotTXD = true
else
startDownload(id)
return
end
fileClose(fh)
end
if fileExists(mods[id][3] ..".dff") then
local fh = fileOpen(mods[id][3] ..".dff", true)
if md5(fileRead(fh, fileGetSize(fh))) == mods[id][4] then
gotDFF = true
else
startDownload(id)
return
end
fileClose(fh)
end
if (gotDFF or not useDFF) and gotTXD then
local txd = engineLoadTXD ( mods[id][3] ..".txd" )
engineImportTXD ( txd, mods[id][3] )
if useDFF then
local dff = engineLoadDFF ( mods[id][3] ..".dff", mods[id][3] )
engineReplaceModel ( dff, mods[id][3] )
end
--outputDebugString("Loaded '".. mods[id][1] .."'")
mods[id][7] = true
end
end
function startDownload(id)
local gotDFF = false
local gotTXD = false
if fileExists(mods[id][3] ..".txd") then
local fh = fileOpen(mods[id][3] ..".txd", true)
if md5(fileRead(fh, fileGetSize(fh))) == mods[id][5] then
gotTXD = true
--outputDebugString("TXD for mod '".. mods[id][1] .."' is already succesfully downloaded")
end
fileClose(fh)
end
if fileExists(mods[id][3] ..".dff") then
local fh = fileOpen(mods[id][3] ..".dff", true)
if md5(fileRead(fh, fileGetSize(fh))) == mods[id][4] then
gotDFF = true
--outputDebugString("DFF for mod '".. mods[id][1] .."' is already succesfully downloaded")
end
fileClose(fh)
end
if not gotDFF or not gotTXD then
triggerServerEvent("requestModDownload", localPlayer, id, mods[id][3], mods[id][1])
end
end
--addCommandHandler("downloadbike", function() startDownload(1) end)
function deleteMod(id)
if mods[id] then
if fileExists(mods[id][3] ..".txd") then
fileDelete(mods[id][3] ..".txd")
end
if fileExists(mods[id][3] ..".dff") then
fileDelete(mods[id][3] ..".dff")
end
engineRestoreModel(mods[id][3])
mods[id][7] = false
exports.commands:sendClientMessage("'".. mods[id][1] .."' deleted.", 0, 255, 0)
return true
end
end
addEvent("receiveModDownload", true)
addEventHandler("receiveModDownload", localPlayer,
function(data, id, modelID, name)
if data and id and mods[id] then
local fileName = modelID ..".txd"
local fh = fileCreate(fileName)
local bw = fileWrite(fh, data[1])
fileClose(fh)
if data[2] ~= "NO" then
local fileName = modelID ..".dff"
local fh = fileCreate(fileName)
local bw = fileWrite(fh, data[2]) + bw
fileClose(fh)
end
exports.commands:sendClientMessage("Download of '".. name .."' completed.", 0, 255, 0)
outputDebugString(bw .." bytes successfully written to disk")
loadModel(id)
end
end)