Jump to content

[TUT]Creating Welcome message


VenomOG

Recommended Posts

Hello, welcome to lua. Your code is well done, the only problem is that you did not specify the "source" and anclasted the event badly to the function.

 

Here is the solution : 

function msg ( source ) --Here you clarify that "source" would come as a player
	local joinedPlayerName = getPlayerName ( source )
	local serverName = getServerName( )
	-- and send him a greeting
	outputChatBox ( "Welcome " .. joinedPlayerName .. " to ".. serverName .."!" , source, 255, 255, 255 )
end
addEventHandler ( "onPlayerJoin", getRootElement(), msg )  --Each time you anchor the event to the function, you must put the name of this

 

Link to comment
  • Moderators

You copied-and-pasted and an example of MTA Wiki which is pretty simple, to make a tutorial using a code that isn't yours?

Also you can't even understand that code. Proof of this is that you only changed the function name and forgot to change in the event handler too.

Would be better you post in the scripting section so someone would explain you how it works.

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