MrSns Posted May 3, 2011 Share Posted May 3, 2011 Hey guys, Im new to scripting and just looking for a bit of help. (your obviously going to realise im new after reading my question haha) So anyway, i have been reading through the tutorials on the mtawiki and im having a bit of trouble. Im not to sure how to structure my scripting and generaly what to do, i get the idea and i know that i can use the Server Functions List page which is really helpful. But yeh I followed the tutorial and i got to trying to make a command. That worked fine but i just want to know is there anything i should be doing in regards to how i structure my scripting, do i need a main() function? Please note i have no previous scripting experience although i have read through some other language tutorials such as VB Thanks guys. here is my current script (one from the tut page) function joinHandler() local x = 1959.55 local y = -1714.46 local z = 20 spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to My Server", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) function createVehicleForPlayer(thePlayer, command, vehicleModel) local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if (createdVehicle == false) then outputChatBox("Vehicle Creation Failed.", thePlayer) end end addCommandHandler("createvehicle", createVehicleForPlayer) Link to comment
eAi Posted May 3, 2011 Share Posted May 3, 2011 No, Lua Doesn't have a 'main' function as other lower-level languages tend to. The MTA onResourceStart event is somewhat equivalent, or you can place code outside any function and that will be run when the script is loaded. 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