Jump to content

My Resource Doesn't worl


Recommended Posts

Hi im created a resource with
meta.xml
server.lua

and

client.lua

 

im making this resource for spawning vehichles with a easy command

my codes are this :

 

function mveh(theplayer,cmd)
 x,y,z = getElementPositon( thePlayer)
 veh = createVehicle ( 400 , x , y, z)
end
addCommandHandler("veh",mveh)
 
i run command /veh in the game and nothing happen
please help me
 

 

Link to comment
Posted (edited)

Hey 👋

The name of the first argument in the function is theplayer with lowercase letters, and when running the subsequent getElementPosition function, you refer to a variable called thePlayer as the first parameter, which does not exist, because you created it earlier with lowercase letters, and Lua is a case sensitive language.
The corrected code:

function mveh(thePlayer,cmd)
 x,y,z = getElementPositon( thePlayer)
 veh = createVehicle ( 400 , x , y, z)
end
addCommandHandler("veh",mveh)


Regards,
Nico.

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