Flipi Posted October 26, 2013 Posted October 26, 2013 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" />
Flipi Posted October 26, 2013 Author Posted October 26, 2013 Resource settings? yes, you understand what I mean?
Castillo Posted October 26, 2013 Posted October 26, 2013 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.
Flipi Posted October 26, 2013 Author Posted October 26, 2013 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 Citizen Posted October 27, 2013 Moderators Posted October 27, 2013 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
Flipi Posted October 27, 2013 Author Posted October 27, 2013 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 Citizen Posted October 28, 2013 Moderators Posted October 28, 2013 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.
Flipi Posted October 28, 2013 Author Posted October 28, 2013 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...
Castillo Posted October 28, 2013 Posted October 28, 2013 All you have to do is send the color along with the message on the "onShouts" event.
Flipi Posted October 28, 2013 Author Posted October 28, 2013 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
Castillo Posted October 29, 2013 Posted October 29, 2013 The thing is, this has nothing to do with setting, you obviously don't understand what I'm saying.
Flipi Posted October 29, 2013 Author Posted October 29, 2013 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?
.:HyPeX:. Posted October 29, 2013 Posted October 29, 2013 We cant make it done for you, you would just mess it up quickly if you dont know what client/server side means. Read this: https://wiki.multitheftauto.com/wiki/Sc ... de_scripts
Flipi Posted October 30, 2013 Author Posted October 30, 2013 We cant make it done for you, you would just mess it up quickly if you dont know what client/server side means.Read this: https://wiki.multitheftauto.com/wiki/Sc ... de_scripts I know what that means, just I never make a script with setting...... you understand?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now