Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Registration has been disabled as I did not want to build a community, but just a place to release and or share content made by me and friends. If you encounter any problems with the site, or content please reach out to me via discord: privatedonut

How to create your first Eluna script.

Deluxt

Administrator
Staff member
Joined
Jun 14, 2024
Messages
31
Lets make a script that sends a message to the player on login.

First thing i do is go and look at Eluna's documentation and see what events are available.

You can find these here

There you will see all the player events.
We are going to use PLAYER_EVENT_ON_LOGIN = 3, // (event, player)

The number 3 is the event id. We will use this to register our event at the end.
The comment (event, player) tells us what the event returns and what our parameters should be.

So we start our script by declaring a function
Code:
local function OnLogin(event, player)
end

Inside of this function were going to send the player a message.

To find all functions available to the player object you can find that by searching Player in the documentation.

I found the function Player:SendBroadcastMessage

I also found the function WorldObject:GetName

Now you may of noticed its not a child of player but instead is a child of WorldObject this is completely fine bc a player is a world object.

So lets combine the 2 and add it to our function.
Code:
local function OnLogin(event, player)
    player:SendBroadcastMessage("Welcome, "..player:GetName().."!")
end

To concatenate a string you use the operator .. as shown above.

Now we need to register our event.
Code:
local function OnLogin(event, player)
    player:SendBroadcastMessage("Welcome, "..player:GetName().."!")
end

RegisterPlayerEvent(3, OnLogin)

With that done we can now save our script and put it in the lua_scripts folder.

And .reload eluna and login to see our message.

With that you have created your first Eluna script.

Creating scripts with Eluna is really easy you just need to use the documentation to find what you want to do and then use it.
 
Back
Top