Jump to content

[SHOW] Weapon Shop - Holoscreen


Alexs

Recommended Posts

Hi everyone, these last two weeks I've been busy linking up one of my old resources with @samt2497's holoscreens.

The results, although the resource is not finished yet and there are some errors to fix, are the following ones:

The resource is fairly simple, weapons are bought and stored at player's arsenal, these are equippable and ammunition works separately, so that certain weapons are able to share the same type of ammunition.

* Video's lag is made by the program that I use to record, it's not caused by the resource, conversely, the resource is capable of remain stable without reducing frames per second.

Link to comment
How did you check if cursor is Range of the buttons or the holoscreen ?!

Please Can you tell me ?

anyway you Did a Nice Job ;)

The samt2497's resource takes care of that.

What the function i use ?

i mean

when the mouse is range of the button won't change color as i make it

first of all how i can get mouse position in the holoscreen !!

Gns8kxG.jpg?1

here is code :

RTE_Demo = nil 
RTE_Holo = nil 
  
addEventHandler( "onClientResourceStart", resourceRoot, 
    function ( startedRes ) 
    local holoscreen,RT_ID,RTE = createHoloScreen(149,2482,16.5,40,0,90,5.35,6) --Create our holoscreen 
        setElementData(holoscreen,"interactive","aim") -- Make it interactive on user aim 
        if RTE then -- If we got the render Target of the screen then 
            RTE_Demo = RTE 
            RTE_Holo = holoscreen 
            addEventHandler ( "onHoloScrenRender", RTE_Holo,drawHoloDemo) -- Event handler for every render of the holo screen 
        end 
    end 
); 
  
function drawHoloDemo() 
    local width, height = dxGetMaterialSize(RTE_Demo) 
    local sW, sH = dxGetMaterialSize(RTE_Demo) 
    dxSetRenderTarget(RTE_Demo,true) 
    -- 
    function isMouseWithinRangeOf(posX, posY, sizeX, sizeY) 
  if isCursorShowing() == false then 
    return false 
  end 
  local cx,cy = getCursorPosition() 
  cx,cy = cx*sW,cy*sH 
  if cx >= posX and cx <= posX+sizeX and cy >= posY and cy <= posY+sizeY then 
    return true,cx,cy 
  else 
    return false 
  end 
end 
  
boxes = { 
  {x = sW/2-sW/10, y = sH/2-sH/7.4+sH/18, w = sW/5, h = sW/5, borderColor = tocolor(0, 200, 255)}, 
  {x = sW/2-sW/6, y = sH/2-sH/7, w = sW/3, h = sH/20, borderColor = tocolor(0, 200, 255), boxD = "aqua", text = "Hi There", messageBox = "1"}, 
  } 
buttons = { 
  {x = boxes[2].x + boxes[2].w - sW/47 - sW/13, y = boxes[2].y + boxes[2].h - sH/14, w = sW/13, h = boxes[2].w/6.5, color = tocolor(255,255,255), borderColor = tocolor(0, 224, 224), text = "Click Here", func = "pressLogin"}, 
} 
    for i,b in ipairs(buttons) do 
        dxDrawRectangle(b.x ,b.y ,b.w,b.h,b.color) 
        dxDrawRectangle(b.x , b.y , b.w, 1, b.borderColor) 
      dxDrawRectangle(b.x , b.y , 1, b.h, b.borderColor) 
      dxDrawRectangle(b.x, b.y + b.h , b.w, 1, b.borderColor) 
      dxDrawRectangle(b.x + b.w, b.y , 1, b.h, b.borderColor) 
      if b.text then 
      dxDrawText ( b.text, b.x , b.y , b.x + b.w , b.y + b.h , tocolor(31,31,31), sW/1600, "default", "center", "center") 
      end 
        if isMouseWithinRangeOf(b.x , b.y , b.w, b.h) then 
        dxDrawRectangle(b.x ,b.y ,b.w,b.h,tocolor(0,255,255)) 
           if b.text then 
           dxDrawText ( "Now Release", b.x , b.y , b.x + b.w , b.y + b.h , tocolor(255,255,255), sW/1600, "default", "center", "center") 
           end 
        end 
    end 
        local ix = getElementData(RTE_Holo,"ix") 
        local iy = getElementData(RTE_Holo,"iy") 
        if ix and iy then 
            local tx = ix*width 
            local ty = iy*height 
            dxDrawLine (tx-13,ty, tx+13,ty,tocolor(255,0,0,255),1) 
            dxDrawLine (tx,ty-13,tx,ty+13,tocolor(255,0,0,255),1) 
        end 
    -- 
    dxSetRenderTarget() 
end 
  

Link to comment
  • 4 months later...
  • 1 month later...

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