RealG4

fetchRemote Help

Recommended Posts

Help please

I need the other players to see the share that I put on my vehicle

----Client


GUIEditor = {
    label = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        Panel_imagen = guiCreateWindow(0.30, 0.29, 0.37, 0.28, "fetchRemote test", true)
        guiWindowSetSizable(Panel_imagen, false)
        guiSetVisible(Panel_imagen, false)
        guiSetAlpha(Panel_imagen, 1.00)

        GUIEditor.label[1] = guiCreateLabel(0.02, 0.11, 0.96, 0.38, "¡Test", true, Panel_imagen)
        guiSetFont(GUIEditor.label[1], "default-bold-small")
        guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", true)
        guiLabelSetVerticalAlign(GUIEditor.label[1], "center")
        url = guiCreateEdit(0.02, 0.53, 0.96, 0.17, "", true, Panel_imagen)
        secUrl = guiCreateButton(0.12, 0.75, 0.36, 0.18, "enter URL.", true, Panel_imagen)
        guiSetFont(secUrl, "default-bold-small")
        guiSetProperty(secUrl, "NormalTextColour", "FFAAAAAA")
        cerrarPanelURL = guiCreateButton(0.52, 0.75, 0.36, 0.18, "Clouse", true, Panel_imagen)
        guiSetFont(cerrarPanelURL, "default-bold-small")
        guiSetProperty(cerrarPanelURL, "NormalTextColour", "FFAAAAAA")    
    end
)


addCommandHandler("Panel",
function()

guiSetVisible(Panel_imagen, not guiGetVisible(Panel_imagen))
showCursor(not isCursorShowing())

end)

addEventHandler("onClientGUIClick", resourceRoot,
	function()
		if source == cerrarPanelURL then
			guiSetVisible(Panel_imagen, false)
			showCursor(false)
		elseif source == secUrl then
			texto = guiGetText(url)
			if texto ~= "" then
				if isPedInVehicle(localPlayer) then
					if texto:len() > 3 then
					--	if string.find(texto, "png") or string.find(texto, "jpg") then
							triggerServerEvent("change", localPlayer, texto)
							guiSetEnabled(secUrl, false)
							guiSetVisible(Panel_imagen, false)
							showCursor(false)
							outputChatBox("Loading image..", 100, 255, 0)
					--	else
							outputChatBox("The image should end at the end as PNG or JPG.", 255, 0, 0)
					--	end
					else
						outputChatBox("The url must have more than 3 characteristics ", 255, 0, 0)
					end
				else
					outputChatBox("You must be in a vehicle to load the URL", 255, 0, 0)
				end
			else
				outputChatBox("You must put a URL to put it to your vehicle.", 255, 0, 0)
			end
		end
	end
	)

function invalido()
	guiSetEnabled(secUrl, true)
end
addEvent("Invalido", true)
addEventHandler("Invalido", root, invalido)

addEvent("onClientReLoadImage", true)
addEventHandler("onClientReLoadImage", root,
	function(image)
		shader_cars, tec = dxCreateShader ( "shader.fx" )
		myTexture = dxCreateTexture( image )
		 local theScriptC = fileCreate("test.png")
		  fileWrite(theScriptC, image)   
            fileClose(theScriptC)   
		engineRemoveShaderFromWorldTexture ( shader_cars, "vehiclegrunge256", getPedOccupiedVehicle(localPlayer) )
		engineApplyShaderToWorldTexture ( shader_cars, "vehiclegrunge256", getPedOccupiedVehicle(localPlayer) )
		dxSetShaderValue ( shader_cars, "TX0", myTexture ) 
		outputChatBox("remove texture /removetexture", 0, 255, 0)
		---outputChatBox("", 0, 255, 0)
		outputChatBox("You can only put it once in a single vehicle, unless you remove your texture to put it in another, if your vehicle disappears bad luck you will have to reconnect to put your paintjob ..", 255, 255, 255)
	end
)
function removetexta()
	if isPedInVehicle(localPlayer) then
		if myTexture then
			engineRemoveShaderFromWorldTexture ( shader_cars, "vehiclegrunge256", getPedOccupiedVehicle(localPlayer) )
			guiSetEnabled(secUrl, true)
			outputChatBox("It has been totally removed.", 255, 0, 0)
		end
	end
end
addCommandHandler("removetexture", removetexta)
---server
addEvent("change",true)
addEventHandler("change",root,function(url)
	fetchRemote(url,onPlayerDownloadImage,"",false,source)
end)

function onPlayerDownloadImage(image,err,pl)
	if isElement(pl) then
		if err == 0 then
			triggerClientEvent(pl,"onClientReLoadImage",root,image)
            local theScriptC = fileCreate(image)
		else
			outputChatBox("Invalid URL, please insert one that is.", source, 255, 0, 0)
			triggerClientEvent(source, "Invalido", source)
			triggerClientEvent(pl,"onClientReLoadImage",root,image)
		end
	end
end

 

Share this post


Link to post

All you have to do is send an event to all clients telling them which texture to use for the shader. See if you can figure out how to do that on your own.

Share this post


Link to post

C'mon, at least make an attempt yourself and show us the code with your attempted implementation. We're not here to do it for you. I told you what needs to be done, now you can figure out how to do it. You're not gonna learn otherwise. If you're unwilling to learn, perhaps you should hire (and pay) a scripter to do it for you.

Share this post


Link to post
4 hours ago, MrTasty said:

C'mon, at least make an attempt yourself and show us the code with your attempted implementation. We're not here to do it for you. I told you what needs to be done, now you can figure out how to do it. You're not gonna learn otherwise. If you're unwilling to learn, perhaps you should hire (and pay) a scripter to do it for you.

Friend but are you not seeing the code? I made the attempt and it doesn't come out, if I did this script through videos

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.