Jacksons Posted August 19, 2011 Share Posted August 19, 2011 i need some help. i've started to learn how to script on MTA and so I read the Scripting Introduction on MTA wiki and started making some steps that are being displayed at the page. everything worked well and then i came to the part where is the code for vehicle spawning.at first, i copied the finished code after reading the entire part on the subject and when i started the server, it worked well. i saved the script and the next day it didn't work. i tried to rewrite it myself, i tried everything i could've imagined to get it fixed and it didn't work. I am talking about the following code: function createVehicleForPlayer(thePlayer, command, vehicleModel) local x,y,z = getElementPosition(thePlayer) -- get the position of the player x = x + 5 -- add 5 units to the x position local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) -- check if the return value was ''false'' if (createdVehicle == false) then -- if so, output a message to the chatbox, but only to this player. outputChatBox("Failed to create vehicle.",thePlayer) end end addCommandHandler("createvehicle", createVehicleForPlayer) Also a note: i tried testing the command without these descriptions and the result is the same + i'm using the unofficial MTA script editor to run the script. Can someone tell me what have I done wrong ? Link to comment
Baseplate Posted August 19, 2011 Share Posted August 19, 2011 please use /debugscript 3 ingame so we can know what is the problem Link to comment
JR10 Posted August 19, 2011 Share Posted August 19, 2011 Did you actually start the resource?? Link to comment
Jacksons Posted August 19, 2011 Author Share Posted August 19, 2011 it says ingame "Access denied to 'debugscript'. I tried to enter debugscript myserver in the server console and it says "The syntax is 'debugscript ' EDIT: Yes, i started the resource, written /createvehicle with the car ID i want to spawn, there was NO car, NO error, like what i posted up here never was in the script. Link to comment
JR10 Posted August 19, 2011 Share Posted August 19, 2011 Login an admin account, then do /debugscript 3 again. Link to comment
Jacksons Posted August 19, 2011 Author Share Posted August 19, 2011 Can you please tell me how do i login on an admin account. I apologize, i'm new to MTA scripting and i really don't know how to do it. Link to comment
JR10 Posted August 19, 2011 Share Posted August 19, 2011 Read the Server Manual Or just skip to Adding Administrators Link to comment
Jacksons Posted August 19, 2011 Author Share Posted August 19, 2011 JR10, thank you so so much, i just found out what the problem was, the script didn't work because i wasn't logged in as admin and it didn't create the vehicle when i entered the /createvehicle. It works perfectly for now, i will leave this open for a little while just in case something about that is screwed again. Once again, JR10 thanks. Link to comment
AGENT_STEELMEAT Posted August 19, 2011 Share Posted August 19, 2011 Hey, even though this works: if (createdVehicle == false) then it could shortened to if not createdVehicle then Just a little tip Link to comment
Jacksons Posted August 19, 2011 Author Share Posted August 19, 2011 Thanks for the tip, i'm sure it will come in handy 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