GuiLabelAddEffect: Difference between revisions
Jump to navigation
Jump to search
X1AhMeD,-09 (talk | contribs) (Created page with "==Syntax== <syntaxhighlight lang="lua">bool guiLabelAddEffect ( gui-element label, string effect )</syntaxhighlight> ===Required Arguments=== * '''label''': The label you wan...") |
(No difference)
|
Revision as of 16:15, 29 April 2018
Syntax
bool guiLabelAddEffect ( gui-element label, string effect )
Required Arguments
- label: The label you want to add effects to it.
- effect: The effect you want ( now the function support 2 effects only ( outline , shadow )
Returns
Returns the label that created as an effect if the effect labels have created, false otherwise.
Code
Click to collapse [-]
Clientside scriptfunction guiLabelAddEffect(label, effect) local nlab = {} local checkTimer = {} if label and getElementType(label) == "gui-label" then if effect and tostring(effect) and effect:len() > 3 then local position = { guiGetPosition(label, false) } local size = { guiGetSize(label, false) } if effect:lower() == "shadow" then nlab[1] = guiCreateLabel(position[1] + 1, position[2] + 1, size[1] + 1, size[2] + 1, guiGetText(label), false, getElementParent(label) and getElementParent(label) or nil) guiLabelSetColor(nlab[1], 0, 0, 0) elseif effect:lower() == "outline" then for i = 1, 4 do x, y, w, h = (i == 1 or i == 2 and 1 or -1), (i == 1 or i == 3 and 1 or -1), (i == 1 or i == 2 and 1 or -1), (i == 1 or i == 3 and 1 or -1) nlab[i] = guiCreateLabel(position[1] + x, position[2] + y, size[1] + w, size[2] + h, guiGetText(label), false, getElementParent(label) and getElementParent(label) or nil) guiLabelSetColor(nlab[i], 0, 0, 0) end end end end if #nlab > 0 then if #nlab == 1 then return nlab[1] elseif #nlab == 4 then return nlab[1], nlab[2], nlab[3], nlab[4] end if label then if isTimer(checkTimer[label]) then killTimer(checkTimer[label]) end checkTimer[label] = setTimer(function() for _,nlabel in ipairs(nlab) do guiSetVisible(nlabel, guiGetVisible(label)) end if not isElement(label) then killTimer(checkTimer[label]) end end, 100, 0) end else return false end end
Example
This example add shadow effect to the label.
addEventHandler("onClientResourceStart", resourceRoot, function() myLabel = guiCreateWindow(350, 100, 50, 50, "Hello World", false) end ) addCommandHandler("effect", function() if myLabel then guiLabelAddEffect(myLabel, "shadow") end end )
Author: #x1AhMeD,-09