Jump to content

[HELP] DxDraw Fade out


ViRuZGamiing

Recommended Posts

Posted (edited)

Hello

function buyMsg (player) 
    if showRoomVehicles[source] then 
        setVehicleLocked ( source, true ) 
        outputChatBox ("To buy this car write /buy", player, 255, 100, 0) 
    end 
end 

I have this in Server Side but I want it to chance the outputChatBox to a dxDraw but dxDraw is client how can I get it in?

should I do this;

-- server 
function buyMsg (player) 
    if showRoomVehicles[source] then 
        setVehicleLocked ( source, true ) 
        triggerClientEvent ( dxDraw, root ) 
    end 
end 
  
--client 
  
function dxDraw ( player ) 
    DxDrawRectangle(......) 
end 
addEvent( "dxDraw", true ) 
addEventHandler( "dxDraw", root, dxDraw ) 

Edited by Guest
Posted

Server

function buyMsg (player) 
    if showRoomVehicles[source] then 
        setVehicleLocked ( source, true ) 
        triggerClientEvent (player, "dxDraw", player ) 
    end 
end 

Client

  
function dxDraw ( ) 
    DxDrawRectangle(0,0,100,100) 
end 
  
addEvent( "dxDraw", true ) 
addEventHandler( "dxDraw", root,  
function() 
 addEventHandler("onClientRender",root,dxDraw) 
setTimer(function() removeEventHandler("onClientRender",root,dxDraw) end ,3000,1) 
end 
) 

it will Draw the Rectangel for 3 secounds

Posted

using "tocolor" on DxDraw. tocolor has 4 arguments RGBA where A is alpha 0-255.

local fade_a 
local do_fade 
  
function dxDraw ( ) 
    DxDrawRectangle(0,0,100,100,tocolor(0,0,0,fade_a)) 
  if do_fade then -- if fade is enabled 
   fade_a = fade_a - 1 -- decrease alpha on every frame until is 0  
 end 
  if do_fade and fade_a <=0 then -- if fade alpha is 0 turn the DxDraw off 
       removeEventHandler("onClientRender",root,dxDraw) 
  end  
end 
  
addEvent( "dxDraw", true ) 
addEventHandler( "dxDraw", root, 
function() 
 fade_a = 255 -- set alpha to max. 
 do_fade = false -- set fade effect off 
 addEventHandler("onClientRender",root,dxDraw) 
 setTimer(function() do_fade = true  end ,10000,1) -- after 10s enable fade 
end 
) 

Posted

According to wiki, it is possible:

bool dxDrawRectangle ( int startX, int startY, float width, float height [, int color = white, bool postGUI = false] ) 

For example, to make the rectangle half visible, you'd use this:

bool dxDrawRectangle ( 100, 100, 50, 50, tocolor(255,255,255,128) ) 

In order to make the rectangle fade out, you'd have to calculate the new alpha value in some time interval or simply "onClientRender".

Posted
using "tocolor" on DxDraw. tocolor has 4 arguments RGBA where A is alpha 0-255.
local fade_a 
local do_fade 
  
function dxDraw ( ) 
    DxDrawRectangle(0,0,100,100,tocolor(0,0,0,fade_a)) 
  if do_fade then -- if fade is enabled 
   fade_a = fade_a - 1 -- decrease alpha on every frame until is 0  
 end 
  if do_fade and fade_a <=0 then -- if fade alpha is 0 turn the DxDraw off 
       removeEventHandler("onClientRender",root,dxDraw) 
  end  
end 
  
addEvent( "dxDraw", true ) 
addEventHandler( "dxDraw", root, 
function() 
 fade_a = 255 -- set alpha to max. 
 do_fade = false -- set fade effect off 
 addEventHandler("onClientRender",root,dxDraw) 
 setTimer(function() do_fade = true  end ,10000,1) -- after 10s enable fade 
end 
) 

Again it works, I like you :D

Posted
function testHit ( thePlayer, matchingDimension ) 
        local elementType = getElementType( thePlayer ) 
        if (elementType) then 
        triggerClientEvent (source, "testMessage", root) 
        end 
end 
  
addEventHandler( "onMarkerHit", testMarker, testHit ) 

How can I get testMarker, it's in another function

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