Jump to content

[REL]Tip Window


iChang

Recommended Posts

Yo yo,

Here's my tip window script.

It's basically a window that moves up from the bottom right of your screen every 60 seconds containing a random tip specified by you.

SERVER:

msgs = { 
    "Message 1", 
    "Message 2", 
    "Message 3", 
    "Message 4" 
} 
  
function getRandomTip() 
    local text = msgs[math.random(1, #msgs)] 
    triggerClientEvent("startHint", root, text) 
end 
setTimer(getRandomTip, 60000, 0) 

CLIENT:

  
sX, sY = guiGetScreenSize() 
  
  
height = 1 --Starting height 
maxHeight = 1.2 
alpha = 0.65 
noticeSound = false 
noticeSoundID = 45 
  
  
--VARIABLES YOU SHOULDN'T CHANGE 
moveWindowForward = false 
secondHeight = 0 
-------------------------------- 
  
  
tipWnd = guiCreateWindow(sX/1.22, sY/height,227,181,"Information",false) 
guiWindowSetMovable(tipWnd,false) 
guiWindowSetSizable(tipWnd,false) 
guiSetAlpha(tipWnd, alpha) 
tipLabel = guiCreateLabel(9,26,216,144,"",false,tipWnd) 
guiSetVisible(tipWnd, false) 
  
  
addEvent("startHint", true) 
addEventHandler("startHint", root, 
function(text) 
    guiSetText(tipLabel, text) 
    moveWindowForward = true 
    tipWindowVisible(true) 
    if noticeSound then 
        playSoundFrontEnd(noticeSoundID) 
    end 
end) 
  
function tipWindowVisible(state) 
    guiSetVisible(tipWnd, state) 
end 
  
addEventHandler("onClientPreRender", root, 
function() 
    if isTimer(backTimer) then return end 
     
    if moveWindowForward then 
        if height < maxHeight then 
            height = height + 0.004 
        end 
        if height >= maxHeight then 
            moveWindowForward = false 
                 
            backTimer = setTimer( 
            function()  
             
                function moveItBack() 
                    if moveWindowForward == false then 
                        if height >= 1 then 
                            height = height - 0.004 
                        end 
                        if height <= 1 then 
                            tipWindowVisible(false) 
                            removeEventHandler("onClientPreRender", root, moveItBack) 
                        end 
                    end 
                end 
                addEventHandler("onClientPreRender", root, moveItBack) 
                 
             end, 9000, 1) 
        end 
    end 
    guiSetPosition(tipWnd, sX/1.22, sY/height, false) 
end) 
  

In the end... It should look like this:

346rpzb.jpg

Edited by Guest
Link to comment

Good idea, but I'd add more graphics to it. Use some dxDrawRectangle-stuff and make some setting-options in which you can set the colors. This way a lot more people will download and use it, since they can make it look like they want to.

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