Jump to content

Simple Script Help


eyeinthesky43

Recommended Posts

Alright so I am new to scripting and don't know much but I am slowly learning.

The current code I have so far:

local msg_red,msg_green,msg_blue = 255,255,0 
  
function servertalkprivate(message, sendto) 
    outputChatBox(tostring(message), sendto, msg_red, msg_green, msg_blue, true) 
end 
  
function servertalk(message) 
    servertalkprivate(message, getRootElement()) 
end 
  
function onJoin() 
    servertalkprivate("MESSAGE1", source) 
    servertalkprivate("MESSAGE2", source) 
end 
  
addEventHandler("onPlayerJoin",getRootElement(),onJoin) 

I want it to display MESSAGE2 in a different color, The closest I have come to making this happen was:

local msg_red,msg_green,msg_blue = 255,255,0 
local msg2_red,msg2_green,msg2_blue = 39,26,225 
  
function servertalkprivate(message, sendto) 
    outputChatBox(tostring(message), sendto, msg_red, msg_green, msg_blue, true) 
    outputChatBox(tostring(message), sendto, msg2_red, msg2_green, msg2_blue, true) 
end 
  
function servertalk(message) 
    servertalkprivate(message, getRootElement()) 
end 
  
function onJoin() 
    servertalkprivate("MESSAGE1", source) 
    servertalkprivate("MESSAGE2", source) 
end 
  
addEventHandler("onPlayerJoin",getRootElement(),onJoin) 

However while that works, It displays MESSAGE1 and MESSAGE2 twice in the chatbox which is not what I wanted to happen lol...... Anyways any help on this would be greatly appreciated.

Link to comment

not really sure what ur asking for here...but..

if u want to just display it using colours, when not use them as parameters in ur function?

something like this for your 1st msg

servertalkprivate("MESSAGE1", source, msg_red, msg_green, msg_blue)  

then use this for your 2nd msg

servertalkprivate("MESSAGE1", source, msg2_red, msg2_green, msg2_blue)  

then in ur function:

function servertalkprivate(message, sendto, r, g, b) 

use the rgb's u send and the text will be outputted in the colours u want.

Link to comment

Thanks for the response, Sorry for not being clear, I basically want MESSAGE1 to display in the RGB color "255,255,0" and MESSAGE2 to display in "39,26,225"

I don't think I did your coding right cause when I tested it out no colors where displayed on the Message?

Here is what I have now:

local msg_red,msg_green,msg_blue = 255,255,0 
local msg2_red,msg2_green,msg2_blue = 39,26,225 
  
function servertalkprivate(message, sendto, r, g, b) 
    outputChatBox(tostring(message), sendto, true) 
end 
  
function servertalk(message) 
    servertalkprivate(message, getRootElement()) 
end 
  
function onJoin() 
    servertalkprivate("MESSAGE1", source, msg_red, msg_green, msg_blue) 
    servertalkprivate("MESSAGE2", source, msg2_red, msg2_green, msg2_blue) 
end 
  
addEventHandler("onPlayerJoin",getRootElement(),onJoin) 

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