Jump to content

Yamamoto

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Yamamoto

  1. weed = {} -- creamos una tabla para almacenar las compras  
    
    function buyWeed ()
        local money = getPlayerMoney( source )
        if not weed[source] then -- comprobamos que no tengo una compra ya hecha
           if money >= 180 then 
              local player = source 
              weed[player] = true -- añadimos la compra a la tabla 
              setPedAnimation(player ,"DEALER", "shop_pay")
              takePlayerMoney(player, 180)
              animTimers[player] = setTimer(startSmokingWeed,4500, 1, player)
           else
            outputChatBox( "Vuelve cuando tengas el dinero",source,200,0,0)
           end 
        else 
            outputChatBox( "Ya compraste weed",source,200,0,0)
        end
    end
    addEvent("buyWeed", true)
    addEventHandler("buyWeed", root, buyWeed)
    
    function startSmokingWeed(player)
      weed[player] = nil  -- en tu funcion startSmokingWeed añade esta linea que elimina la compra 
    end 

     

    • Thanks 1
  2. 19 hours ago, Kelly003 said:

    I want to export a function that rotates the object, this is what the function looks like:

    function rotateobj()
        local orx, ory, orz = getElementRotation(obj)
        setElementRotation(obj, orx, ory, orz+1)
    end
    addEventHandler("onClientRender"root, rotateobj)



    and i want to export this function to another script and i don't know how to do it i tried to do something but i can't get it


     

    
    local obj = createObject(1947, 193.71983, -105.13480, 1.54872-1)
    exports["rotobj"]:rotateobj()
     

    first you need to add the variable in your function

    function rotateobj(obj)
        local orx, ory, orz = getElementRotation(obj)
        setElementRotation(obj, orx, ory, orz+1)
    end

    and then export

    local obj = createObject(1947, 193.71983, -105.13480, 1.54872-1)
    exports["rotobj"]:rotateobj(obj)

     

     

  3. which way is more efficient for a trigger

    triggerClientEvent(root, "....", root)
    
    or 
    
    for k, player in ipairs(getElementsByType("player")) do 
      triggerClientEvent(player, "....", player)
    end 

     

  4.  

    Is it possible to combine these two shaders so that a black and white blur comes out?

    texture texture0;
    float factor;
     
    sampler Sampler0 = sampler_state
    {
        Texture = (texture0);
        AddressU = MIRROR;
        AddressV = MIRROR;
    };
     
    struct PSInput
    {
      float2 TexCoord : TEXCOORD0;
    };
     
    float4 PixelShader_Background(PSInput PS) : COLOR0
    {
            float4 sum = tex2D(Sampler0, PS.TexCoord);
            for (float i = 1; i < 3; i++) {
                    sum += tex2D(Sampler0, float2(PS.TexCoord.x, PS.TexCoord.y + (i * factor)));
                    sum += tex2D(Sampler0, float2(PS.TexCoord.x, PS.TexCoord.y - (i * factor)));
                    sum += tex2D(Sampler0, float2(PS.TexCoord.x - (i * factor), PS.TexCoord.y));
                    sum += tex2D(Sampler0, float2(PS.TexCoord.x + (i * factor), PS.TexCoord.y));
            }
            sum /= 9;
            sum.a = 1.0;
            return sum;
    }
     
    technique complercated
    {
        pass P0
        {
            PixelShader = compile ps_2_0 PixelShader_Background();
        }
    }
     
    technique simple
    {
        pass P0
        {
            Texture[0] = texture0;
        }
    }
    //
    // blackwhite.fx
    //
    
    texture screenSource;
     
    sampler TextureSampler = sampler_state
    {
        Texture = <screenSource>;
    };
    
    float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0
    {
        float4 color = tex2D(TextureSampler, TextureCoordinate);
     
        float value = (color.r + color.g + color.b) / 3; 
        color.r = value;
        color.g = value;
        color.b = value;
     
        return color;
    }
     
    technique BlackAndWhite
    {
        pass Pass1
        {
            PixelShader = compile ps_2_0 PixelShaderFunction();
        }
    }

     

×
×
  • Create New...