Legenden Posted December 30, 2011 Posted December 30, 2011 Hello, I'd like a hand for my first script. I'm a total rookie. So according to MTA wiki I had to write this: "YourName" type="gamemode" name="My Server" description="My first MTA DM server" /> But as I loaded the resource in my server it said: [04:22:15] SCRIPT ERROR: myserver/newb.lua:9: '' expected near 'end' Help please.
0 Jaysds1 Posted December 30, 2011 Posted December 30, 2011 This is the wrong place to post this but i'll help... The meta.xml file should have everything that is included in your resource, so if you create another file, it should be put in the meta.xml as: <script src="newb.lua" /> Moderator, Can you move this to the scripting section please
0 Legenden Posted December 31, 2011 Author Posted December 31, 2011 This is the wrong place to post this but i'll help...The meta.xml file should have everything that is included in your resource, so if you create another file, it should be put in the meta.xml as: <script src="newb.lua" /> Moderator, Can you move this to the scripting section please I did that at the first time, I just copied the example from wiki.
0 myonlake Posted December 31, 2011 Posted December 31, 2011 This is the wrong place to post this but i'll help...The meta.xml file should have everything that is included in your resource, so if you create another file, it should be put in the meta.xml as: <script src="newb.lua" /> Moderator, Can you move this to the scripting section please I did that at the first time, I just copied the example from wiki. This is the wrong board to put the thread, however, I'd like to see the lines from 0-10.
0 Jaysds1 Posted December 31, 2011 Posted December 31, 2011 ok, the problem is in the script, can you post the script please
0 Legenden Posted January 1, 2012 Author Posted January 1, 2012 The newb.lua file: local spawnX, spawnY, spawnZ = 386, -1926, 1 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to My Server", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) end function createVehicleForPlayer(thePlayer, spawn, 468) local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(468),x,y,z) if (createdVehicle == false) then outputChatBox("fail",thePlayer) end end addCommandHandler ("createvehicle", createVehicleForPlayer) The meta.xml file: "Legenden" type="gamemode" name="My Server" description="First attempt in scripting" /> (thePlayer, spawn, 468) - if you wonder what this means: -- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel function createVehicleForPlayer(thePlayer, command, vehicleModel) -- create a vehicle and stuff end -- create a command handler addCommandHandler("createvehicle", createVehicleForPlayer)
0 Sparrow Posted January 1, 2012 Posted January 1, 2012 this is it: local spawnX, spawnY, spawnZ = 386, -1926, 1 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to My Server", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) function createVehicleForPlayer(thePlayer, spawn, 468) local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(468),x,y,z) if (createdVehicle == false) then outputChatBox("fail",thePlayer) end end addCommandHandler ("createvehicle", createVehicleForPlayer) I only remove the 'end' after addEventHandler("onPlayerJoin", getRootElement(), joinHandler)
0 Legenden Posted January 1, 2012 Author Posted January 1, 2012 this is it: local spawnX, spawnY, spawnZ = 386, -1926, 1 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to My Server", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) function createVehicleForPlayer(thePlayer, spawn, 468) local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(468),x,y,z) if (createdVehicle == false) then outputChatBox("fail",thePlayer) end end addCommandHandler ("createvehicle", createVehicleForPlayer) I only remove the 'end' after addEventHandler("onPlayerJoin", getRootElement(), joinHandler) Like this it says: [00:49:32] Script error: myserver\newb.lua:9: or "...." expected near '468' Thanks anyway.
0 Sparrow Posted January 1, 2012 Posted January 1, 2012 This is it: local spawnX, spawnY, spawnZ = 386, -1926, 1 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to My Server", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) function createVehicleForPlayer(thePlayer, spawn) local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(468),x,y,z) if (createdVehicle == false) then outputChatBox("fail",thePlayer) end end addCommandHandler ("createvehicle", createVehicleForPlayer) I test it in my local server and it's working.
0 Legenden Posted January 4, 2012 Author Posted January 4, 2012 Thanks now it's working. That "468" was useless.
Question
Legenden
Hello, I'd like a hand for my first script. I'm a total rookie. So according to MTA wiki I had to write this:
But as I loaded the resource in my server it said:
[04:22:15] SCRIPT ERROR: myserver/newb.lua:9: '' expected near 'end'
Help please.
10 answers to this question
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