[How-To] Create a basic script

well whats your question?

it works on FxServer
Print “Hello World” on the screen

What does the sm, ^, and " " mean?

Thank you for this tutorial. I’ve never scripted in lua and this will be my beginning! Please continue making tutorials like this one.

EDIT (FIXED): After posting to the forums I noticed I was missing an apostrophe at the end of the manifest version. This fixed it.

Any reason it would be failing to load welcome for me?

I’m obviously using the FXServer but every time I try to join my local server it says ‘Failed to load welcome :(’. I’ve got __resource.lua and client.lua files. Both are LUA Files and not txt documents (Already checked).

I’m 100% completely new to LUA scripting so I might be wrong in saying this but I have a weird feeling it’s to do with the resource manifest? Will it not be quite a dated manifest now?

__resource.lua

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5
client_script "client.lua"

client.lua

AddEventHandler("playerSpawned", function(spawn)
    TriggerEvent("chatMessage", "", { 0, 0, 0 }, "Hello world!")
end)

Thank you! Good luck)

Any one know if this is right please?

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

client_script "client.lua"
AddEventHandler("playerSpawned", function(spawn)
    -- TriggerEvent("chatMessage", "", { 0, 0, 0 }, "Welcome To Beyond Gaming Network")
end

I put this all under __resource but I think I did it wrong lol. Im trying to learn it sorry.

This part would go in the client.lua file that you reference in the __resource.lua . Not in __resource.lua itself.

1 Like

Ah got ya thank you, I must of miss read that. Thanks again.

4 messages in the same time

AddEventHandler(“playerSpawned”, function(spawn)
TriggerEvent(“chatMessage”, “”, { 0, 0, 0 }, “text”)
TriggerEvent(“chatMessage”, “”, { 0, 0, 0 }, “text”)
TriggerEvent(“chatMessage”, “”, { 0, 0, 0 }, “text”)
TriggerEvent(“chatMessage”, “”, { 0, 0, 0 }, “text”)
end)

this is my __resource.lua

resource_manifest_version ‘77731fab-63ca-442c-a67b-abc70f28dfa5’

client_script “client.lua”

this is my client.lua

AddEventHandler(“playerSpawned”, function(spawn)
TriggerEvent(“chatMessage”, “”, { 0, 0, 0 }, “Hi there the server will restart every 3 hours. No Fail Rping. Ask an admin if you have any quistion. AND HAVE FUN!!!”)
end)

is that right? im just trying to start off with this and it said when i joined my server that it couldnt load the resource and this is what it says when i go to my zap hosting console Could not open resource metadata file C:/cygwin\home\zap373762\g48857\gta5-fivem\server-data/resources//announcements/__resource.lua. :frowning: ?

From what I see your quotation marks are very different. You should stick with the " " always.

Ok thanks i will try that that’s how it came

it still says that the resource failed to load. :frowning:

Share your __resource.lua and client.lua as preformatted text here to check the whole thing out.

what do i just copy and paste it?

This helped a ton and will help me get started with everything Thanks so much! Is there any way you could maybe do a tutorial on chat commands and/or a command that brings up a phone or any image for that matter? @pongo1231

chat commands is just

RegisterCommand("commandName", function(source, args, rawCommand)
 ---put code in here
end)

and to bring up a picture you need to learn NUI.

Hello a frind give me this, probably you all scripters already know it or have something better… https://projects.eclipse.org/projects/tools.ldt

@Woopi Thanks So much! Keep up the good work!