Jump to content

problem running the script


Jacksons

Recommended Posts

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

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, 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...