Jump to content

welcome message


Recommended Posts

You forgot to end the if statement and function.

function greetings() 
    local joinedPlayerName = getPlayerName ( source ) 
    if ( joinedPlayerName == 'mike' ) then 
        outputChatBox( "Welcome Mike!" ) 
    end 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), greetings ) 

Link to comment
function greetings() -- Here you define the function 
     local joinedPlayerName = getPlayerName ( source ) -- You are getting the player name and storing it in memory 
     --if getPlayerName( "mike" ) then This line is wrong, getPlayerName requires an argument pointing to a player, in this case that's a string and not a pointer, if you want to compare it should be like the following 
     if (joinedPlayerName == "Mike") then -- You can also do if (getPlayerName(source) == "Mike") to avoid using server's memory 
          outputChatBox( "Welcome Mike!" ) -- printing a message 
     end -- If is being closed here 
end -- You missed an end statement in order to close the function 
addEventHandler ( "onPlayerJoin", getRootElement(), greetings ) 

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