Szerző Téma: Egyedi tuning és szín  (Megtekintve 657 alkalommal)

Egyedi tuning és szín
« Dátum: 2017. augusztus 31. - 01:30:05 »
0 Show voters
Sziasztok az lenne a kérdésem : 
 
1.) Van egy kocsim annak eltüntettem a bumperjét és creálok egy ujjat mint egy object és hozzá attacholom ez így jó lesz hosszú távon egy kocsis szerveren a tuning rendszerbe ? 
 
2.) Hogy tudnám annak az egy objektumnak a színét meg változtatni ? Mert úgy akarom hogy a kocsi szinéhez passzoljon.
 
Forrás kód :  Kliens : 
 

bumper = nil
addEventHandler(\"onClientResourceStart\",resourceRoot,
function()
shader = dxCreateShader(\"color.fx\",0,0,false,\"object\")
end)
 
function newBumper()
local theVeh = getPedOccupiedVehicle(localPlayer)
setVehicleComponentVisible(theVeh, \"bump_front_dummy\", false)
local x,y,z = getVehicleComponentPosition(theVeh, \"bump_front_dummy\")

triggerServerEvent ( \"CreateBumper\", resourceRoot,localPlayer,theVeh,x,y,z)
end
addCommandHandler(\"bumper\",newBumper)
function getBumperGlobal ( bum,veh )
outputChatBox(\"GOOD NIGGA\")
  bumper = bum
  engineApplyShaderToWorldTexture (shader,\"#emapelegybody128\",veh)
end
addEvent( \"getBumpCli\", true )
addEventHandler( \"getBumpCli\", localPlayer, getBumperGlobal )
 
function playerPressedKey(button, press)
    if (press)  and (button == \"arrow_l\")then
   local x,y,z =  getElementAttachedOffsets(bumper)   
   triggerServerEvent ( \"MoveBump\", resourceRoot,bumper,x+0.01,y,z)
    end
if (press)  and (button == \"arrow_r\")then
   local x,y,z =  getElementAttachedOffsets(bumper)   
   triggerServerEvent ( \"MoveBump\", resourceRoot,bumper,x-0.01,y,z)
    end

if (press)  and (button == \"arrow_u\")then
   local x,y,z =  getElementAttachedOffsets(bumper)   
   triggerServerEvent ( \"MoveBump\", resourceRoot,bumper,x,y+0.01,z)
    end

if (press)  and (button == \"arrow_d\")then
   local x,y,z =  getElementAttachedOffsets(bumper)   
   triggerServerEvent ( \"MoveBump\", resourceRoot,bumper,x,y-0.01,z)
    end

if (press)  and (button == \"num_1\")then
   local x,y,z =  getElementAttachedOffsets(bumper)   
   triggerServerEvent ( \"MoveBump\", resourceRoot,bumper,x,y,z+0.01)
    end

if (press)  and (button == \"num_3\")then
   local x,y,z =  getElementAttachedOffsets(bumper)   
   triggerServerEvent ( \"MoveBump\", resourceRoot,bumper,x,y,z-0.01)
    end


end
addEventHandler(\"onClientKey\", root, playerPressedKey)
 
-- This function will set the new color of the nitro
function Coloring(r,g,b)
if shader then
   if r and g and b then
   local theVeh = getPedOccupiedVehicle(localPlayer)
      
      dxSetShaderValue (shader, \"gNitroColor\", r/255, g/255, b/255 )
   end
end
end
-- Example command use
addCommandHandler(\"color\",
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
      Coloring(r,g,b)
   else
      outputChatBox(\"Colors must be between 0 and 255\",255,255,255,true)
   end

end
end)

 
Szerver : 
 

function createBumpObject(player,vehicle,x,y,z)
bumper = createObject ( 1172,  x,  y,  z)
attachElements(bumper,vehicle,x,y,z)
triggerClientEvent ( player, \"getBumpCli\", player,bumper,vehicle)
end
addEvent( \"CreateBumper\", true )
addEventHandler( \"CreateBumper\", resourceRoot, createBumpObject )
 
function moveBump(bump,x,y,z)
setElementAttachedOffsets (bump,x,y,z)
end
addEvent( \"MoveBump\", true )
addEventHandler( \"MoveBump\", resourceRoot, moveBump )
 
function getBump(bump,x,y,z)
getElementAttachedOffsets (bump,x,y,z)
end
addEvent( \"getBump\", true )
addEventHandler( \"getBump\", resourceRoot, getBump )

 
Shader : 
 

float4 gColorShader = 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(gColorShader);

    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
    {
    }
}

 
 

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal