Jump to content

Paintjob + ElementData + ServertriggerEvent


Starztec

Recommended Posts

Good afternoon, my problem is that I do not know how to make the paintjob all see, from that, as I do so that when the user buys a specific object with a certain paintjob of the object, it is saved in a database ... Sorry for bad english

 

--Client Side

addEventHandler("onClientGUIClick", guiRoot, --VENTANA2 = CORTINAS > Completas > Turquesas
	function ()
local getGui = guiGetVisible(Ventana2)
		
if source == Boton9a then	
    triggerServerEvent("PonerCortina", localPlayer, localPlayer)
			PrecioCortinasCompletas = 3500
			PrecioTotal = PrecioCortinasCompletas
			guiSetText(BotonTOTAL2, PrecioCortinasCompletas)
	else 
	----------------------------------------------------------------------------
	----------------------------------------------------------------------------
if source == Boton10a then	--ROJAS
			triggerServerEvent("PonerCortina", localPlayer, localPlayer)
			PrecioCortinasCompletas = 3500
			PrecioTotal = PrecioCortinasCompletas
			guiSetText(BotonTOTAL2, PrecioCortinasCompletas)
			
			Cortinas = dxCreateTexture( "cortinas.png" )
			
					me = getLocalPlayer()
	if isPedInVehicle ( me ) then
		triggerServerEvent ( "addPJ", resourceRoot, Boton10a, me )
		Cortinas = dxCreateTexture( "cortinasRojas.png" )
												
engineRemoveShaderFromWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) )
shader_cars, tec = dxCreateShader ( "shader.fx" )
engineApplyShaderToWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) )
dxSetShaderValue ( shader_cars, "TX0", CortinasRojas ) 
	
												
 end end end end  ) 
addEvent( "addPJ2", true )
addEventHandler( "addPJ2", getLocalPlayer(), CortinasCompletas )
----------------------------------------------------------------------------
----------------------------------------------------------------------------
addEventHandler("onClientGUIClick", guiRoot, --VENTANA2 = CORTINAS > Completas > Azules
	function ()
local getGui = guiGetVisible(Ventana2)
		
if source == Boton11a then	--AZULES
			triggerServerEvent("PonerCortina", localPlayer, localPlayer)
			PrecioCortinasCompletas = 3500
			PrecioTotal = PrecioCortinasCompletas
			guiSetText(BotonTOTAL2, PrecioCortinasCompletas)
			
			Cortinas = dxCreateTexture( "cortinasAzules.png" )
			
					me = getLocalPlayer()
	if isPedInVehicle ( me ) then
		triggerServerEvent ( "addPJ", resourceRoot, Boton11a, me )
		Cortinas = dxCreateTexture( "cortinasAzules.png" )
												
engineRemoveShaderFromWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) )
shader_cars, tec = dxCreateShader ( "shader.fx" )
engineApplyShaderToWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) )
dxSetShaderValue ( shader_cars, "TX0", Cortinas )  
	
												
 end end end  ) 
addEvent( "addPJ2", true )
addEventHandler( "addPJ2", getLocalPlayer(), CortinasCompletas2 )

 

--Server Side

function Cortina1()
    local vehicle = getPedOccupiedVehicle( source ) 
    if ( vehicle ) then 
		local pos = {getElementPosition( vehicle )}
        Cortinapuesta = createObject( 1000, pos[1], pos[2], pos[3] )
        attachElements( Cortinapuesta, vehicle, 0, 0, 0, 0, 0, 0 )
	
    end
end 
addEvent("PonerCortina", true)
addEventHandler("PonerCortina", root, Cortina1)


function CancelarCortina()
    local vehicle = getPedOccupiedVehicle( source ) 
    if ( vehicle ) then 
			destroyElement(Cortinapuesta) 
		
    end end
addEvent("SacarCortina", true)
addEventHandler("SacarCortina", root, CancelarCortina)

-----------------------------------------------------------------------------------------------------

function addPJfction (player)
     triggerClientEvent (getRootElement(),"addPJ2", getRootElement(), player )
end
addEvent( "addPJ", true )
addEventHandler( "addPJ", resourceRoot, addPJfction )

function removePJfction (player)
     triggerClientEvent (getRootElement(),"removePJ2", getRootElement(),player )
end
addEvent( "removePJ", true )
addEventHandler( "removePJ", resourceRoot, removePJfction )

 

Link to comment

I don't understand a lot but I can figure out you mean that you want to save a paintjob on a database, so you can load it later.

You should really learn SQL functions on the wiki:

executeSQLQuery()

You should trigger a client event for all players, so the shader is applied for everyone, preferably on the Cortina1() function.

for i,players in ipairs (getElementsByType ("player")) do
  triggerClientEvent (players,"setShader",players,cortina)
  end

then on the "setShader" event, use engineApplyShaderToWorldTexture() on the first parameter of the function called by "setShader" on the client side.

Link to comment
11 hours ago, MadnessReloaded said:

I don't understand a lot but I can figure out you mean that you want to save a paintjob on a database, so you can load it later.

You should really learn SQL functions on the wiki:


executeSQLQuery()

You should trigger a client event for all players, so the shader is applied for everyone, preferably on the Cortina1() function.


for i,players in ipairs (getElementsByType ("player")) do
  triggerClientEvent (players,"setShader",players,cortina)
  end

then on the "setShader" event, use engineApplyShaderToWorldTexture() on the first parameter of the function called by "setShader" on the client side.

10 hours ago, MadnessReloaded said:

jugadores

 

If I'm not mistaken, what would generate that is that all users have the same paintjob and is not what I look for, but only that user has that paintjob when clicking. Anyway, I can not attache them

 

-- Client Side

addEventHandler("onClientGUIClick", guiRoot, --VENTANA2 = CORTINAS > Completas > Turquesas
	function (player)
local getGui = guiGetVisible(Ventana2)
		
if source == Boton9a then	
    triggerServerEvent("PonerCortina", localPlayer, localPlayer)
	
			PrecioCortinasCompletas = 3500
			PrecioTotal = PrecioCortinasCompletas
			guiSetText(BotonTOTAL2, PrecioCortinasCompletas)
			 local paintjobID = 1
												
 end end) 
 

 
 function addPaintjob2(paintjobID,player)
if paintjobID == 1 then
	myTexture = dxCreateTexture( "cortinasRojas.png" )
	elseif paintjobID == 2 then
	myTexture = dxCreateTexture( "cortinasAzules.png" )
	else
	if player == getLocalPlayer() then
	outputChatBox ("There is no such paintjob ID!")
	return
	end
	end
	engineRemoveShaderFromWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) )
	shader_cars, tec = dxCreateShader ( "shader.fx" )
	engineApplyShaderToWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) )
	dxSetShaderValue ( shader_cars, "TX0", myTexture ) 
end
addEvent( "setShader", true )
addEventHandler( "setShader", getLocalPlayer(), addPaintjob2 )
Server-Side

function Cortina1()
    local vehicle = getPedOccupiedVehicle( source ) 
    if ( vehicle ) then 
		local pos = {getElementPosition( vehicle )}
        Cortinapuesta = createObject( 1000, pos[1], pos[2], pos[3] )
        attachElements( Cortinapuesta, vehicle, 0, 0, 0, 0, 0, 0 )
		
		triggerClientEvent (players,"setShader",players,cortina)
		
		
  end end
addEvent("PonerCortina", true)
addEventHandler("PonerCortina", root, Cortina1)

 

Link to comment

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.
×
×
  • Create New...