Annas Posted May 19, 2016 Share Posted May 19, 2016 Hello, all what i want is loading a skin shader without download.. So i tried to create this resource -- Server Side function downloadPlayerAlternateSkin(plr, cmd, filename) theskinId = filename if (filename) then fetchRemote("http://localhost/shadersqsdqs/"..filename..".jpg", checkPlayerAlternateSkin) end end addCommandHandler("loadshader", downloadPlayerAlternateSkin) function checkPlayerAlternateSkin(responseData, errno) if (errno == 0) then GottheSkin = responseData end end function setPlayerAlternateSkin(player, theid, thepng) theid = theskinId thepng = GottheSkin textureName = "*" if (not GottheSkin) then outputChatBox("Something goes wrong, please contact an admin.", player, 255, 0, 0) return end triggerClientEvent(root, "CSTshaders.applyShader", root, player, {theid, textureName, thepng}, "skin" ) end What i want?: - Add jpg file (Example: 5.jpg) on (http://localhost/shadersqsdqs) folder - Go ingame and type "./loadshader 5" to download the JPG file (it should goes to MTA->mods->Deathmatch->priv->[iD or Key]->ResourceName) The problem is: It didn't want to be downloaded, well i don't know if Fetch Remote able to download PNG/JPG files or no.. Help me please Link to comment
Addlibs Posted May 20, 2016 Share Posted May 20, 2016 If fetchRemote is on the serverside, then nothing should be downloaded/saved under ../priv/ as far as I'm concerned. (And I don't think anything get's downloaded/saved even if used through clientside) It's probably your clientside code, upon receiving the pixel code (from PNG/JPEG) that saves it to "@.png" or whatever (as long as there is the prefix "@" which means it'll be in the priv folder) Link to comment
Anubhav Posted May 20, 2016 Share Posted May 20, 2016 fetchRemote is not for downloading files. Use downloadFile instead. fetchRemote is used for POST and GET requests. After seeing the examples, reliazed that you can do that. You can use the example. You can create a texture using it client side and draw it then.. or apply it. Link to comment
Annas Posted May 20, 2016 Author Share Posted May 20, 2016 If fetchRemote is on the serverside, then nothing should be downloaded/saved under ../priv/ as far as I'm concerned. (And I don't think anything get's downloaded/saved even if used through clientside) It's probably your clientside code, upon receiving the pixel code (from PNG/JPEG) that saves it to "@.png" or whatever (as long as there is the prefix "@" which means it'll be in the priv folder) i didn't understand you .. , how to save the PNG/JPEG ? , where should i put the '@', can you make an example using my code?, and thanks Link to comment
Anubhav Posted May 21, 2016 Share Posted May 21, 2016 If fetchRemote is on the serverside, then nothing should be downloaded/saved under ../priv/ as far as I'm concerned. (And I don't think anything get's downloaded/saved even if used through clientside) It's probably your clientside code, upon receiving the pixel code (from PNG/JPEG) that saves it to "@.png" or whatever (as long as there is the prefix "@" which means it'll be in the priv folder) i didn't understand you .. , how to save the PNG/JPEG ? , where should i put the '@', can you make an example using my code?, and thanks You probably can't do that. But you can make a texture and load it as shader as I told. See the example. Link to comment
Saml1er Posted May 21, 2016 Share Posted May 21, 2016 The data variable in callback function can be sent to client side using triggerClientEvent and then save it using: local f = fileCreate (":myResourceName/fileName") fileWrite ( f, data) fileClose ( f ) f = nil Link to comment
Annas Posted May 21, 2016 Author Share Posted May 21, 2016 The data variable in callback function can be sent to client side using triggerClientEvent and then save it using: local f = fileCreate (":myResourceName/fileName") fileWrite ( f, data) fileClose ( f ) f = nil Done thanks. Im using this: function downloadsCSTShaders (data, theskinId) local f = fileCreate ("@/jpg2/"..theskinId.."") fileWrite ( f, data) fileClose ( f ) f = nil end addEventHandler("CSTskins.downloadTheShaderOnSkins", root, downloadsCSTShaders) File created and everything is okey .. But, there is an issuse.. , the Texture cannot be created .. i used this .. but it's not working.. local textureElement = dxCreateTexture ( "@/jpg2/"..thepng.."" ); Bad file path @ 'dxCreateTexture' [@/jpg2/ Link to comment
Saml1er Posted May 21, 2016 Share Posted May 21, 2016 thepng variable is an empty string, make sure it has the file name. Link to comment
Annas Posted May 22, 2016 Author Share Posted May 22, 2016 Hey, It's working perfect, Now i need to make it, select (filename) from MySQL.. but it's not working Notice: function downloadPlayerAlternatexx() local filename = exports.CSTmysql:query("SELECT * shaderid FROM skinsShaders") if (filename) then fetchRemote("http://localhost/shadersqsdqs/"..filename..".jpg", checkPlayerAlternateSkin) end end addCommandHandler("additsx", downloadPlayerAlternatexx) The problem is: It Didn't select (shaderid) .. Maybe my code have issuse, please help me.. Link to comment
Saml1er Posted May 23, 2016 Share Posted May 23, 2016 Hey, It's working perfect, Now i need to make it, select (filename) from MySQL.. but it's not workingNotice: function downloadPlayerAlternatexx() local filename = exports.CSTmysql:query("SELECT * shaderid FROM skinsShaders") if (filename) then fetchRemote("http://localhost/shadersqsdqs/"..filename..".jpg", checkPlayerAlternateSkin) end end addCommandHandler("additsx", downloadPlayerAlternatexx) The problem is: It Didn't select (shaderid) .. Maybe my code have issuse, please help me.. I believe the variable filename return a table so you have to do something like this: fetchRemote("http://localhost/shadersqsdqs/"..filename[1]["key"]..".jpg", checkPlayerAlternateSkin) Keep in mind that key is the column name so better change it. Link to comment
Anubhav Posted May 23, 2016 Share Posted May 23, 2016 The query itself has a problem. function downloadPlayerAlternatexx(p, _) local filename = exports.CSTmysql:query("SELECT * FROM skinsShaders") if (#filename > 0 ) then fetchRemote("http://localhost/shadersqsdqs/"..filename[1].shaderid..".jpg", checkPlayerAlternateSkin) end end addCommandHandler("additsx", downloadPlayerAlternatexx) Also you need to poll the result if you haven't. Link to comment
Annas Posted May 23, 2016 Author Share Posted May 23, 2016 It's working, but only for the first Line.. It downloads only the first line ( i need it to download all currently lines.. See screenshot: Wish you understand me Link to comment
Annas Posted May 23, 2016 Author Share Posted May 23, 2016 It's working, but only for the first Line.. It downloads only the first line ( i need it to download all currently lines.. See screenshot: Wish you understand me Anyone please 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