Jump to content

Help my script!


Flipi

Recommended Posts

Hi, How I can do to make the text color can be changed with setting?

this is a shout admin....

Script....

local sx, sy = guiGetScreenSize() 
local sx = sx / 2 
local sy = sy / 2 
function drawText() 
    local r,g,b = (0,128,255) 
    local width = dxGetTextWidth(theText, 3, "default") 
    local height = dxGetFontHeight(3, "default") 
    local leftB = sx - width / 2 
    local topB = sy - (height + 5) 
    local left = sx - width / 2 
    local top = sy - height 
    dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) 
    dxDrawText(theText, leftB, topB, left, top, RGBColor(r,g,b), 3, "default-bold", "left", "top", false, true, true) 
end 
draw = false 
function drawShout(text) 
    if not draw then 
        theText = text 
        addEventHandler("onClientRender", root, drawText) 
        draw = true 
        setTimer(function() 
        draw = false 
        removeEventHandler("onClientRender", root, drawText) 
        end, 5000, 1) 
    end 
end 
addEvent("onShouts", true) 
addEventHandler("onShouts", root, drawShout) 
  
function RGBColor(red, green, blue) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then 
        return 
end 

Meta setting....

        name="*Color de texto" 
    value="#0080FF" 
    /> 

Link to comment
  • Moderators

Yeah we got it, and Solidsnake just gave you the way to do it:

On the server side, get the value of the setting you seted in the meta with the get function.

Once you got it, send it on the client side with the triggerClientEvent function.

On the client side, just get the value that was sent and store it in a global variable (variable that doesn't have the local keyword).

And in your drawText function, do something like this:

function drawText() 
    --local r,g,b = (0,128,255) 
    local color = myGlobalColor or tocolor(0, 128, 255) 
    [...] 
    dxDrawText(theText, leftB, topB, left, top, color, ...) 
    [...] 
end 

Link to comment
Yeah we got it, and Solidsnake just gave you the way to do it:

On the server side, get the value of the setting you seted in the meta with the get function.

Once you got it, send it on the client side with the triggerClientEvent function.

On the client side, just get the value that was sent and store it in a global variable (variable that doesn't have the local keyword).

And in your drawText function, do something like this:

function drawText() 
    --local r,g,b = (0,128,255) 
    local color = myGlobalColor or tocolor(0, 128, 255) 
    [...] 
    dxDrawText(theText, leftB, topB, left, top, color, ...) 
    [...] 
end 

In this way can it be??

local sx, sy = guiGetScreenSize() 
local sx = sx / 2 
local sy = sy / 2 
function drawText() 
    local r,g,b = tocolor(0,128,255) 
    local width = dxGetTextWidth(theText, 3, "default") 
    local height = dxGetFontHeight(3, "default") 
    local leftB = sx - width / 2 
    local topB = sy - (height + 5) 
    local left = sx - width / 2 
    local top = sy - height 
    dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) 
    dxDrawText(theText, leftB, topB, left, top, RGBColor(r,g,b), 3, "default-bold", "left", "top", false, true, true) 
end 
draw = false 
function drawShout(text) 
    if not draw then 
        theText = text 
        addEventHandler("onClientRender", root, drawText) 
        draw = true 
        setTimer(function() 
        draw = false 
        removeEventHandler("onClientRender", root, drawText) 
        end, 5000, 1) 
    end 
end 
addEvent("onShouts", true) 
addEventHandler("onShouts", root, drawShout) 
  
function RGBColor(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return 
end 

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