Jump to content

[Help] Script doesn't work - again


MarbleXeno

Recommended Posts

So, hello.

2 hours ago I wrote that I have a problem with the script. I have him again. But i think,  I'm doing everything right now, I don't know what's going on. I am new, so for many the solution can be simple, for me, it is not. I will be very grateful if someone helps me.

After writing command "/createveh" nothing is happening, i don't know why.

SCRIPT (skrypt.Lua)

function createSomeVehicle()
    x, y, z = getElementPosition(getPlayerFromName("Xeno"))
    createVehicle(400, x, y, z)
end

addCommandHandler("createveh", createSomeVehicle)

meta.xml

<meta>
    <source src="skrypt.Lua" type="server" />
</meta>

 

Edited by MarbleXeno
Link to comment
function createSomeVehicle(player, command) -- I believe the player and command arguments are passed automatically when it comes to the Command Handler
    local x, y, z = getElementPosition(player) -- Because we don't need the x, y or z variables after this function, should make those variables local
    createVehicle(400, x, y, z)
end

addCommandHandler("createveh", createSomeVehicle)

However, I did not spot anything wrong with the code you posted, it should have worked as far as I can tell. May seem silly, but are you certain your player name was in fact "Xeno" at the time of using the command? Also, if there are any missing thens or ends, that will stop a script from even loading up. Missing ( )s, accidentally using a . when it should be a , etc etc etc

getElementPosition(Element) - You need the player element, NOT a player name: He was just getting the player element from the player name "Xeno"

Edited by ReZurrecti0n
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...