Jump to content

ChatBox Script


Recommended Posts

Ok, I just started scripting today and I wanted to start off very simpel, but I failed with my plan.

First thing I programmed a code with which a message is given once a player enters a server. Everybody on the server can read this message. Next thing I wanted to make another message when entering the server, but this one should only be shown to the person that entered the server. I tried everything that came to my mind. I know that you can do

outputChatBox(text, visibleTo) 

but I don't know what to enter for "visibileTo". The only thing I got it to work with was GetRandomPlayer() which is not what I want. But all the commands like getLocalPlaeyer() are client sided thus don't work.

Can any1 help me?

Link to comment

So here is my code, but it doesn't work...

function welcomemsg() 
local name = getPlayerName(source) 
         outputConsole('Welcome to the server, '..name..' !', source) 
end 
addEventHandler("onPlayerJoin", getRootElement(), welcomemsg) 

Edit: Ok, I finally got it :)

function welcomemsg ( ) 
    local name = getPlayerName ( source ) 
    outputChatBox ( "Welcome to the server, " .. name .. "!", source) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), welcomemsg) 

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