boro Posted October 26, 2014 Share Posted October 26, 2014 Hi i have idea for start downloading players mod when is player spawned is it possible ? Example function downloadOnSpawn ( ) engineImportTXD(engineLoadTXD("pcj600.txd"), 461) engineReplaceModel(engineLoadDFF("pcj600.dff", 0), 461) end addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), downloadOnSpawn ) Link to comment
Et-win Posted October 26, 2014 Share Posted October 26, 2014 viewtopic.php?f=91&t=78826 Link to comment
boro Posted October 26, 2014 Author Share Posted October 26, 2014 I try this but it dont work alpha mod dont are loaded local screenWidth,screenHeight = guiGetScreenSize() local downloadFiles = { { "mods/alpha.txd" }, { "mods/alpha.dff" }, } function downloadState() dxDrawText("Downloading... (0/2)",screenWidth,screenHeight,screenWidth,screenHeight,tocolor(255,255,255,255),1,"bankgothic") end addEventHandler("onClientRender",root,downloadState) for _, downFile in pairs( downloadFiles ) do downloadFile ( downFile[1] ) downloadState() end addEventHandler ( "onClientFileDownloadComplete", resourceRoot, function ( file, success ) if ( success ) then -- alpha if ( file == "mods/alpha.txd" and fileExists("mods/alpha.dff") ) or ( file == "mods/alpha.dff" and fileExists("mods/alpha.txd") ) then local txdalp = engineLoadTXD ( "mods/alpha.txd" ) local dffalp = engineLoadDFF ( "mods/alpha.dff", 602 ) engineImportTXD ( txdalp, 602 ) engineReplaceModel ( dffalp, 602 ) removeEventHandler("onClientRender",root,downloadState) end end end ) function checkIfPlayerAlreadyHasDownloaded() if ( fileExists("mods/alpha.dff") and fileExists("mods/alpha.txd")) then outputChatBox("Loading carmods...") local txdalp = engineLoadTXD ( "mods/alpha.txd" ) local dffalp = engineLoadDFF ( "mods/alpha.dff", 602 ) engineImportTXD ( txdalp, 602 ) engineReplaceModel ( dffalp, 602 ) else outputChatBox("client has no carmods, and has triggered the download!") for _, downFile in pairs( downloadFiles ) do downloadFile ( downFile[1] ) downloadState() end end end addEventHandler("onClientPlayerSpawn",root,checkIfPlayerAlreadyHasDownloaded) Link to comment
Et-win Posted October 26, 2014 Share Posted October 26, 2014 Read further... viewtopic.php?f=91&t=78826&start=30 Last script posted and read further for explanation. (If he didn't delete it, too long ago to remember ) Link to comment
boro Posted October 26, 2014 Author Share Posted October 26, 2014 Hm i check it but all still dont work for me and this script is good idea ? dont make it some lag on server ? function downloadOnSpawn ( ) engineImportTXD(engineLoadTXD("pcj600.txd"), 461) engineReplaceModel(engineLoadDFF("pcj600.dff", 0), 461) end addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), downloadOnSpawn ) I download mods only if is player spawn Link to comment
boro Posted October 26, 2014 Author Share Posted October 26, 2014 Ok i check your old posts And i have now this script but still dont work, in meta i have set download to false and old downloaded mod is deleted and still nothing what is bad now ? local screenWidth,screenHeight = guiGetScreenSize() local downloadFiles = { "mods/alpha.txd", "mods/alpha.dff" } function downloadState() dxDrawText("Downloading... (0/2)",screenWidth,screenHeight,screenWidth,screenHeight,tocolor(255,255,255,255),1,"bankgothic") end --[[ This is handled in onClientPlayerSpawn for _, downFile in pairs( downloadFiles ) do downloadFile ( downFile ) downloadState() end ]] addEventHandler ( "onClientFileDownloadComplete", root, function ( file, success ) if ( success and fileExists ( "mods/alpha.dff" ) and fileExists ( "mods/alpha.txd" ) ) then local txdalp = engineLoadTXD ( "mods/alpha.txd" ) local dffalp = engineLoadDFF ( "mods/alpha.dff", 602 ) engineImportTXD ( txdalp, 602 ) engineReplaceModel ( dffalp, 602 ) removeEventHandler("onClientRender",root,downloadState) end end ) function checkIfPlayerAlreadyHasDownloaded() if ( fileExists("mods/alpha.dff") and fileExists("mods/alpha.txd")) then outputChatBox("Loading carmods...") local txdalp = engineLoadTXD ( "mods/alpha.txd" ) local dffalp = engineLoadDFF ( "mods/alpha.dff", 602 ) engineImportTXD ( txdalp, 602 ) engineReplaceModel ( dffalp, 602 ) else outputChatBox("client has no carmods, and has triggered the download!") for _, downFile in pairs( downloadFiles ) do downloadFile ( downFile ) addEventHandler ( "onClientRender", root, downloadState ) end end end addEventHandler("onClientPlayerSpawn", localPlayer, checkIfPlayerAlreadyHasDownloaded ) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now