toxicsmoke11 Posted January 7, 2014 Share Posted January 7, 2014 script function greetings() local joinedPlayerName = getPlayerName ( source ) if getPlayerName( "mike" ) then outputChatBox( "Welcome Mike!" ) end addEventHandler ( "onPlayerJoin", getRootElement(), greetings ) error: mike.lua:8: end expected to close 'function' line 1 near Link to comment
xXMADEXx Posted January 7, 2014 Share Posted January 7, 2014 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
Renkon Posted January 7, 2014 Share Posted January 7, 2014 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
toxicsmoke11 Posted January 7, 2014 Author Share Posted January 7, 2014 Thank you xXMADEXx for fixing the script,and thank you Renkon for explaining to me which line does what. Link to comment
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