Jump to content

help nos color


Recommended Posts

how to make nitro color visible to everyone.

i mean i want each player color to be visible to the other

---------------------------------------------------------------------------------
--
-- Nitro shader
--
--
---------------------------------------------------------------------------------

addEventHandler("onClientResourceStart",resourceRoot,
function()
	nitroShader = dxCreateShader("nitro.fx")
end)

-- This function will set the new color of the nitro
function updateNitroColor(r,g,b)
	if nitroShader then
		if r and g and b then
			engineApplyShaderToWorldTexture (nitroShader,"smoke")
			dxSetShaderValue (nitroShader, "gNitroColor", r/255, g/255, b/255 )
		end
	end
end

-- This function will reset the nitro back to the original
function resetNitroColor()
	if nitroShader then
		engineRemoveShaderFromWorldTexture(nitroShader,"smoke")
	end
end



-- Example command use
addCommandHandler("nitro",
function(command,r,g,b)
	if r and g and b then
		local r,g,b = tonumber(r),tonumber(g),tonumber(b)
		if r <= 255 and g <= 255 and b <= 255 then
			updateNitroColor(r,g,b)
			outputChatBox("Nitro color updated!",255,255,255,true)
		else
			outputChatBox("Colors must be between 0 and 255",255,255,255,true)
		end
	else
		resetNitroColor()
		outputChatBox("Nitro color reset to original!",255,255,255,true)
	end
end)

this is not my script btw

Link to comment

my Problem is that the nitro color is the same for everyone.

for example: my nitro color is yellow and another player's is blue but i see his nitro color as yellow and he sees mine as blue 

-- server
function setNitroColor(r, g, b, player)
	triggerClientEvent(root , "Nitrochange", root, r, g, b, player)
end


-- client

shader = dxCreateShader(":CCS/models/nitro.fx")

function nitroColor(r, g, b, v) 
	if v == localPlayer then
		dxSetShaderValue (shader, "gNitroColor", r/255, g/255, b/255 )
		engineApplyShaderToWorldTexture (shader,"smoke", getPedOccupiedVehicle(v))
	end
end
addEvent( "Nitrochange", true)
addEventHandler("Nitrochange", root, nitroColor)


-- shader

//
// nitro.fx
//
// Author: NeXTreme


//---------------------------------------------------------------------
// Nitro settings
//---------------------------------------------------------------------
float4 gNitroColor = float4(255,255,255,150);


//---------------------------------------------------------------------
// These parameters are set by MTA whenever a shader is drawn
//---------------------------------------------------------------------
float4x4 gWorld : WORLD;
float4x4 gView : VIEW;
float4x4 gProjection : PROJECTION;


//------------------------------------------------------------------------------------------
// textureState - String value should be a texture number followed by 'Texture'
//------------------------------------------------------------------------------------------
texture gTexture0           < string textureState="0,Texture"; >;


//---------------------------------------------------------------------
// Sampler for the main texture
//---------------------------------------------------------------------
sampler texsampler = sampler_state
{
    Texture = (gTexture0);
};


//---------------------------------------------------------------------
// Structure of data sent to the vertex and pixel shaders
//---------------------------------------------------------------------
struct VertexShaderInput
{
    float3 Position : POSITION0;
    float4 Diffuse : COLOR0;
    float2 TexCoords : TEXCOORD0;
};

struct PixelShaderInput
{
    float4 Position  : POSITION;
    float4 Diffuse : COLOR0;
    float2 TexCoords : TEXCOORD0;
};


//------------------------------------------------------------------------------------------
// VertexShaderFunction
//------------------------------------------------------------------------------------------

PixelShaderInput VertexShaderFunction(VertexShaderInput In)
{
    PixelShaderInput Out = (PixelShaderInput)0;
	
	float4 posWorld = mul(float4(In.Position,1), gWorld);
    float4 posWorldView = mul(posWorld, gView);
    Out.Position = mul(posWorldView, gProjection);
	Out.TexCoords = In.TexCoords;
	
    Out.Diffuse = saturate(gNitroColor);
	
    return Out;
}


//------------------------------------------------------------------------------------------
// PixelShaderFunction
//------------------------------------------------------------------------------------------
float4 PixelShaderFunction(PixelShaderInput In) : COLOR0
{
	float4 texel = tex2D(texsampler, In.TexCoords);
	
	float4 finalColor = texel * In.Diffuse;
		
	finalColor *= 0.23;
	
    return finalColor;
}



//-----------------------------------------------------------------------------
// Techniques
//-----------------------------------------------------------------------------
technique nitro
{
    pass P0
    {
        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader  = compile ps_2_0 PixelShaderFunction();
    }
}


technique fallback
{
    pass P0
    {
    }
}

 

Edited by kikos500
Link to comment

The problem is that you're replacing a texture file
And as far as I know without some keen scripts you can't replace textures server sided like that, probably because it'll cause lag, they haven't added this feature for easy access.
For example:
If you replace a texture on the infernus, everyone has to see it, and you have to see everyone with the texture also.

Link to comment

I'm not entirely sure but I'm pretty sure they're using a shader function with customized .dff and .txd files.
While the nos color is a .fx file modification.
Would have to ask certain members of the community who know modding very well.
 

Link to comment

Impossible because this effect is not an element and you cannot limit shaders to a certain effect of a certain vehicle...

If you change the color of one NOS effect, all will be changed because you need to apply this shader to the world in order to work at all.

 

Unless you use some haxy workaround and add a custom object that can be attached to the vehicle which isn't really that easy for a beginner.

  • Like 1
Link to comment
15 hours ago, Einheit-101 said:

Impossible because this effect is not an element and you cannot limit shaders to a certain effect of a certain vehicle...

If you change the color of one NOS effect, all will be changed because you need to apply this shader to the world in order to work at all.

 

Unless you use some haxy workaround and add a custom object that can be attached to the vehicle which isn't really that easy for a beginner.

ok I have another question if I to add a car painjob on the car roof  how can I do that?

maybe replace a mta object with a custom object with a txd looking like the paint that I want?

Link to comment

I'm not too good with shaders, but it's worth a try... try to remove the if statement that checks if it's the localPlayer. Because you will only change the shader for the local player, the code will never run for others. If you use getPedOccupiedVehicle(v), you will still only change the localPlayer's vehicle, but others should see it as well, the big if here is, can MTA restrict it to a single vehicle... 

-- server
function setNitroColor(r, g, b, player)
	triggerClientEvent(root , "Nitrochange", root, r, g, b, player)
end


-- client



function nitroColor(r, g, b, v) 
  	local shader = dxCreateShader(":CCS/models/nitro.fx")
	dxSetShaderValue (shader, "gNitroColor", r/255, g/255, b/255 )
	engineApplyShaderToWorldTexture (shader,"smoke", getPedOccupiedVehicle(v))
end
addEvent( "Nitrochange", true)
addEventHandler("Nitrochange", root, nitroColor)

 

Edited by pa3ck
Link to comment
  • Scripting Moderators
1 hour ago, pa3ck said:

I'm not too good with shaders, but it's worth a try... try to remove the if statement that checks if it's the localPlayer. Because you will only change the shader for the local player, the code will never run for others. If you use getPedOccupiedVehicle(v), you will still only change the localPlayer's vehicle, but others should see it as well, the big if here is, can MTA restrict it to a single vehicle... 


-- server
function setNitroColor(r, g, b, player)
	triggerClientEvent(root , "Nitrochange", root, r, g, b, player)
end


-- client



function nitroColor(r, g, b, v) 
  	local shader = dxCreateShader(":CCS/models/nitro.fx")
	dxSetShaderValue (shader, "gNitroColor", r/255, g/255, b/255 )
	engineApplyShaderToWorldTexture (shader,"smoke", getPedOccupiedVehicle(v))
end
addEvent( "Nitrochange", true)
addEventHandler("Nitrochange", root, nitroColor)

 

The only way is to remake a nos smoke effect.

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...