Jump to content

Help my script!


Flipi

Recommended Posts

Posted

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" 
    /> 

Posted
You must use the get function ( server side only ). What you can do is, send get the value, then send it to the client side along with the message.

I want to able change the text color shout through the setting of resources. (is server-side)

any help??

  • Moderators
Posted

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 

Posted
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 

  • Moderators
Posted

Where are the modifications we asked you to put in ?? I also did a bit of the code you had to do yourself.

You need a server side code and modify some stuff in your client-side code.

Posted
Where are the modifications we asked you to put in ?? I also did a bit of the code you had to do yourself.

You need a server side code and modify some stuff in your client-side code.

I do not understand... :(

Posted
All you have to do is send the color along with the message on the "onShouts" event.

but local r,g,b or function RGBColor?

help me, it's my first script with setting u.u

Posted
The thing is, this has nothing to do with setting, you obviously don't understand what I'm saying.

give me an example of how it should be? :(

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